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: 608498 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 080F5C6FA90 for ; Wed, 21 Sep 2022 06:31:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229554AbiIUGbD (ORCPT ); Wed, 21 Sep 2022 02:31:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229791AbiIUGav (ORCPT ); Wed, 21 Sep 2022 02:30:51 -0400 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ADC629CB5 for ; Tue, 20 Sep 2022 23:30:49 -0700 (PDT) Received: by mail-qk1-x72e.google.com with SMTP id u28so3348918qku.2 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=JLEYZX+WbHdoA1QDB0iAPc27somu+/HSnx9bUYjNVT/cGPinOa4j07cUgiwtOXmybY 4iuSWet4QWYMrUJDCQEwLmqe2WKocCq+RraXl6HmjWT2Cbd3jc9Tr5vBXpFxPbgMtLma XCUFsclgloiCvNUYmmiC6GNMQVnibWPCcsj8Xe2N24HJFPd7kd6ghLskQT7PSYTK7l/4 1GIsv3CiV0q6zf/lBXnt5jT+ognaTzx5m9H19af2mNMYJx4HWA2BWM6z+KcHoo9q9iAJ lHVKsuNET9A5yL5pTqFYhaSeJsF8XRlOZlowC2dX+lZbcKMFdkrqjQLUa5aTiClHDo8e o+7w== X-Gm-Message-State: ACrzQf1ebf7V+6KnIfihe8PFY0YGfQ8EdbG8XVsNuPOl9O4b0sXXny9w TfERNhEOhCbEZf2YRDlkeiJrxCU11G819eK4D+c= 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-input@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: 608074 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 CED6FC6FA93 for ; Wed, 21 Sep 2022 06:31:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229819AbiIUGbE (ORCPT ); Wed, 21 Sep 2022 02:31:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229776AbiIUGaw (ORCPT ); Wed, 21 Sep 2022 02:30:52 -0400 Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CD3F45044 for ; Tue, 20 Sep 2022 23:30:51 -0700 (PDT) Received: by mail-qv1-xf30.google.com with SMTP id s13so3759023qvq.10 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=CLCttDFF4M/XXymvVFlgdYWkt+OukIaqFvvBKsYTpr8Ka4Nbcp8W9kK2DSX03YJ2yH AHBNp3HJzd+75UY2zQOzvcbGvSnKjypPJYfvxYTxJfomGXO+iD1c4/K+4wwSOjC2+tEQ TkrQrVKE27/Ywb3qyDKMPaHIDoKmJEJ0UMt8en3K+On869E8ou+R9lRPhJlkXE3i94fe xdGrRnx2yNNZWidB/XqAZvpk+oMFykWYlwfL87JsI/5JsjGBCir6y1DE9DjyCLph6kIp SKnv21anSAK57dtjbkrscNYXyXc6XHy1j2jD3ztNxXmx0Fco//z+nKEBJkZBQ+pUAPkm OjxQ== X-Gm-Message-State: ACrzQf2n4IpYXSFrqe+qjZ6a2Fja8FtMLJ2wMdSEWCndaQn0O29rOTos PsBWX9q2o4OyS4IDg5jALzFuLQ== 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-input@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: 608497 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 68312C6FA82 for ; Wed, 21 Sep 2022 06:31:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229496AbiIUGbF (ORCPT ); Wed, 21 Sep 2022 02:31:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229807AbiIUGay (ORCPT ); Wed, 21 Sep 2022 02:30:54 -0400 Received: from mail-qv1-xf36.google.com (mail-qv1-xf36.google.com [IPv6:2607:f8b0:4864:20::f36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92AEC4F196 for ; Tue, 20 Sep 2022 23:30:53 -0700 (PDT) Received: by mail-qv1-xf36.google.com with SMTP id d1so3822304qvs.0 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=2sxn+JIvmBYMEB+KTyPT3/HeCnismA7Zw+jmWKyHCfafcSAhm0Q3pF/G2D9t1GdI7E FG7C7coGWW8i8pbOb63yalXDjiEwSOa1LnbAtASxtsiPQTFdIFcAExiJFr9x4/c0yHf3 je2BwO3V9E9kNrtbJ2TQqe2T3y4F8x0e2EVFIxWeA2ii5dZrD6CYEUi/BiKHrGfjqSxT 08n56Uewkin5hYcN9gQjmpa27iR5ic+ZNsMUzwtH71xWPOfr1Yi84CRE1SoAFsMCtdg1 NfrNO5uQMNpNjw0jgSwbWoJndqrfsyaZQ/GbrqzrfxsRDLGmtEFGq7Mkfi5k0VM31vZ2 KzoA== X-Gm-Message-State: ACrzQf1udIVKk8xYoqxFVnZxLPo+TrcZJU/RzCfnJEXQX26GXWTY/bOH 9jGucoKAvT8IbwChl3u4PFlIRQ== 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-input@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: 608073 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 14C7CC6FA97 for ; Wed, 21 Sep 2022 06:31:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229691AbiIUGbG (ORCPT ); Wed, 21 Sep 2022 02:31:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229898AbiIUGa5 (ORCPT ); Wed, 21 Sep 2022 02:30:57 -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 01E527B1DC for ; Tue, 20 Sep 2022 23:30:55 -0700 (PDT) Received: by mail-qt1-x834.google.com with SMTP id b23so3407156qtr.13 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=hLY0jX/yRBQTVUitqSgfeRmzaPf6PVkhQUni4hraXadBK/HUGIw1/mn7dMaIWqPvZF KKLWbh/IzVYZ9GYGzsYFErHmTwP8yGf7SZfJz102B/fVTrDIiz979WesD+qKmXzELN5o h9w5Z7RFoOVJXpDc3T0ciLd9PdFOyKvC1OzVNzc6RXpEFu9xwDN03nCrbjA3lvpRPe8w pQnT9PT7bIvu34CgZUNebBn9TwFqKSvCr97xobaAFGUsoODMfQUMo036tm3MaKTlEgwA yaGbi4HuMe8UlUqeX0dMDffxQbmKXRnHvW97QA6uE8lqw3AEXPkkwieIM1Xwr77A7Aoh A38w== X-Gm-Message-State: ACrzQf0mOI3jU5OjB9HK4Xa7kSUJ8CZx9hK4Z3woq11/tmp4ulWPFVwW 4F9sa+aOi8alHL2+s3PMOMVO6Q== 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-input@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: 608496 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 91DEBC6FA94 for ; Wed, 21 Sep 2022 06:31:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229807AbiIUGbH (ORCPT ); Wed, 21 Sep 2022 02:31:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229926AbiIUGa6 (ORCPT ); Wed, 21 Sep 2022 02:30:58 -0400 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6C68F6D for ; Tue, 20 Sep 2022 23:30:57 -0700 (PDT) Received: by mail-qk1-x72c.google.com with SMTP id d15so3322918qka.9 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=6uJirT0d6uDZoaEEA+e9Okou6iG1tM9EuQsU/dqofMs6piOHk5LA4FCv8wamfvQuI2 ZAzy3tTXrHdH2exLr8cGN7NvGw9vNdScQ/JDLFt+XClw1sbpkITuL4j+NzXCwhk0uSke J2Hnp09w1jSSE5Yo6vfevcMQ03yaaQlcIPkKVdKOh8foQjw1UCRsSzDn/Ufjikk/pawG 2CHIbMc8Fu1g3fXzGOpSw0xy5tZafojxVMIbR6nYWSYIPGKvOO/ZD/lE8oaJygYWlLz3 /tp5pkVlAiAbyyB5kf5noNYVE+KsgBObhL1BSCUv7mzkqqfCFZaywzHkvQk2WBTKRZac 2/dA== X-Gm-Message-State: ACrzQf1Lvj6S3ucrABIwbFQMCky2Tr4e07CDLmUnV4SDKymyCerDpNsO lt0OpFoMMm7HsjuV83nE8c1XHA== 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-input@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; }