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: 12983245 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 BBE15C6FA82 for ; Wed, 21 Sep 2022 06:31:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229901AbiIUGbB (ORCPT ); Wed, 21 Sep 2022 02:31:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229703AbiIUGav (ORCPT ); Wed, 21 Sep 2022 02:30:51 -0400 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B8512A439 for ; Tue, 20 Sep 2022 23:30:49 -0700 (PDT) Received: by mail-qk1-x731.google.com with SMTP id q11so3316699qkc.12 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=tgKmBW44Xo+7d6pKXwF/Qv4bzyHpo7RHKube4bhrrlo3Jq+NeOLrCUMI7wDUnGW9KV FUR/lBLwlyf528OdIWSrWJeP1zYrqGoDVmpe69TSx/qGS2Gcvseql4wTWiVIzit/0+cp U6yBuNFE9rIqFGFlzSWEoqzut2y5N1qPwGXC3m+oto5UA+4bfD1KcwwDro6FF6wGQQDq xRQ0AXDIgezgLYo+TLJaPPm7JtZbzXP3lJAEQUZ+Iv8Ny+nfRNukWvztnfwq1h36ewqx LgUlGVX+XX3ozjehv5FfyQC7HtvFi24uLcOlpR2SCEelqJZOFICbcjSesONXWoDNiDmJ 0A6g== X-Gm-Message-State: ACrzQf1k9znyYG/0MV6ygilIoyokuGTe8C3QMVeIJ0+ZTBZ3ehe5mYjA 3oEkaeJrlYjUfdDq8lV7OVQrpg== 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-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 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: 12983248 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 87EA6C6FA96 for ; Wed, 21 Sep 2022 06:31:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229525AbiIUGbF (ORCPT ); Wed, 21 Sep 2022 02:31:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229657AbiIUGaw (ORCPT ); Wed, 21 Sep 2022 02:30:52 -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 8B8903ECFD for ; Tue, 20 Sep 2022 23:30:51 -0700 (PDT) Received: by mail-qv1-xf36.google.com with SMTP id z9so3755837qvn.9 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=LQcNvJMBA0zROZ5nxfC0mOleNr1Z4QYBwLYebw/p1HqupRzql3x7wzkBFdAGo9H+UJ YFAvH1NItgcPpa4j6RMnoP3+Jw9dUsp+Y7BgakgHd4mZTo5WE/UNxFpgHnCzoVQHzGek nBd5xNXao8DcBkmjpgK8JCMMz7BfOnE5mkrQUAC+Ut8JPQmfK/rkiFzSkc/g8AzSaOhb D6pyGrhrwPN2IiESWBlzWyUhyTnOLYr/cemW6XbFQ/a2KUrbJvGccTlen3gabPiO91+M MZ5Q2qTufJAoQrD5CoKqTCBlCA2JaSWDo2E8AxmRNhRwcak0dfUYzixFqCgUJotfvqb5 zZjw== X-Gm-Message-State: ACrzQf2vEcLV0bDCIM1OgMFWjCnxKYXMKgkfqOND7a5ZihFsL6C23nHK GFIeEPZdtlD69eU2bNZj5YfypmbxR+3EqHFuGlQ= 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-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/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: 12983247 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 A4582C6FA94 for ; Wed, 21 Sep 2022 06:31:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229673AbiIUGbE (ORCPT ); Wed, 21 Sep 2022 02:31:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229496AbiIUGaz (ORCPT ); Wed, 21 Sep 2022 02:30:55 -0400 Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A9C252E4B for ; Tue, 20 Sep 2022 23:30:53 -0700 (PDT) Received: by mail-qv1-xf2f.google.com with SMTP id l14so3761759qvq.8 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=cbGIDpSv2UT53XqBL+OTnEIqcWOMKCBwyuKse13px8sp6sgKX36MhaOvE6tDATS9sY qgkQpUDvU+FcUqhwJDtYg/haoQlMf4huwPGPPR0KZ2pRG8TJWaOoc308sFzRiPCMiIvd biMgqsvIZDQdtl73+YK+Vi5SxvoQT/iMsNW4AL+Sbh4XPbif/c48EXDakpOk8VY46AXP hWhJ1JjzQy3nxFEmYH9BUeWoNbVLtF2LuHBdoCihtl+WbbduIEZxnN+qR+iuZOsfI/P2 NkEhYUTVQNSzGkQjBbXP3cpG9mxpVAYPVKMx3bsNS2aFacczBIyk6DUOuHTmGg1qdFYo 0XNw== X-Gm-Message-State: ACrzQf3Bg/65lXm/k3oGPT9RLjdQw4d/saP69fPcPEI4MRrI6kMv+l7H B8Cc5qfxoh1ZzJWEeok0uggJk9kzX5Ej0SuauqU= 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-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 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: 12983249 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 26513C6FA99 for ; Wed, 21 Sep 2022 06:31:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229776AbiIUGbG (ORCPT ); Wed, 21 Sep 2022 02:31:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229903AbiIUGa5 (ORCPT ); Wed, 21 Sep 2022 02:30:57 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02D097B1FE for ; Tue, 20 Sep 2022 23:30:56 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id h21so3443458qta.3 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=P9rRdkzu5466wcfS59u+uIHLs27CHHhy7kOCvfWm/eAghpaDMOlsZ7R7D8bFmjlCqi O/ZvemRc/5LpZsANx1qW9oa1b+rzbrU4Kui+pncQVeX8XLbTPvIFjk32jNT8t9SYJ3tz Ndk2hcSMTjj9k4HF8T21e8c+kzo9E63AORJO44Od3p8Mj7tZragn8sU1rHAxc4z6S6nt TcfKbV8du1t23SPo+5+NFlLzq0O7tXjJYwSjMOc29+3OIaIvrIvElbCZ2Mz1fo3wq9XY aw/Q9jHq637IoWMPDmqLBlbZRB/gAFmLdvKw3QLLSXJO607kugqBZJTLTxQrISNq3frn ogbg== X-Gm-Message-State: ACrzQf3XfBKo9VHcjn15yy67Sq1tN0oWA0awgr29B5wGtQfiFXsvKAzb iaxR3cVoCQrsZ3abQo55vlDVo2eGZCv/aCuyAmg= 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-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 | 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: 12983250 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 72E08C6FA91 for ; Wed, 21 Sep 2022 06:31:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229785AbiIUGbH (ORCPT ); Wed, 21 Sep 2022 02:31:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229912AbiIUGa6 (ORCPT ); Wed, 21 Sep 2022 02:30:58 -0400 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26D9E2F65A for ; Tue, 20 Sep 2022 23:30:57 -0700 (PDT) Received: by mail-qk1-x733.google.com with SMTP id d17so3308198qko.13 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=vf1f1psqLiQjFawFacrB1srXekIbN1ztWdylU/L0uVzczWdV+7xPlELuUSnxOP5d5r i+tnx5cmS5l5WHUhQ6AfS71tAqfI8lM1k+LERtAGKpUmAEOyQCxixl9eEEmsXCbW1twM eMscztco3/v/x+ynOB9KecVrLnmr46OnIKWPqzK5vnGwLcf1MStaQ/Qg2NP1y7Yc5gK/ +3ru5xRQ8exBw3QIo6sDEZROhfZ6fhdKPV0kMt1TwBYsuZMvhdtiGNsYvlmyy20TvJUQ Hwe+c2ScptwBaqKvvwzJOWTVG99D5SHd/1yegS/wQ6wxAOHr/+7c9g/OGh1Hdfj4sIoz 7zKw== X-Gm-Message-State: ACrzQf2JSC+o3EAJtGmbkUyi8quthUPz/pt9SjUMbthxrqvnNKSHjdIY k2iCqHfEF6qWVQmSX8OLDqH1/Q== 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-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 | 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; }