From patchwork Tue Sep 27 02:50:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 12989728 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27476C07E9D for ; Tue, 27 Sep 2022 02:57:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231139AbiI0C5e (ORCPT ); Mon, 26 Sep 2022 22:57:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229719AbiI0C4C (ORCPT ); Mon, 26 Sep 2022 22:56:02 -0400 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A225A5D0D4 for ; Mon, 26 Sep 2022 19:51:19 -0700 (PDT) Received: by mail-qt1-x82f.google.com with SMTP id j10so5310691qtv.4 for ; Mon, 26 Sep 2022 19:51:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=F3pNm/W20l8PIjrNMCG3DOuHAeukeerlsNhlNvML72U=; b=CiZ//Cu5xLWspJ2bFEXuqKVIB8JUaQWbggVtFioxRfQh2n3jBDstrbCV8J9oCYcj3z 6N0RsQ9Xrb2iVkhAg57BnmDIQsOsJsN8SGZdV2qOhXBWDbzHY9QLrdpac11OqsI01L16 BJc6gvtafdRx8K05SH1EXRcwdtMFEzi1VHHJg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=F3pNm/W20l8PIjrNMCG3DOuHAeukeerlsNhlNvML72U=; b=CtD9+mETbdFRS84996fN3cYy/2czycUtkvHpGicdOnUP2AlYq7FC5OqhQlHoq+lxBX 2cmulbwgrh+m5pu30op8NHZ+nce+QuE2zwlgPk8mlnkqHWg+iJpoc9VCQ+Rqi+dJLnUh /1dFB/EeC5lM5AQTygrTLTPy1W9+BxOlE2034UJlmgt35ROweRYH6XZ+sBOgIDriYDlA EO5k2c1mdLU++ZXsRsn66c7ndfHHqDs9J4YWGdFOjkwaWzsm6TzFBcFsSzesJZfRLtjO R4UBXJHkATpz2F4BOYM7k5CCQLv1cCg9Yopg4IdPVdsgICt/m9B50CNfTju4wFsDAWoU WChg== X-Gm-Message-State: ACrzQf3Dt0GG2ZXfOCuWMuRxdPyLNHg4c6/IsAore7QY6X2+BGx2VMGC Rgr34CxeP245BVVW9Q8podfFdA== X-Google-Smtp-Source: AMsMyM60D8LyEwc7BF2TtRbUsvPreL3iK2mFzmlHJHf8/oK7qhwx79o8gDPnWnBsMZBpYy46T4+1Pw== X-Received: by 2002:ac8:5f08:0:b0:35c:cbe5:4b83 with SMTP id x8-20020ac85f08000000b0035ccbe54b83mr20731629qta.218.1664247078800; Mon, 26 Sep 2022 19:51:18 -0700 (PDT) Received: from roguebox.lan ([164.92.70.235]) by smtp.gmail.com with ESMTPSA id y5-20020a37f605000000b006bb0f9b89cfsm199620qkj.87.2022.09.26.19.51.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 19:51:18 -0700 (PDT) From: Matt Ranostay To: jic23@kernel.org, gupt21@gmail.com, benjamin.tissoires@redhat.com, jikos@kernel.org Cc: linux-input@vger.kernel.org, linux-iio@vger.kernel.org, linux-i2c@vger.kernel.org, Matt Ranostay Subject: [PATCH v5 1/5] i2c: muxes: ltc4306: fix future recursive dependencies Date: Mon, 26 Sep 2022 19:50:46 -0700 Message-Id: <20220927025050.13316-2-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220927025050.13316-1-matt.ranostay@konsulko.com> References: <20220927025050.13316-1-matt.ranostay@konsulko.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org When using 'imply IIO' for other configurations which have 'select GPIOLIB' the following recursive dependency is detected for I2C_MUX_LTC4306 Switch from 'select GPIOLIB' to 'depends on GPIOLIB' to avoid this per recommendation in kconfig-language.rst drivers/gpio/Kconfig:14:error: recursive dependency detected! drivers/gpio/Kconfig:14: symbol GPIOLIB is selected by I2C_MUX_LTC4306 drivers/i2c/muxes/Kconfig:47: symbol I2C_MUX_LTC4306 depends on I2C_MUX drivers/i2c/Kconfig:62: symbol I2C_MUX is selected by MPU3050_I2C drivers/iio/gyro/Kconfig:127: symbol MPU3050_I2C depends on IIO drivers/iio/Kconfig:6: symbol IIO is implied by HID_MCP2221 drivers/hid/Kconfig:1227: symbol HID_MCP2221 depends on GPIOLIB Signed-off-by: Matt Ranostay --- drivers/i2c/muxes/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/muxes/Kconfig b/drivers/i2c/muxes/Kconfig index 1708b1a82da2..8642ea8e0a3d 100644 --- a/drivers/i2c/muxes/Kconfig +++ b/drivers/i2c/muxes/Kconfig @@ -46,7 +46,7 @@ config I2C_MUX_GPMUX config I2C_MUX_LTC4306 tristate "LTC LTC4306/5 I2C multiplexer" - select GPIOLIB + depends on GPIOLIB select REGMAP_I2C help If you say yes here you get support for the Analog Devices From patchwork Tue Sep 27 02:50:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 12989729 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BEF1C6FA90 for ; Tue, 27 Sep 2022 02:57:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229703AbiI0C5g (ORCPT ); Mon, 26 Sep 2022 22:57:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230249AbiI0C4D (ORCPT ); Mon, 26 Sep 2022 22:56:03 -0400 Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [IPv6:2607:f8b0:4864:20::f2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2187761D77 for ; Mon, 26 Sep 2022 19:51:22 -0700 (PDT) Received: by mail-qv1-xf2a.google.com with SMTP id ml1so5509007qvb.1 for ; Mon, 26 Sep 2022 19:51:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=fjKONfzvcToa9xf9WhGIF//2C04Wz2LbGFmYzFaCWaU=; b=CiSyL6z+RZVWIzvY/ORpUNqpSkwc5IPLOV1dufLUixrZPX7+PbcYiRajuaQEz2R/cj lwg8wVZyfz4a3LLzLPTaS3UNOwfM1seVXVGmibCrXtUY2B1eX7xgEjBPpFbqhbker0eZ vtInG6pQu0HM7ZOnjUeWhv68JfdgeXzNYjiCU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=fjKONfzvcToa9xf9WhGIF//2C04Wz2LbGFmYzFaCWaU=; b=NYX4OzzdfBeJtvNq7BEDlfrQm7/iD0dVzoLVcPAjWt0fXEccemvC4YIQVWTInI4bgJ dxakbtQ5fe5ld39k+xOsHNs0skakfHjrYFxwLSqeDKEdKTZbcDwDlvKi5iLivtPq9q2f bmVXz8eEtZORT1ES+HEmk9UldoS1pE3q5l2vwdtSl1tTpOWZ/9JU9wya/2NYIRtUCGW+ VKYqsfyEbyFtiurMWkv3S1Y17DcQNs+qYrpPBISzun8ZBSzxtwSyagL1BJ+QMooBaBxL VvL9bb5439ImjUb48fCKPPxSsEkq2JOwjpGSeaGPiHxinslBp4JVI9OK0Ls/9zdX13Vo iQdg== X-Gm-Message-State: ACrzQf0RluUuGxg6xj53+UDABfmRMUAe88WVf0CJjzapU6fVk7lM3URz Q+coaYwQUym2HCowBK6b16Hjjw== X-Google-Smtp-Source: AMsMyM72trpFIIWMM6yZqeQ1QFTb3xFCWBDapjcF0kwjXqlIJHMlYir+1g3Ne0O+Le9/E4U75mAQ4A== X-Received: by 2002:a05:6214:f6d:b0:4ac:a1ca:9de4 with SMTP id iy13-20020a0562140f6d00b004aca1ca9de4mr19621704qvb.62.1664247081189; Mon, 26 Sep 2022 19:51:21 -0700 (PDT) Received: from roguebox.lan ([164.92.70.235]) by smtp.gmail.com with ESMTPSA id y5-20020a37f605000000b006bb0f9b89cfsm199620qkj.87.2022.09.26.19.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 19:51:20 -0700 (PDT) From: Matt Ranostay To: jic23@kernel.org, gupt21@gmail.com, benjamin.tissoires@redhat.com, jikos@kernel.org Cc: linux-input@vger.kernel.org, linux-iio@vger.kernel.org, linux-i2c@vger.kernel.org, Matt Ranostay Subject: [PATCH v5 2/5] iio: adc: stx104: fix future recursive dependencies Date: Mon, 26 Sep 2022 19:50:47 -0700 Message-Id: <20220927025050.13316-3-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220927025050.13316-1-matt.ranostay@konsulko.com> References: <20220927025050.13316-1-matt.ranostay@konsulko.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org When using 'imply IIO' for other configurations which have 'select GPIOLIB' the following recursive dependency is detected for STX1040 Switch from 'select GPIOLIB' to 'depends on GPIOLIB' to avoid this per recommendation in kconfig-language.rst drivers/gpio/Kconfig:14:error: recursive dependency detected! drivers/gpio/Kconfig:14: symbol GPIOLIB is selected by STX104 drivers/iio/adc/Kconfig:20: symbol STX104 depends on IIO drivers/iio/Kconfig:6: symbol IIO is implied by HID_MCP2221 drivers/hid/Kconfig:1227: symbol HID_MCP2221 depends on GPIOLIB Signed-off-by: Matt Ranostay --- drivers/iio/adc/Kconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 7fe5930891e0..929dd9493479 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -1024,9 +1024,8 @@ config STMPE_ADC config STX104 tristate "Apex Embedded Systems STX104 driver" - depends on PC104 && X86 + depends on PC104 && X86 && GPIOLIB select ISA_BUS_API - select GPIOLIB help Say yes here to build support for the Apex Embedded Systems STX104 integrated analog PC/104 card. From patchwork Tue Sep 27 02:50:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 12989730 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9632C6FA92 for ; Tue, 27 Sep 2022 02:57:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230330AbiI0C5i (ORCPT ); Mon, 26 Sep 2022 22:57:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230386AbiI0C4P (ORCPT ); Mon, 26 Sep 2022 22:56:15 -0400 Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CC6F6E888 for ; Mon, 26 Sep 2022 19:51:24 -0700 (PDT) Received: by mail-qt1-x834.google.com with SMTP id y2so5310023qtv.5 for ; Mon, 26 Sep 2022 19:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=3OBHFG8N1Wi/0+IDhzqdlFHWU7KQ36OfnHlG8UgKWrs=; b=fvl0FxpxnAb2ElYyhcyhcRlNeE/qyGMjB/hqO4hopozUF+IsxRG2ZcBOIN63Ua8qiP iphLcUjZm+zqkgEY4OJRgnfJboia7qgCL2ahnT2Mrnhoy1G0ExREY8nqcrfLsTlSr0D9 hdZRaKuvEoDjIUK3mOsanFAnGzVYq1QUosq7M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=3OBHFG8N1Wi/0+IDhzqdlFHWU7KQ36OfnHlG8UgKWrs=; b=8F3Cll9BptiVeJQygU/145isE85RySU5Zz1NItYprSopRGIsG1bwmNGHt+Tvu7p34F pn8Zp63WAVAHu6t8+ndUPoI4+eOPlSPhkhSdJRmQCLcLKUU0nzrFshsVSHQyeVZU5MBA HkGRGVdmZIUWKY4SJosBCI8H/BEQjCmHIgsqdotmmLki2gaV9fW0J3w/oMFrEHZl1q03 Xv5dNRMuSLJLSAzLXiZZAKAIRwjLl8Hx0h9XPRlltzGziiAjEWmC6hx+VJ+LcHX+UIlJ /X6r82rZyzCC76YvL5NyAqEgBljmbT9VjPDc4omXotzVoaTOB+Ta0DYEMimqTcG74Kx5 tWoQ== X-Gm-Message-State: ACrzQf2u8t8yKyQexOiCPGUiUtBCd7ZjM0jAAa0YkP/PJr02cYn6f5Fo yjXnj28rul89OX+CN+j2RhMd6IRyiV1a+o5e X-Google-Smtp-Source: AMsMyM6Ycp2k/KnZ3joMhOyXWsmYanW6wkY4ckTXs6DGSEZsX2auFfpAzZ257aA1YYi8p0crsTKI3w== X-Received: by 2002:ac8:584c:0:b0:35c:ceee:197a with SMTP id h12-20020ac8584c000000b0035cceee197amr20960705qth.662.1664247083421; Mon, 26 Sep 2022 19:51:23 -0700 (PDT) Received: from roguebox.lan ([164.92.70.235]) by smtp.gmail.com with ESMTPSA id y5-20020a37f605000000b006bb0f9b89cfsm199620qkj.87.2022.09.26.19.51.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 19:51:22 -0700 (PDT) From: Matt Ranostay To: jic23@kernel.org, gupt21@gmail.com, benjamin.tissoires@redhat.com, jikos@kernel.org Cc: linux-input@vger.kernel.org, linux-iio@vger.kernel.org, linux-i2c@vger.kernel.org, Matt Ranostay Subject: [PATCH v5 3/5] iio: dac: fix future recursive dependencies Date: Mon, 26 Sep 2022 19:50:48 -0700 Message-Id: <20220927025050.13316-4-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220927025050.13316-1-matt.ranostay@konsulko.com> References: <20220927025050.13316-1-matt.ranostay@konsulko.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org When using 'imply IIO' for other configurations which have 'select GPIOLIB' the following recursive dependency is detected for AD5592R/AD5593R Switch from 'select GPIOLIB' to 'depends on GPIOLIB' to avoid this per recommendation in kconfig-language.rst drivers/gpio/Kconfig:14:error: recursive dependency detected! drivers/gpio/Kconfig:14: symbol GPIOLIB is selected by AD5592R drivers/iio/dac/Kconfig:93: symbol AD5592R depends on IIO drivers/iio/Kconfig:6: symbol IIO is implied by HID_MCP2221 drivers/hid/Kconfig:1227: symbol HID_MCP2221 depends on GPIOLIB Signed-off-by: Matt Ranostay --- drivers/iio/dac/Kconfig | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig index 80521bd28d0f..b93003e80b70 100644 --- a/drivers/iio/dac/Kconfig +++ b/drivers/iio/dac/Kconfig @@ -92,8 +92,7 @@ config AD5592R_BASE config AD5592R tristate "Analog Devices AD5592R ADC/DAC driver" - depends on SPI_MASTER - select GPIOLIB + depends on SPI_MASTER && GPIOLIB select AD5592R_BASE help Say yes here to build support for Analog Devices AD5592R @@ -104,8 +103,7 @@ config AD5592R config AD5593R tristate "Analog Devices AD5593R ADC/DAC driver" - depends on I2C - select GPIOLIB + depends on I2C && GPIOLIB select AD5592R_BASE help Say yes here to build support for Analog Devices AD5593R From patchwork Tue Sep 27 02:50:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 12989731 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7EDDC6FA82 for ; Tue, 27 Sep 2022 02:57:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231159AbiI0C5j (ORCPT ); Mon, 26 Sep 2022 22:57:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230404AbiI0C4o (ORCPT ); Mon, 26 Sep 2022 22:56:44 -0400 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEC9374CE1 for ; Mon, 26 Sep 2022 19:51:25 -0700 (PDT) Received: by mail-qt1-x835.google.com with SMTP id g12so5328242qts.1 for ; Mon, 26 Sep 2022 19:51:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Vh4rdFc767lJKefOOjqse4JvtQ6pHDKw9Ksf9KEoCe8=; b=JIfkxgHmjDQK6XSML8XAScC4bY1vjPXKRxOGDkA2hFc1P1H+a6pINq0EfU1ue0WImJ UIX/GzhFzs1fhUGk7SWHjevN5+2MBrNstZMV5tXU9sUPH3XIls+vab4gk/3EYmnQIJHM L/UzDNYehbOw87q5oOw4XktGXs3gbpaIZERLo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Vh4rdFc767lJKefOOjqse4JvtQ6pHDKw9Ksf9KEoCe8=; b=J3cQY14tqV29qbtmTYAU3vtVZByLWm3zkMFju21XICEXfZl0sAIGEN2Uc6rYbmM6CC UkuQqFNeN222/R8mszmSHTbj2TS+gstazh0avYxp9GjTNvna2MCBzDgWnRykXVeDhTJd PcqPy+4tthJVp0Gcky+gkxalS+Z4/6WYPz1IrRk8HOV6tZrDv8aIpxUHXml7Xti0yJc7 rOgAynVbzFUcn/oDqcaoQIUJ3P/i+z8SCfLrjnSU/R/9+uM6hIduJRk/rZgDTED5gLD+ yCrdUkL6Y5a2fPybZ7TXGYELNe3V4dHwZgtdKn6LMvfmStOynD07O0o+5ddXjDsIYVrh GKtQ== X-Gm-Message-State: ACrzQf0mfXZU9Sgz6Yrh5yEd7D1UPM4Xzq08SH4KScNI7cucQtxGp+gL NlHNIV03ihb100YoL0+1VPBKEjOkpWu6pB+T X-Google-Smtp-Source: AMsMyM7nB4J0F/dZdMpx0HjSKJ+CMikkeV5pfKaPVLJeZTNwtv2Qc7tEvK7/6L3ynkA6gIRUVOhfXg== X-Received: by 2002:a05:622a:1053:b0:35c:bab4:bd80 with SMTP id f19-20020a05622a105300b0035cbab4bd80mr20660628qte.189.1664247085607; Mon, 26 Sep 2022 19:51:25 -0700 (PDT) Received: from roguebox.lan ([164.92.70.235]) by smtp.gmail.com with ESMTPSA id y5-20020a37f605000000b006bb0f9b89cfsm199620qkj.87.2022.09.26.19.51.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 19:51:25 -0700 (PDT) From: Matt Ranostay To: jic23@kernel.org, gupt21@gmail.com, benjamin.tissoires@redhat.com, jikos@kernel.org Cc: linux-input@vger.kernel.org, linux-iio@vger.kernel.org, linux-i2c@vger.kernel.org, Matt Ranostay Subject: [PATCH v5 4/5] HID: mcp2221: switch i2c registration to devm functions Date: Mon, 26 Sep 2022 19:50:49 -0700 Message-Id: <20220927025050.13316-5-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220927025050.13316-1-matt.ranostay@konsulko.com> References: <20220927025050.13316-1-matt.ranostay@konsulko.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Switch from i2c_add_adapter() to resource managed devm_i2c_add_adapter() for matching rest of driver initialization, and more concise code. Signed-off-by: Matt Ranostay --- drivers/hid/hid-mcp2221.c | 51 ++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c index de52e9f7bb8c..3365e21547c6 100644 --- a/drivers/hid/hid-mcp2221.c +++ b/drivers/hid/hid-mcp2221.c @@ -824,6 +824,21 @@ static int mcp2221_raw_event(struct hid_device *hdev, return 1; } +/* Device resource managed function for HID unregistration */ +static void mcp2221_hid_unregister(void *ptr) +{ + struct hid_device *hdev = ptr; + + hid_hw_close(hdev); + hid_hw_stop(hdev); +} + +/* This is needed to be sure hid_hw_stop() isn't called twice by the subsystem */ +static void mcp2221_remove(struct hid_device *hdev) +{ + return; +} + static int mcp2221_probe(struct hid_device *hdev, const struct hid_device_id *id) { @@ -849,7 +864,8 @@ static int mcp2221_probe(struct hid_device *hdev, ret = hid_hw_open(hdev); if (ret) { hid_err(hdev, "can't open device\n"); - goto err_hstop; + hid_hw_stop(hdev); + return ret; } mutex_init(&mcp->lock); @@ -857,6 +873,10 @@ static int mcp2221_probe(struct hid_device *hdev, hid_set_drvdata(hdev, mcp); mcp->hdev = hdev; + ret = devm_add_action_or_reset(&hdev->dev, mcp2221_hid_unregister, hdev); + if (ret) + return ret; + /* Set I2C bus clock diviser */ if (i2c_clk_freq > 400) i2c_clk_freq = 400; @@ -873,19 +893,17 @@ static int mcp2221_probe(struct hid_device *hdev, "MCP2221 usb-i2c bridge on hidraw%d", ((struct hidraw *)hdev->hidraw)->minor); - ret = i2c_add_adapter(&mcp->adapter); + ret = devm_i2c_add_adapter(&hdev->dev, &mcp->adapter); if (ret) { hid_err(hdev, "can't add usb-i2c adapter: %d\n", ret); - goto err_i2c; + return ret; } i2c_set_adapdata(&mcp->adapter, mcp); /* Setup GPIO chip */ mcp->gc = devm_kzalloc(&hdev->dev, sizeof(*mcp->gc), GFP_KERNEL); - if (!mcp->gc) { - ret = -ENOMEM; - goto err_gc; - } + if (!mcp->gc) + return -ENOMEM; mcp->gc->label = "mcp2221_gpio"; mcp->gc->direction_input = mcp_gpio_direction_input; @@ -900,26 +918,9 @@ static int mcp2221_probe(struct hid_device *hdev, ret = devm_gpiochip_add_data(&hdev->dev, mcp->gc, mcp); if (ret) - goto err_gc; + return ret; return 0; - -err_gc: - i2c_del_adapter(&mcp->adapter); -err_i2c: - hid_hw_close(mcp->hdev); -err_hstop: - hid_hw_stop(mcp->hdev); - return ret; -} - -static void mcp2221_remove(struct hid_device *hdev) -{ - struct mcp2221 *mcp = hid_get_drvdata(hdev); - - i2c_del_adapter(&mcp->adapter); - hid_hw_close(mcp->hdev); - hid_hw_stop(mcp->hdev); } static const struct hid_device_id mcp2221_devices[] = { From patchwork Tue Sep 27 02:50:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 12989732 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A04DC07E9D for ; Tue, 27 Sep 2022 02:57:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230422AbiI0C5k (ORCPT ); Mon, 26 Sep 2022 22:57:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230430AbiI0C5S (ORCPT ); Mon, 26 Sep 2022 22:57:18 -0400 Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED5EB80BE7 for ; Mon, 26 Sep 2022 19:51:28 -0700 (PDT) Received: by mail-qv1-xf35.google.com with SMTP id i15so5494923qvp.5 for ; Mon, 26 Sep 2022 19:51:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=puxbil75WqJcR5kGhdtSOI7FdeieA+yyTnzxxJR0if4=; b=FsniAfNd99uojcJzGEUIcu7bFftKLRvs5Z9rKdECS6lXM4yNv0a5toQaw9iVIoupaL ecLsV9jD7uOG5BijA88d/VwpZdRilnvucZzv9Q3LKxM5/Cxbk5rY3CYBNaFaBG0TdZt/ +tNo4T1uIjAwUXC1eZymNBjxO0Rf1vi0+yAww= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=puxbil75WqJcR5kGhdtSOI7FdeieA+yyTnzxxJR0if4=; b=7ESFvxXkiv3v7wLaEXJzPU3TTUQVGNFaY6ToOuMZDdRVYPxBpiCvICl0xzaqIOSKqe iC5eCNlySg6ZRdGJUfA9iF6t3vo1wtY1mCJbW+fjnywU9sR/ItQbNJ3dldz4t7HtMcfW gQ56kbHmQ4sZcYLPaspmYk5K9+w+7qctanx0A8LdlhNn40VV/tqs8Ji4M0C/hiUD6Kij /gnmbP5L9QNgjqoBkrF0Z8fYGpZ7FcIv3ydVU/og0umRdBL7V+OzUqxVlQoVHSoVU/NM 9E24hX5UygrvaBR785+8x00HZ130int09/ADou61s1LEoWuvAaSS003tKhvJ6WauGFWv gmxw== X-Gm-Message-State: ACrzQf2NJ3QaDuS81UpjK5BwFdsJugrTlK9VXyM5UZyRf/fqGG8mT+pm qEE/MpGyCCfu/BAbZTzigyE3IQ== X-Google-Smtp-Source: AMsMyM5TQ7F3e/W5Z+m8FlDxJ5X9MhNTUfVrUXap0yjZ7iLSJevmAO1ejSVMwhpgbdYI6nYVmkt8ZQ== X-Received: by 2002:ad4:5fc9:0:b0:4ad:7802:c31b with SMTP id jq9-20020ad45fc9000000b004ad7802c31bmr19568061qvb.116.1664247088064; Mon, 26 Sep 2022 19:51:28 -0700 (PDT) Received: from roguebox.lan ([164.92.70.235]) by smtp.gmail.com with ESMTPSA id y5-20020a37f605000000b006bb0f9b89cfsm199620qkj.87.2022.09.26.19.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 19:51:27 -0700 (PDT) From: Matt Ranostay To: jic23@kernel.org, gupt21@gmail.com, benjamin.tissoires@redhat.com, jikos@kernel.org Cc: linux-input@vger.kernel.org, linux-iio@vger.kernel.org, linux-i2c@vger.kernel.org, Matt Ranostay Subject: [PATCH v5 5/5] HID: mcp2221: add ADC/DAC support via iio subsystem Date: Mon, 26 Sep 2022 19:50:50 -0700 Message-Id: <20220927025050.13316-6-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220927025050.13316-1-matt.ranostay@konsulko.com> References: <20220927025050.13316-1-matt.ranostay@konsulko.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add support for 3x 10-bit ADC and 1x DAC channels registered via the iio subsystem. To prevent breakage and unexpected dependencies this support only is only built if CONFIG_IIO is enabled, and is only weakly referenced by 'imply IIO' within the respective Kconfig. Additionally the iio device only gets registered if at least one channel is enabled in the power-on configuration read from SRAM. Signed-off-by: Matt Ranostay --- drivers/hid/Kconfig | 1 + drivers/hid/hid-mcp2221.c | 258 +++++++++++++++++++++++++++++++++++++- 2 files changed, 258 insertions(+), 1 deletion(-) diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 6ce92830b5d1..8ee4a4a852a1 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -1299,6 +1299,7 @@ config HID_MCP2221 tristate "Microchip MCP2221 HID USB-to-I2C/SMbus host support" depends on USB_HID && I2C depends on GPIOLIB + imply IIO help Provides I2C and SMBUS host adapter functionality over USB-HID through MCP2221 device. diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c index 3365e21547c6..fdffd12bc3b6 100644 --- a/drivers/hid/hid-mcp2221.c +++ b/drivers/hid/hid-mcp2221.c @@ -10,12 +10,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include "hid-ids.h" /* Commands codes in a raw output report */ @@ -30,6 +32,9 @@ enum { MCP2221_I2C_CANCEL = 0x10, MCP2221_GPIO_SET = 0x50, MCP2221_GPIO_GET = 0x51, + MCP2221_SET_SRAM_SETTINGS = 0x60, + MCP2221_GET_SRAM_SETTINGS = 0x61, + MCP2221_READ_FLASH_DATA = 0xb0, }; /* Response codes in a raw input report */ @@ -89,6 +94,7 @@ struct mcp2221 { struct i2c_adapter adapter; struct mutex lock; struct completion wait_in_report; + struct delayed_work init_work; u8 *rxbuf; u8 txbuf[64]; int rxbuf_idx; @@ -97,6 +103,18 @@ struct mcp2221 { struct gpio_chip *gc; u8 gp_idx; u8 gpio_dir; + u8 mode[4]; +#if IS_REACHABLE(CONFIG_IIO) + struct iio_chan_spec iio_channels[3]; + u16 adc_values[3]; + u8 adc_scale; + u8 dac_value; + u16 dac_scale; +#endif +}; + +struct mcp2221_iio { + struct mcp2221 *mcp; }; /* @@ -713,7 +731,7 @@ static int mcp_get_i2c_eng_state(struct mcp2221 *mcp, static int mcp2221_raw_event(struct hid_device *hdev, struct hid_report *report, u8 *data, int size) { - u8 *buf; + u8 *buf, tmp; struct mcp2221 *mcp = hid_get_drvdata(hdev); switch (data[0]) { @@ -745,6 +763,9 @@ static int mcp2221_raw_event(struct hid_device *hdev, break; } mcp->status = mcp_get_i2c_eng_state(mcp, data, 8); +#if IS_REACHABLE(CONFIG_IIO) + memcpy(&mcp->adc_values, &data[50], sizeof(mcp->adc_values)); +#endif break; default: mcp->status = -EIO; @@ -816,6 +837,66 @@ static int mcp2221_raw_event(struct hid_device *hdev, complete(&mcp->wait_in_report); break; + case MCP2221_SET_SRAM_SETTINGS: + switch (data[1]) { + case MCP2221_SUCCESS: + mcp->status = 0; + break; + default: + mcp->status = -EAGAIN; + } + complete(&mcp->wait_in_report); + break; + + case MCP2221_GET_SRAM_SETTINGS: + switch (data[1]) { + case MCP2221_SUCCESS: + memcpy(&mcp->mode, &data[22], 4); +#if IS_REACHABLE(CONFIG_IIO) + mcp->dac_value = data[6] & GENMASK(4, 0); +#endif + mcp->status = 0; + break; + default: + mcp->status = -EAGAIN; + } + complete(&mcp->wait_in_report); + break; + + case MCP2221_READ_FLASH_DATA: + switch (data[1]) { + case MCP2221_SUCCESS: + mcp->status = 0; + + /* Only handles CHIP SETTINGS subpage currently */ + if (mcp->txbuf[1] != 0) { + mcp->status = -EIO; + break; + } + +#if IS_REACHABLE(CONFIG_IIO) + /* DAC scale value */ + tmp = FIELD_GET(GENMASK(7, 6), data[6]); + if ((data[6] & BIT(5)) && tmp) + mcp->dac_scale = tmp + 4; + else + mcp->dac_scale = 5; + + /* ADC scale value */ + tmp = FIELD_GET(GENMASK(4, 3), data[7]); + if ((data[7] & BIT(2)) && tmp) + mcp->adc_scale = tmp - 1; + else + mcp->adc_scale = 0; +#endif + + break; + default: + mcp->status = -EAGAIN; + } + complete(&mcp->wait_in_report); + break; + default: mcp->status = -EIO; complete(&mcp->wait_in_report); @@ -839,6 +920,176 @@ static void mcp2221_remove(struct hid_device *hdev) return; } +#if IS_REACHABLE(CONFIG_IIO) +static int mcp2221_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *channel, int *val, + int *val2, long mask) +{ + struct mcp2221_iio *priv = iio_priv(indio_dev); + struct mcp2221 *mcp = priv->mcp; + int ret; + + if (mask == IIO_CHAN_INFO_SCALE) { + if (channel->output) + *val = 1 << mcp->dac_scale; + else + *val = 1 << mcp->adc_scale; + + return IIO_VAL_INT; + } + + mutex_lock(&mcp->lock); + + if (channel->output) { + *val = mcp->dac_value; + ret = IIO_VAL_INT; + } else { + /* Read ADC values */ + ret = mcp_chk_last_cmd_status(mcp); + + if (!ret) { + *val = le16_to_cpu(mcp->adc_values[channel->address]); + if (*val >= BIT(10)) + ret = -EINVAL; + else + ret = IIO_VAL_INT; + } + } + + mutex_unlock(&mcp->lock); + + return ret; +} + +static int mcp2221_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct mcp2221_iio *priv = iio_priv(indio_dev); + struct mcp2221 *mcp = priv->mcp; + int ret; + + if (val < 0 || val >= BIT(5)) + return -EINVAL; + + mutex_lock(&mcp->lock); + + memset(mcp->txbuf, 0, 12); + mcp->txbuf[0] = MCP2221_SET_SRAM_SETTINGS; + mcp->txbuf[4] = BIT(7) | val; + + ret = mcp_send_data_req_status(mcp, mcp->txbuf, 12); + if (!ret) + mcp->dac_value = val; + + mutex_unlock(&mcp->lock); + + return ret; +} + +static const struct iio_info mcp2221_info = { + .read_raw = &mcp2221_read_raw, + .write_raw = &mcp2221_write_raw, +}; + +static int mcp_iio_channels(struct mcp2221 *mcp) +{ + int idx, cnt = 0; + bool dac_created = false; + + /* GP0 doesn't have ADC/DAC alternative function */ + for (idx = 1; idx < MCP_NGPIO; idx++) { + struct iio_chan_spec *chan = &mcp->iio_channels[cnt]; + + switch (mcp->mode[idx]) { + case 2: + chan->address = idx - 1; + chan->channel = cnt++; + break; + case 3: + /* GP1 doesn't have DAC alternative function */ + if (idx == 1 || dac_created) + continue; + /* DAC1 and DAC2 outputs are connected to the same DAC */ + dac_created = true; + chan->output = 1; + cnt++; + break; + default: + continue; + }; + + chan->type = IIO_VOLTAGE; + chan->indexed = 1; + chan->info_mask_separate = BIT(IIO_CHAN_INFO_RAW); + chan->info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE); + chan->scan_index = -1; + } + + return cnt; +} + +static void mcp_init_work(struct work_struct *work) +{ + struct iio_dev *indio_dev; + struct mcp2221 *mcp = container_of(work, struct mcp2221, init_work.work); + struct mcp2221_iio *data; + static int retries = 5; + int ret, num_channels; + + hid_hw_power(mcp->hdev, PM_HINT_FULLON); + mutex_lock(&mcp->lock); + + mcp->txbuf[0] = MCP2221_GET_SRAM_SETTINGS; + ret = mcp_send_data_req_status(mcp, mcp->txbuf, 1); + + if (ret == -EAGAIN) + goto reschedule_task; + + num_channels = mcp_iio_channels(mcp); + if (!num_channels) + goto unlock; + + mcp->txbuf[0] = MCP2221_READ_FLASH_DATA; + mcp->txbuf[1] = 0; + ret = mcp_send_data_req_status(mcp, mcp->txbuf, 2); + + if (ret == -EAGAIN) + goto reschedule_task; + + indio_dev = devm_iio_device_alloc(&mcp->hdev->dev, sizeof(*data)); + if (!indio_dev) + goto unlock; + + data = iio_priv(indio_dev); + data->mcp = mcp; + + indio_dev->name = "mcp2221"; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &mcp2221_info; + indio_dev->channels = mcp->iio_channels; + indio_dev->num_channels = num_channels; + + devm_iio_device_register(&mcp->hdev->dev, indio_dev); + +unlock: + mutex_unlock(&mcp->lock); + hid_hw_power(mcp->hdev, PM_HINT_NORMAL); + + return; + +reschedule_task: + mutex_unlock(&mcp->lock); + hid_hw_power(mcp->hdev, PM_HINT_NORMAL); + + if (!retries--) + return; + + /* Device is not ready to read SRAM or FLASH data, try again */ + schedule_delayed_work(&mcp->init_work, msecs_to_jiffies(100)); +} +#endif + static int mcp2221_probe(struct hid_device *hdev, const struct hid_device_id *id) { @@ -920,6 +1171,11 @@ static int mcp2221_probe(struct hid_device *hdev, if (ret) return ret; +#if IS_REACHABLE(CONFIG_IIO) + INIT_DELAYED_WORK(&mcp->init_work, mcp_init_work); + schedule_delayed_work(&mcp->init_work, msecs_to_jiffies(100)); +#endif + return 0; }