From patchwork Sun Sep 11 01:40:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 605184 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 5F59DC6FA8A for ; Sun, 11 Sep 2022 01:41:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229609AbiIKBlM (ORCPT ); Sat, 10 Sep 2022 21:41:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229629AbiIKBlJ (ORCPT ); Sat, 10 Sep 2022 21:41:09 -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 CDEFB32DAB for ; Sat, 10 Sep 2022 18:41:07 -0700 (PDT) Received: by mail-qv1-xf2f.google.com with SMTP id s13so4233111qvq.10 for ; Sat, 10 Sep 2022 18:41:07 -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=TVCgLHI6doxJO+C8xmrBxNy2DyFsnEYY2dswoZKE5JM=; b=oeoaIkxV0Fuf+OqJSjW+T81ab/aP9Fg5NTRvgrXw7z46AbDt4qN44e050xDr2FKgIZ FwYJjVPvdalFc2rVV/OPkhuxaVm9CFHHwL0BsHGR4/9APHGFMZMSimDl6GyIqKPTgEMQ +k33C3tcZ9S8IlnS0Kl11cWBGccWB7LtOfayE= 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=TVCgLHI6doxJO+C8xmrBxNy2DyFsnEYY2dswoZKE5JM=; b=Z2uTOS9vQmmWeY156s6dNw6qlp3l8FKvJ9hXj24hPA3zQ3PKjDlu71aUkr9aREHY8O vif/TJTiOGTjNQU8IuCMiQNXiliSENRb2L2eRHmT4KP5hRbsTur6D55ZM9Ddop0ZR9DY PYdkiu0gbduSa6hvDm1secpt7JKpiPt0u+9m4D9PjxK1mlUDXQ37F9utUd/7tpt1kO3r 0XmvYMliwnGnxPd1QwtfECdN32zgHotmnzJsbRSQ+s6eWoSTqxPD0K0TqF46CXJJxzXx AHnZtDX4Pnzl9SxQ8Ov7giAlqG6pRNCKORBDW8BVqiXe8ZbXvkn5a/DyJmP1WuzhHN1T Xr3g== X-Gm-Message-State: ACgBeo0CU06ZicvlvFNVcIJQrtQj/eOwlL9YiDDzDnbN20SPlE/WnGcJ W4sXofWw8VsidyNKqlITxkG2dw== X-Google-Smtp-Source: AA6agR6dbbSLsAlHCay/8aZh/7yY8ZouRstyZCThCYHwwTqxn4RetkzUX74LqLnee1WzVt6w3HVDsg== X-Received: by 2002:a05:6214:2a81:b0:473:af82:9a95 with SMTP id jr1-20020a0562142a8100b00473af829a95mr17908794qvb.44.1662860467002; Sat, 10 Sep 2022 18:41:07 -0700 (PDT) Received: from localhost.localdomain ([159.65.38.31]) by smtp.gmail.com with ESMTPSA id q26-20020ac8451a000000b003438a8e842fsm3542973qtn.44.2022.09.10.18.41.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Sep 2022 18:41:06 -0700 (PDT) From: Matt Ranostay To: jic23@kernel.org, gupt21@gmail.com Cc: linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, Matt Ranostay Subject: [PATCH v2 1/5] i2c: muxes: ltc4306: fix future recursive dependencies Date: Sat, 10 Sep 2022 18:40:44 -0700 Message-Id: <20220911014048.64235-2-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220911014048.64235-1-matt.ranostay@konsulko.com> References: <20220911014048.64235-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 detected happens 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 Sun Sep 11 01:40:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 605183 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 4A290C6FA82 for ; Sun, 11 Sep 2022 01:41:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229589AbiIKBlM (ORCPT ); Sat, 10 Sep 2022 21:41:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229718AbiIKBlK (ORCPT ); Sat, 10 Sep 2022 21:41:10 -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 5847E33368 for ; Sat, 10 Sep 2022 18:41:09 -0700 (PDT) Received: by mail-qv1-xf31.google.com with SMTP id s13so4233136qvq.10 for ; Sat, 10 Sep 2022 18:41:09 -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=YEluTMkVQhnCulwc8lwLW2vyLgQvDTIQ3djmLSBHRwA=; b=PGqMJMAvDWyttgnWm0pTyDnKcUYAigL+jt5p10BN4nhxbUYKdD0mM5Sx9Rb9coaNMp GKCLFsWg9iZYxt9eHTvm4Y2SLxZH+N1+wqPM103T6qU3fZ9nBxLqeUYBfT3iOV2exiTm Y2O2bNywBgw1+A6PD5S/PmdQEw8xmt+iLK36Q= 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=YEluTMkVQhnCulwc8lwLW2vyLgQvDTIQ3djmLSBHRwA=; b=cKw7RfE1FmcyDqU/o1UZl9TyYrpN09UTQc/wRxiJ45VKGYX2gO3FuTw8USnzkG2Nw4 MfSml1LmNyYHLZsr3SCoVR5owDkSOK3/88DITq9RVUV/OoOLfOfmXjOJgCe1LA/2olL3 tcowIj9XX7DihY2+Npu8jspe+1YHWY5p1K4DSzeTOVGqO4RJKZiQlhMSWnVVmXNaqlnf JWjCTU5d27SH+At+ALNkRNGTpaOBG7dnZh3/YN6DBbOJhXjC8Snws7baPOjkqNcVOEjV QeqTmlRU0gg6J0KCGiGe2Ki0NqoYAGOxq2oRQ9a2Pc1DstgIFAHBp4J1U8F7lM9LiYNA yiwA== X-Gm-Message-State: ACgBeo1TnTYnRIBrKXJAmtom2+kWWpLFaZpWRoM+QNriYxLcmK050RoC 0z4pNWba6Ixqbg2YIEyxrRF2xw== X-Google-Smtp-Source: AA6agR49EZ9pGn5pO7p824CWVfWBv3bH2r7zOT5v+m9hhUjZTTPRCXQBLcb0Ut+1YsJi8/fnL/E4fA== X-Received: by 2002:a05:6214:2588:b0:49e:5dea:8e66 with SMTP id fq8-20020a056214258800b0049e5dea8e66mr17942488qvb.21.1662860468523; Sat, 10 Sep 2022 18:41:08 -0700 (PDT) Received: from localhost.localdomain ([159.65.38.31]) by smtp.gmail.com with ESMTPSA id q26-20020ac8451a000000b003438a8e842fsm3542973qtn.44.2022.09.10.18.41.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Sep 2022 18:41:08 -0700 (PDT) From: Matt Ranostay To: jic23@kernel.org, gupt21@gmail.com Cc: linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, Matt Ranostay Subject: [PATCH v2 2/5] iio: addac: stx104: fix future recursive dependencies Date: Sat, 10 Sep 2022 18:40:45 -0700 Message-Id: <20220911014048.64235-3-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220911014048.64235-1-matt.ranostay@konsulko.com> References: <20220911014048.64235-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 detected happens 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 --- 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 Sun Sep 11 01:40:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 604883 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 32DF2C6FA8D for ; Sun, 11 Sep 2022 01:41:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229718AbiIKBlN (ORCPT ); Sat, 10 Sep 2022 21:41:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229862AbiIKBlL (ORCPT ); Sat, 10 Sep 2022 21:41:11 -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 C609B31341 for ; Sat, 10 Sep 2022 18:41:10 -0700 (PDT) Received: by mail-qk1-x72c.google.com with SMTP id u28so927572qku.2 for ; Sat, 10 Sep 2022 18:41:10 -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=wUfUODMZKfU/KRMGIPcJ/EprHfUIajE7CfzqJDq54Sc=; b=X/wGV2VLKPM41GBNPVmj/Ik9dl6bKc59iC9TiPfHcpc9QgI8SbLKntgeQCqoA7MqgV g1zOHz7umwNdtI6zKQiKh8JOftpweA418DhQmaGp5+OPfME2mCYYl7B9fwE2iNnud3vl XYdECviAx0Nci2jpYOOCS8wnuD4vYFRXSz3ZA= 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=wUfUODMZKfU/KRMGIPcJ/EprHfUIajE7CfzqJDq54Sc=; b=EW0JlH/Ec88zDomPDKPTR+mASRFC3Hx+yDMiU8KdPJIz5Z7gvKYg7kWJIhXkLprAa2 zLICjAG++iLf6cRosFM/s0KT9Bknw0pf8uD9fpTjbNLahu8WT1nw31clFYGHuWw/HRVa 93Xhx2ERp9Y4gBvRVGICQZE6Gzfy+yiOUBw6SsENA7jtMRKl3iRNMOKOHQnq/p4fKTlo t5osR+eWdBcEutY287//wfdzek5eMeQ/pp7BvcF+7nOPmEujCgRes79i6loCCeJJIlIa 3xEnOPiuFzpnxbaZatBv23KyfcqOVUa0DPNB7CzTmCGBMrByqvrZAcdZMUsEJzqA12G2 212Q== X-Gm-Message-State: ACgBeo0Qui38sAK/mTlAbITHziUWrY96rS4RqpwW/NtS1BQxkVoaqNXc qt97IZdR2BZunR4kM+O5qkKl0KQmbxF4STx0Cjg= X-Google-Smtp-Source: AA6agR7gtrVhQaNCx+8D8JtPVoCa7mQHb9j8E6uOWozp39f7/GAVTA8jFLa/bqQYpCgkpB1zm3OQWw== X-Received: by 2002:a37:68c6:0:b0:6cd:e798:f07c with SMTP id d189-20020a3768c6000000b006cde798f07cmr5503925qkc.596.1662860469940; Sat, 10 Sep 2022 18:41:09 -0700 (PDT) Received: from localhost.localdomain ([159.65.38.31]) by smtp.gmail.com with ESMTPSA id q26-20020ac8451a000000b003438a8e842fsm3542973qtn.44.2022.09.10.18.41.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Sep 2022 18:41:09 -0700 (PDT) From: Matt Ranostay To: jic23@kernel.org, gupt21@gmail.com Cc: linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, Matt Ranostay Subject: [PATCH v2 3/5] iio: dac: fix future recursive dependencies Date: Sat, 10 Sep 2022 18:40:46 -0700 Message-Id: <20220911014048.64235-4-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220911014048.64235-1-matt.ranostay@konsulko.com> References: <20220911014048.64235-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 detected happens for AD5592R and AD5593R. Switch from 'select GPIOLIB' to 'depends on GPIOLIB' to avoid this per recommendation in kconfig-language.rst drivers/gpio/Kconfig:14:error: recursive dependency detected! drivers/gpio/Kconfig:14: symbol GPIOLIB is selected by AD5592R drivers/iio/dac/Kconfig:93: symbol AD5592R depends on IIO drivers/iio/Kconfig:6: symbol IIO is implied by HID_MCP2221 drivers/hid/Kconfig:1227: symbol HID_MCP2221 depends on GPIOLIB Signed-off-by: Matt Ranostay --- drivers/iio/dac/Kconfig | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig index 80521bd28d0f..b93003e80b70 100644 --- a/drivers/iio/dac/Kconfig +++ b/drivers/iio/dac/Kconfig @@ -92,8 +92,7 @@ config AD5592R_BASE config AD5592R tristate "Analog Devices AD5592R ADC/DAC driver" - depends on SPI_MASTER - select GPIOLIB + depends on SPI_MASTER && GPIOLIB select AD5592R_BASE help Say yes here to build support for Analog Devices AD5592R @@ -104,8 +103,7 @@ config AD5592R config AD5593R tristate "Analog Devices AD5593R ADC/DAC driver" - depends on I2C - select GPIOLIB + depends on I2C && GPIOLIB select AD5592R_BASE help Say yes here to build support for Analog Devices AD5593R From patchwork Sun Sep 11 01:40:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 604882 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 602CCECAAD5 for ; Sun, 11 Sep 2022 01:41:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229629AbiIKBlO (ORCPT ); Sat, 10 Sep 2022 21:41:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbiIKBlN (ORCPT ); Sat, 10 Sep 2022 21:41:13 -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 5163732DA4 for ; Sat, 10 Sep 2022 18:41:12 -0700 (PDT) Received: by mail-qk1-x72b.google.com with SMTP id q11so820123qkc.12 for ; Sat, 10 Sep 2022 18:41:12 -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=oqYENd/2txABU+QCOqmWhZqh5LDN7sKRoTIhe4ZzfVA=; b=DZCYgj2stF5GjFI8rseFm8XHv9/HzWyX8k93XPPfIEZZOEHbLkliP4KHvxCd4vlTIG 213J16NhmLJ7Hd/SNgy09ixa0tJbH5wBcsn5hhaGrhzTiswBHBGXQl/8FulErsjD2Vwc xB3i79WfVqR4yZa1gVKBkx0CL5hBc8uCyT4QM= 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=oqYENd/2txABU+QCOqmWhZqh5LDN7sKRoTIhe4ZzfVA=; b=V1o6tSpO6oROk8CwyITcnmAZCIuB6FRQxlRaJgaLJWqR88R2EEsRc5p7SAZAHQ/mxJ ZRlRIVnTeuDKcjsG1n+ZPIK4cHDXp5s5li2suqptLDib6xekxoLLG9JweitYevBE9c/M bIBTdBFx+v6S9KTfG75GN9HrRYsYJfIdDvtXgYnRki3BWFlXxm9BybNQRYFZhktakB9y AjPB/sRP72DKdt8Lhc7iUznl+RTgoIytu9AKUCNVQuBZRs/whhPmBIzwmAD/qUr1lheD 5Hun5PcyLAlfae07HgOMcaHVo/FCpJGs58mBHY8oTZDJbcVV075TicV8cEH20N3+XfYz /s2A== X-Gm-Message-State: ACgBeo0M0PVn/ceaoNkTkIM0IEchDTgfRkTXG3Yvh7cNz4cDix+Hy5Go hAwrNYfSZTlKphWYKA2wsP8VkQ== X-Google-Smtp-Source: AA6agR6ywEfecacYTGqZQjCYhDu06PIROl6pvp5Fhx4NxaV5HOMVhE9MSPdDttwtZYdJy+3slTZkIQ== X-Received: by 2002:a05:620a:458a:b0:6bb:c0f:c0ff with SMTP id bp10-20020a05620a458a00b006bb0c0fc0ffmr15455535qkb.78.1662860471535; Sat, 10 Sep 2022 18:41:11 -0700 (PDT) Received: from localhost.localdomain ([159.65.38.31]) by smtp.gmail.com with ESMTPSA id q26-20020ac8451a000000b003438a8e842fsm3542973qtn.44.2022.09.10.18.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Sep 2022 18:41:11 -0700 (PDT) From: Matt Ranostay To: jic23@kernel.org, gupt21@gmail.com Cc: linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, Matt Ranostay Subject: [PATCH v2 4/5] HID: mcp2221: switch i2c registration to devm functions Date: Sat, 10 Sep 2022 18:40:47 -0700 Message-Id: <20220911014048.64235-5-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220911014048.64235-1-matt.ranostay@konsulko.com> References: <20220911014048.64235-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 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c index de52e9f7bb8c..29e69576c3d4 100644 --- a/drivers/hid/hid-mcp2221.c +++ b/drivers/hid/hid-mcp2221.c @@ -873,7 +873,7 @@ 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; @@ -884,7 +884,7 @@ static int mcp2221_probe(struct hid_device *hdev, mcp->gc = devm_kzalloc(&hdev->dev, sizeof(*mcp->gc), GFP_KERNEL); if (!mcp->gc) { ret = -ENOMEM; - goto err_gc; + goto err_i2c; } mcp->gc->label = "mcp2221_gpio"; @@ -900,12 +900,10 @@ static int mcp2221_probe(struct hid_device *hdev, ret = devm_gpiochip_add_data(&hdev->dev, mcp->gc, mcp); if (ret) - goto err_gc; + goto err_i2c; return 0; -err_gc: - i2c_del_adapter(&mcp->adapter); err_i2c: hid_hw_close(mcp->hdev); err_hstop: @@ -917,7 +915,6 @@ 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); } From patchwork Sun Sep 11 01:40:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 605182 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 727C8C6FA8A for ; Sun, 11 Sep 2022 01:41:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229897AbiIKBlQ (ORCPT ); Sat, 10 Sep 2022 21:41:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229872AbiIKBlP (ORCPT ); Sat, 10 Sep 2022 21:41:15 -0400 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F316732DAB for ; Sat, 10 Sep 2022 18:41:13 -0700 (PDT) Received: by mail-qt1-x836.google.com with SMTP id a20so1320407qtw.10 for ; Sat, 10 Sep 2022 18:41:13 -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=MGwVR7KMW7JJIFZssHswgB9KTK6/O+Daft2L6+TvsYk=; b=d3ohxfJQAr1tfy845NI3BHY8FLz05JxvjbpC3ohzGzwkuYHNdEHGI0YQNlg34r1QY2 ylHp0bR7qXr0AN7YxUES7sAgzCPv3cLbMwi9h0r0wOipb9pRG8uFsEQ0fki1F9zWv6ZG c6/YF4GKupfNTrqIIm5TGkPtW9++cahl32Dm4= 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=MGwVR7KMW7JJIFZssHswgB9KTK6/O+Daft2L6+TvsYk=; b=T/vpCAvhjOc++Fr7fJvjpe1WBiwaTNvIrhImva3KDpRb+5O25zh0JZzRdCSKKFSfe5 8/v7B+L8+kjYSeiKcS+eT9/P+VmErqqWziinbK5DciVm6yWXmICCbq3kplj280AMURgP 9m5co96VYCe2yGFk0TgBrUIiDN+NRec0BFYFhRe67iCxeZuxzKb7NW4XDFPOaZp/Netr EMCzeAhSVoksY523AwNxKmHagZWn9c4O8RQIYlAYPqfIMMp2OguFJBdpMVW2gCG6h0fm naaq4XxU8GJNlhwcND4+K6fNLzEE9pECH33UEeuR5iT8laOK9SFOw/Ba9aIuAsIpTUTd fiRQ== X-Gm-Message-State: ACgBeo16TaDOpT9EwGfwVFvsc06x82aeAU/6J73Gef0ndVOegM3+Fei6 yDIEbNwai4FqguSAU6/BfPXz2A== X-Google-Smtp-Source: AA6agR783G+KnEwWosiImBznkx+mgxw99W0bEjHSjU9PJJVgBYUrgD5j3Ge8whEas0DmXM+6EYYcWw== X-Received: by 2002:ac8:58c4:0:b0:343:731e:7e81 with SMTP id u4-20020ac858c4000000b00343731e7e81mr18140205qta.367.1662860472950; Sat, 10 Sep 2022 18:41:12 -0700 (PDT) Received: from localhost.localdomain ([159.65.38.31]) by smtp.gmail.com with ESMTPSA id q26-20020ac8451a000000b003438a8e842fsm3542973qtn.44.2022.09.10.18.41.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Sep 2022 18:41:12 -0700 (PDT) From: Matt Ranostay To: jic23@kernel.org, gupt21@gmail.com Cc: linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, Matt Ranostay Subject: [PATCH v2 5/5] HID: mcp2221: add ADC/DAC support via iio subsystem Date: Sat, 10 Sep 2022 18:40:48 -0700 Message-Id: <20220911014048.64235-6-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220911014048.64235-1-matt.ranostay@konsulko.com> References: <20220911014048.64235-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 | 187 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 188 insertions(+) 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 29e69576c3d4..923b41eb76b3 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,8 @@ enum { MCP2221_I2C_CANCEL = 0x10, MCP2221_GPIO_SET = 0x50, MCP2221_GPIO_GET = 0x51, + MCP2221_SET_SRAM_SETTINGS = 0x60, + MCP2221_GET_SRAM_SETTINGS = 0x61, }; /* Response codes in a raw input report */ @@ -89,6 +92,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 +101,16 @@ 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 dac_value; +#endif +}; + +struct mcp2221_iio { + struct mcp2221 *mcp; }; /* @@ -745,6 +759,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 +833,32 @@ 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; + default: mcp->status = -EIO; complete(&mcp->wait_in_report); @@ -824,6 +867,145 @@ static int mcp2221_raw_event(struct hid_device *hdev, return 1; } +#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; + + 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->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); + mutex_unlock(&mcp->lock); + hid_hw_power(mcp->hdev, PM_HINT_NORMAL); + + if (ret) + return; + + num_channels = mcp_iio_channels(mcp); + if (!num_channels) + return; + + indio_dev = devm_iio_device_alloc(&mcp->hdev->dev, sizeof(*data)); + if (!indio_dev) + return; + + 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); +} +#endif + static int mcp2221_probe(struct hid_device *hdev, const struct hid_device_id *id) { @@ -902,6 +1084,11 @@ static int mcp2221_probe(struct hid_device *hdev, if (ret) goto err_i2c; +#if IS_REACHABLE(CONFIG_IIO) + INIT_DELAYED_WORK(&mcp->init_work, mcp_init_work); + schedule_delayed_work(&mcp->init_work, msecs_to_jiffies(500)); +#endif + return 0; err_i2c: