From patchwork Wed Sep 21 06:30:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 608065 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 99BB0C6FA91 for ; Wed, 21 Sep 2022 06:31:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229703AbiIUGbD (ORCPT ); Wed, 21 Sep 2022 02:31:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229819AbiIUGav (ORCPT ); Wed, 21 Sep 2022 02:30:51 -0400 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D1A22AC5F for ; Tue, 20 Sep 2022 23:30:49 -0700 (PDT) Received: by mail-qk1-x72b.google.com with SMTP id h28so3379434qka.0 for ; Tue, 20 Sep 2022 23:30:49 -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=/093o1NxENUaTouo0Mdw75upRRId/THkS7GyiJgLLTE=; b=FgUmzi1dfdXBxW+EWGXKjLCCuHAwhBsR5vQEA9muOyMr3dKPjhQ2mBAg9784oU0vcW QOuE694beWFUhq9p6GmdXGsPjvjTIQJTbxYECtkIYuUDiq6qZBgne0upMcPEUNhDym1E XX6BATaZn61RKYAd5Gzu/uG0Z07kB76Sgdx3I= 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=/093o1NxENUaTouo0Mdw75upRRId/THkS7GyiJgLLTE=; b=KFdeCQGHcx9+AW3PH8r72Dgp46PtZw8SSO1k9hZW0mP9DDPBv7hTs/KECUIdC7o98V sebfv97K/rZTRPHMUlhZ1TyIH9nleMBkmpn60poR76mooDuh6hwhrm7aigHGNoFNM8cy eQvWRgVgtJRQbV8KjZK3h+QrpKT45qBQKmJ57+5NoE8AmO2SrRewk13CwFSeP92G7aAH gZlTSpKa1iTyJ6LyxnvQSoObRlD12RvOkMnX5HjGdF8HAzYQKJkXGq64STVW4tY+vMcS 93yC3X/7hEZTRHKtatFl5fmI+BlWV27UUVgzsEJZ/pLI5vDhUQ9d4pmQMLShtN2OND0c Y+zA== X-Gm-Message-State: ACrzQf2+PjEbJz9HXh9lvY3BZjc7lAoKjHSnGmye41DAMrfdLwzsPJky yTJHDB+DmS9Z8fIk5SlPcN2ehw== X-Google-Smtp-Source: AMsMyM7VVlNQFM2jb19B9vU1xma0PWwNFZ9Hwj6vv6nqxc1WcJIo9JThqwHvdsmROp7UflCFr+TP6w== X-Received: by 2002:a05:620a:4809:b0:6ce:496c:7e78 with SMTP id eb9-20020a05620a480900b006ce496c7e78mr18631613qkb.470.1663741848731; Tue, 20 Sep 2022 23:30:48 -0700 (PDT) Received: from localhost.localdomain ([164.92.70.235]) by smtp.gmail.com with ESMTPSA id m10-20020ac807ca000000b00342f05defd1sm1060855qth.66.2022.09.20.23.30.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 23:30:48 -0700 (PDT) From: Matt Ranostay To: gupt21@gmail.com, jic23@kernel.org Cc: linux-i2c@vger.kernel.org, linux-iio@vger.kernel.org, linux-input@vger.kernel.org, Matt Ranostay Subject: [PATCH v4 1/5] i2c: muxes: ltc4306: fix future recursive dependencies Date: Tue, 20 Sep 2022 23:30:22 -0700 Message-Id: <20220921063026.89619-2-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220921063026.89619-1-matt.ranostay@konsulko.com> References: <20220921063026.89619-1-matt.ranostay@konsulko.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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 ea838dbae32e..7b6a68df4a39 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 Wed Sep 21 06:30:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 608475 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 E07BEC6FA95 for ; Wed, 21 Sep 2022 06:31:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229791AbiIUGbE (ORCPT ); Wed, 21 Sep 2022 02:31:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229831AbiIUGaw (ORCPT ); Wed, 21 Sep 2022 02:30:52 -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 87E4032D8D for ; Tue, 20 Sep 2022 23:30:51 -0700 (PDT) Received: by mail-qv1-xf2a.google.com with SMTP id m9so3769049qvv.7 for ; Tue, 20 Sep 2022 23:30:51 -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=EEEIkVBJ75c1He7ol3L/GMy6O2j7bpfcaiLKZ3AKsE0=; b=ZJDah8N78ksArxAT6Gozi9vW0xRjIitzUcmHaXdaTbK3H/Wx4Aesa5+XuZ+rkXBofR I1VJveiMvxCLoCLCCHKrHF4U3TBbStkfwx127M/5S5vPrYdkSCMnpwHTxWYufGDhoUz1 +HOYLpeGcNuRmzR0wS9wLvdxwtSjqq9/GgShU= 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=EEEIkVBJ75c1He7ol3L/GMy6O2j7bpfcaiLKZ3AKsE0=; b=XaAKsy/XCGLbbACLcq5j9m2X8Tlvr7pzKAXIcsi7mjL3uU9aAbpqKpvuCoQIm5/Dsa eS3/32bt4AZdxPhmAws/T3dFrbtBPLwyvYU13hHJioHZO3uLmDUrEEE6yy9F1QTqP0N+ UYuZqO8EoD3gkJhJlxbbmES751/V16ParTCwaSpQUXhM37dgntV9LeqFeqfsHEUxeIfO +LSQDWMXHVaNOoI+dpw5Uu6gRsazageHAA+pO837MxRpxJ6YNy6IPYYrjrUuMUnC48tB zPtMNmpQPWGftaS/CM1NbPO8tWohVmCycI8+Yry4IJFsbKDu9gfSO2bFoOqGNrgLTL23 X9CQ== X-Gm-Message-State: ACrzQf2J++CO3qOODJsbHW0ILQBh7Ik+5bOk+k1wD9oakGiyXyATjDJu HUzWQGUFqJVv9orEjwA1oC2hNA== X-Google-Smtp-Source: AMsMyM7+rfhHP0WFlK4pb4y4HRfC9wcWDXLEEq2JWTqgV/VHCrznChHrIGbQHc54zQmtykzCJZDJKA== X-Received: by 2002:a05:6214:2468:b0:4ac:8786:f20e with SMTP id im8-20020a056214246800b004ac8786f20emr21853047qvb.50.1663741850700; Tue, 20 Sep 2022 23:30:50 -0700 (PDT) Received: from localhost.localdomain ([164.92.70.235]) by smtp.gmail.com with ESMTPSA id m10-20020ac807ca000000b00342f05defd1sm1060855qth.66.2022.09.20.23.30.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 23:30:50 -0700 (PDT) From: Matt Ranostay To: gupt21@gmail.com, jic23@kernel.org Cc: linux-i2c@vger.kernel.org, linux-iio@vger.kernel.org, linux-input@vger.kernel.org, Matt Ranostay Subject: [PATCH v4 2/5] iio: addac: stx104: fix future recursive dependencies Date: Tue, 20 Sep 2022 23:30:23 -0700 Message-Id: <20220921063026.89619-3-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220921063026.89619-1-matt.ranostay@konsulko.com> References: <20220921063026.89619-1-matt.ranostay@konsulko.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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/addac/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 Acked-by: Jonathan Cameron --- drivers/iio/addac/Kconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iio/addac/Kconfig b/drivers/iio/addac/Kconfig index fcf6d2269bfc..494790816ac7 100644 --- a/drivers/iio/addac/Kconfig +++ b/drivers/iio/addac/Kconfig @@ -19,9 +19,8 @@ config AD74413R 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 Wed Sep 21 06:30:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 608064 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 9A73EC32771 for ; Wed, 21 Sep 2022 06:31:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229519AbiIUGbF (ORCPT ); Wed, 21 Sep 2022 02:31:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229818AbiIUGaz (ORCPT ); Wed, 21 Sep 2022 02:30:55 -0400 Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 935735281B for ; Tue, 20 Sep 2022 23:30:53 -0700 (PDT) Received: by mail-qv1-xf31.google.com with SMTP id ml1so3784440qvb.1 for ; Tue, 20 Sep 2022 23:30:53 -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=guDbos8H+2MulL5VMihZeNnAKhgf5f7tTlWaiadNPoot+VqaoIjDN+78BC+UdAl3nt YFVMuCtgffobaeY3UYySVas8gJlgyOl7w37Kjj9hMHvJnsoTmHazpfiRPc+rp+Ev0RYH FOKrLxndUHSLj6N41V4mNFZp2HzCBgz7vH3M4= 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=cD8STB3D1DZKY7uUCH8dkbPwf0nDP1wKU7JdHdbhaCKcO/hcrUSzeERYDNcl4/augC afHEHBugwlSQBLeVN6vETLVH2upSK58CEZMn+IetSby1N4QZNZutfTS7RM1jQC1dP1EU tbq/UrTZaP+E96+D3ofkoIJaGeg6JbJ6u1wPutBQ91/2OhmvbMmdcNLHn6DAfZjDfEEp 2w6oLxwTmllioRHB81RSy1bWDJM73e6w82BWSryktkcw5PruxzDztne/DYqs6R9Gw5ti l8VX0pdc8Je56nvfAyZbpJDwpj9Tb0zOXdPNk9vZS47Z8sFxpr3Oi/nsXyUNcavQUS5U 8hkQ== X-Gm-Message-State: ACrzQf3di19pffA+9o7ViTxJ9hgV884AU+Iq09GXpc9hfXY74finWtb0 mZ11fNOc0+eYk3L/4qqJc17SXg== X-Google-Smtp-Source: AMsMyM7zFvK7QiqfmPImkZGwRtcWCoH4lq1sjNgZgk8F/zIlG7fpfDbQC9BVrs9Do3P7lyUFBIXuuA== X-Received: by 2002:a05:6214:2588:b0:49e:5dea:8e66 with SMTP id fq8-20020a056214258800b0049e5dea8e66mr22486940qvb.21.1663741852744; Tue, 20 Sep 2022 23:30:52 -0700 (PDT) Received: from localhost.localdomain ([164.92.70.235]) by smtp.gmail.com with ESMTPSA id m10-20020ac807ca000000b00342f05defd1sm1060855qth.66.2022.09.20.23.30.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 23:30:52 -0700 (PDT) From: Matt Ranostay To: gupt21@gmail.com, jic23@kernel.org Cc: linux-i2c@vger.kernel.org, linux-iio@vger.kernel.org, linux-input@vger.kernel.org, Matt Ranostay Subject: [PATCH v4 3/5] iio: dac: fix future recursive dependencies Date: Tue, 20 Sep 2022 23:30:24 -0700 Message-Id: <20220921063026.89619-4-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220921063026.89619-1-matt.ranostay@konsulko.com> References: <20220921063026.89619-1-matt.ranostay@konsulko.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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 Acked-by: Jonathan Cameron --- 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 Wed Sep 21 06:30:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 608474 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 9A168C6FA98 for ; Wed, 21 Sep 2022 06:31:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229771AbiIUGbG (ORCPT ); Wed, 21 Sep 2022 02:31:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229895AbiIUGa5 (ORCPT ); Wed, 21 Sep 2022 02:30:57 -0400 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01E0E792FA for ; Tue, 20 Sep 2022 23:30:55 -0700 (PDT) Received: by mail-qt1-x82d.google.com with SMTP id g12so3456795qts.1 for ; Tue, 20 Sep 2022 23:30:55 -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=mlVGPwO+07kuJrM0Nnjb7s2sOnMb8GPVRLx94R4E7gs=; b=fss57bJBh8c6SOblTfdjH+G8dANT8AsNUqFiBVhincgz2iiJ7tJd4WjjAJEEb196yr mdwywb8Ht7PGWW7WKcyQUWLtjUKd6mFidItRpE//Pk5M97b90IKaFivGAFXfNwg3gVLs tN/S49ou0vNvS1iuF3N/+dOSTFTjnNUVeFc4M= 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=mlVGPwO+07kuJrM0Nnjb7s2sOnMb8GPVRLx94R4E7gs=; b=aU+jUluw26uZaX184yye2cwBSIA8hKgBomJjGoDPjgV7IlnNAu8GVJf+YK7Um823B7 QfXdNvA1HyH9oY4xzHlJUvOUSvtL+cyNGVY9CMPhnAmXyNkVPoUc2wDDe1OmNlcqhcBF b/0yQ31qbbV18j9Oh3uJXSqvVW+EeZNDOk6sX4e/JcQjv01GVrORSEw5Vn7okNtfBA8f S4wEaeR2WHH7ZBPo4c0v5n33eAdHe56dTs4ycUztEPV2tnseei3CNToW4NTfQRhW2w2K rBqxXUJVIH+GAb/OerXB44MDyffWGhiNOzxGidIPxq4NJ/PP57ePa/kCXJVxBWYGU0dg l6Xg== X-Gm-Message-State: ACrzQf1R/pxS3FoMsQFQ7hFCWeJBJ7sk8OdWxhRXuzQBitC/aPAq0MG2 ZEMiyku5EoI65bX7yE6CjHXpzA== X-Google-Smtp-Source: AMsMyM7lbGdMehRb5bQh41Qks9Goqd8Dg/VM4CIatKvSGNd+3cB3ygfNk9A9OokMRtpnYYjDz8f4SA== X-Received: by 2002:a05:622a:44b:b0:35c:e129:a1b with SMTP id o11-20020a05622a044b00b0035ce1290a1bmr15021109qtx.78.1663741854798; Tue, 20 Sep 2022 23:30:54 -0700 (PDT) Received: from localhost.localdomain ([164.92.70.235]) by smtp.gmail.com with ESMTPSA id m10-20020ac807ca000000b00342f05defd1sm1060855qth.66.2022.09.20.23.30.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 23:30:54 -0700 (PDT) From: Matt Ranostay To: gupt21@gmail.com, jic23@kernel.org Cc: linux-i2c@vger.kernel.org, linux-iio@vger.kernel.org, linux-input@vger.kernel.org, Matt Ranostay Subject: [PATCH v4 4/5] HID: mcp2221: switch i2c registration to devm functions Date: Tue, 20 Sep 2022 23:30:25 -0700 Message-Id: <20220921063026.89619-5-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220921063026.89619-1-matt.ranostay@konsulko.com> References: <20220921063026.89619-1-matt.ranostay@konsulko.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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 | 45 +++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c index de52e9f7bb8c..7ba63bcd66de 100644 --- a/drivers/hid/hid-mcp2221.c +++ b/drivers/hid/hid-mcp2221.c @@ -824,6 +824,14 @@ static int mcp2221_raw_event(struct hid_device *hdev, return 1; } +static void mcp2221_hid_remove(void *ptr) +{ + struct hid_device *hdev = ptr; + + hid_hw_close(hdev); + hid_hw_stop(hdev); +} + static int mcp2221_probe(struct hid_device *hdev, const struct hid_device_id *id) { @@ -849,7 +857,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 +866,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_remove, hdev); + if (ret) + return ret; + /* Set I2C bus clock diviser */ if (i2c_clk_freq > 400) i2c_clk_freq = 400; @@ -873,19 +886,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 +911,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[] = { @@ -932,7 +926,6 @@ static struct hid_driver mcp2221_driver = { .name = "mcp2221", .id_table = mcp2221_devices, .probe = mcp2221_probe, - .remove = mcp2221_remove, .raw_event = mcp2221_raw_event, }; From patchwork Wed Sep 21 06:30:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 608063 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 ACE7FC6FA8B for ; Wed, 21 Sep 2022 06:31:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229761AbiIUGbH (ORCPT ); Wed, 21 Sep 2022 02:31:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229924AbiIUGa6 (ORCPT ); Wed, 21 Sep 2022 02:30:58 -0400 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 275AB5F994 for ; Tue, 20 Sep 2022 23:30:57 -0700 (PDT) Received: by mail-qk1-x730.google.com with SMTP id q11so3316823qkc.12 for ; Tue, 20 Sep 2022 23:30:57 -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=3lMJVYbJjtccXXKyB50PZyz4j5r0AXrFSb7LRKIXcd4=; b=ZXG2EEUn5A7NUCw8LRo8FsVKaXEbApHNC2xugE1aC4s+nOz5OovpsMiRgObN5GSeYA oPBRk6WUnVjdwbczi1AuYx8eUk+fLdnXPNATi6zEH4ooyu8csq0x+K3Y0koGWrJ7MA0m 4s/ZXj3Ycn6tgFUgdZ+oBzz73brkKXhbdG69k= 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=3lMJVYbJjtccXXKyB50PZyz4j5r0AXrFSb7LRKIXcd4=; b=5c0YCC7Z+lmVieSgadBFvd1N1gMOQ+6hsa7EPP46+3CNuPCxb2Nc/zIFNDHWYXmEz5 SlDZdKE5wLdhCPoi/lR9MxluBRPCpxcAGndBNyNVV/O2IOTzRmNz+8Ebf8vXum1Zihpw 81yvBtq5n1smstDknSlhfT1BVibO9TwTDgsF1edconEYsWqjY1qqwtL9aVqdmNba0XWe cwqZq79NmiIhH3B0bRr45Y0hjWgbrmJD1ksOMXJFBqnBfByTSQpvuk6RGv7hmhJJKghq zoGJzzYbVEuIAc89JcyCz0biNbwZ5JHRnEwlE6AL6wO152GmixZOrjNw7cmEjXjidQAF I/kg== X-Gm-Message-State: ACrzQf295B0jqy0Lcvh+hVTuphcjEnpXpnS6BzKDCVRZ0E/j9U+72yXq 0JukJ1Pk0GcqP/FK704Q3at5jg== X-Google-Smtp-Source: AMsMyM4/Bb0F4bHJumuP4EeZPmiKRLS35o0M8xDeVN+PFeIxc5RUuJhK2yyIVBUsFMiUfW7ykmE4Cg== X-Received: by 2002:a05:620a:1432:b0:6cd:4de8:4033 with SMTP id k18-20020a05620a143200b006cd4de84033mr18909659qkj.6.1663741856756; Tue, 20 Sep 2022 23:30:56 -0700 (PDT) Received: from localhost.localdomain ([164.92.70.235]) by smtp.gmail.com with ESMTPSA id m10-20020ac807ca000000b00342f05defd1sm1060855qth.66.2022.09.20.23.30.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 23:30:56 -0700 (PDT) From: Matt Ranostay To: gupt21@gmail.com, jic23@kernel.org Cc: linux-i2c@vger.kernel.org, linux-iio@vger.kernel.org, linux-input@vger.kernel.org, Matt Ranostay Subject: [PATCH v4 5/5] HID: mcp2221: add ADC/DAC support via iio subsystem Date: Tue, 20 Sep 2022 23:30:26 -0700 Message-Id: <20220921063026.89619-6-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220921063026.89619-1-matt.ranostay@konsulko.com> References: <20220921063026.89619-1-matt.ranostay@konsulko.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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 | 252 +++++++++++++++++++++++++++++++++++++- 2 files changed, 252 insertions(+), 1 deletion(-) diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 863d1f96ea57..cdae312f4795 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -1228,6 +1228,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 7ba63bcd66de..2a7783b607af 100644 --- a/drivers/hid/hid-mcp2221.c +++ b/drivers/hid/hid-mcp2221.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "hid-ids.h" /* Commands codes in a raw output report */ @@ -30,6 +31,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 +93,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 +102,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 +730,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 +762,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 +836,64 @@ 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; + } + + /* DAC scale value */ + tmp = (data[6] >> 6) & 0x3; + if ((data[6] & BIT(5)) && tmp) + mcp->dac_scale = tmp + 4; + else + mcp->dac_scale = 5; + + /* ADC scale value */ + tmp = (data[7] >> 3) & 0x3; + if ((data[7] & BIT(2)) && tmp) + mcp->adc_scale = tmp - 1; + else + mcp->adc_scale = 0; + + break; + default: + mcp->status = -EAGAIN; + } + complete(&mcp->wait_in_report); + break; + default: mcp->status = -EIO; complete(&mcp->wait_in_report); @@ -832,6 +910,173 @@ static void mcp2221_hid_remove(void *ptr) hid_hw_stop(hdev); } +#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; + 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); + + /* 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) { @@ -913,6 +1158,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; }