From patchwork Mon Sep 12 17:31:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 12973844 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 77E13C6FA90 for ; Mon, 12 Sep 2022 17:32:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229762AbiILRcY (ORCPT ); Mon, 12 Sep 2022 13:32:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229861AbiILRcW (ORCPT ); Mon, 12 Sep 2022 13:32:22 -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 31C0824F3F for ; Mon, 12 Sep 2022 10:32:21 -0700 (PDT) Received: by mail-qt1-x834.google.com with SMTP id h21so6762719qta.3 for ; Mon, 12 Sep 2022 10:32:21 -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=RvNoI+RXBUolsFk9NDjJyaJaLEEqnkmDehbv2qaSWEKZjSasX7ODEEHGu2eu8uprJj NfHE+A9P80Mivo8zajIXc43GejzE+Jc+B27gvA0/J3Z4akyaEoVovaZINquyL9jp7gr0 gabhCt6cDtkddjdWp23ca1ZHRXQqwqC8ybsto= 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=3wZm6N2JdVHfYf8hdbKiGjFnFNXLC8z+5b1KX4ILphWPzpw48EIK9I23WJ1hXX9Cyw QPAZmXVW2FmSymoTn/rj/O8aBANkOOn7a2BjCV/V58GE0zXFBqKcQQP7id7AnOEVJGku 4GuRJWugAJicG+b8H4YomMv9O1V8LuXK94jIsG0fMBILbmljRnNgIdwSGdEkx8GcFo9u hCmG/VYb5u9REcqr/4Ych1QUf98GZGu3k25nw5CHKu7bxr8B5MKqGSQ6uYG1YV3G/QQL dpHU53gSAQxsebkeOAEHb+4Bcz0WqTqV35PmMN27W/1mCytjDbk+bsBZfIC7FJGecfau QzoQ== X-Gm-Message-State: ACgBeo2C+4TlenPlmBRg/CbtO/7KnHhcLBUec5mF0E5sNZAkyWn3eYrL r0OZl7hUsUPZdySuBaPSIw9JOA== X-Google-Smtp-Source: AA6agR55qCs0zERnpRPB5l4Br0DRhsycobSsxD/32DEs/WDcB9gwWY3p+3Nc+dzJz7Qxe922lzACYA== X-Received: by 2002:a05:622a:199c:b0:344:7645:9ba1 with SMTP id u28-20020a05622a199c00b0034476459ba1mr24647270qtc.629.1663003940345; Mon, 12 Sep 2022 10:32:20 -0700 (PDT) Received: from localhost.localdomain ([159.65.38.31]) by smtp.gmail.com with ESMTPSA id h63-20020a376c42000000b006b8d1914504sm8289394qkc.22.2022.09.12.10.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 10:32:20 -0700 (PDT) From: Matt Ranostay To: gupt21@gmail.com, jic23@kernel.org Cc: linux-iio@vger.kernel.org, linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, Matt Ranostay Subject: [PATCH v3 1/5] i2c: muxes: ltc4306: fix future recursive dependencies Date: Mon, 12 Sep 2022 10:31:58 -0700 Message-Id: <20220912173202.16723-2-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220912173202.16723-1-matt.ranostay@konsulko.com> References: <20220912173202.16723-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 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 Mon Sep 12 17:31:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 12973845 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 5C5E4C6FA82 for ; Mon, 12 Sep 2022 17:32:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230120AbiILRcZ (ORCPT ); Mon, 12 Sep 2022 13:32:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230206AbiILRcY (ORCPT ); Mon, 12 Sep 2022 13:32:24 -0400 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3C4C22298 for ; Mon, 12 Sep 2022 10:32:22 -0700 (PDT) Received: by mail-qk1-x72d.google.com with SMTP id i3so1860649qkl.3 for ; Mon, 12 Sep 2022 10:32:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=YEluTMkVQhnCulwc8lwLW2vyLgQvDTIQ3djmLSBHRwA=; b=lgj5k5WWPKvkPTZvPgBnH+Z8PQ6d5iVrT9qtPK+SlRvbwMQXm1tA3KijkKbk40pMlI OHCZMdByFkaF1NEMGuU8Q61QxXYlsiTyAEEwMeJIqQKCJt+DVbpfsA83VeaGuRlvDHmU 9WVHsoDbMHkldAVlaRs+NUmj5z0VMKbvw5/YM= 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=UeABt2uYjxOLNKn6DmCZKZZGw3+XmEaHXjffwKAgXK5V5oFwNFiuH8bWGMPafzdLTf VG4ivYvzibJp3GTiXCOgXXdw6kL+q/PpgxeTr1TkBw2/xRCyeCwqF68fGYKHyYUoLvT1 /viK4UXMkijXBSXJABmIey4C9aMfAPULim7VYtTLDKZ9ObPg+iHFeNEDkVOcAXKt/9AN nH9EUNflOcEk2W5qiL1vm4A4cKCvEq6BoDJIxdeaN5NYlisKaRq6ou3PtSBwJcexSQWS mOW2CXkXxMfc3vrWPXwt19EEsHx5+TIlVFIBrO7Naa2h0rARAuM2sdb8Q/8UP+aj0aab lNlA== X-Gm-Message-State: ACgBeo0sp8VW3OXhCpXjXpEilOWnA1tDQ72i4n3C90TtsSvBx4U/XFN0 gB32ZlaODfK7Hlvyh8celTabJA== X-Google-Smtp-Source: AA6agR7jD/N/A5Mqe4C+ePHGGjcU6jhoG9397WhahTmz6Tha0Hs+fNrk1RG7+KT1oxUX/n4jaa4tEw== X-Received: by 2002:a05:620a:4155:b0:6ce:3e4f:9b1c with SMTP id k21-20020a05620a415500b006ce3e4f9b1cmr3563613qko.744.1663003942012; Mon, 12 Sep 2022 10:32:22 -0700 (PDT) Received: from localhost.localdomain ([159.65.38.31]) by smtp.gmail.com with ESMTPSA id h63-20020a376c42000000b006b8d1914504sm8289394qkc.22.2022.09.12.10.32.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 10:32:21 -0700 (PDT) From: Matt Ranostay To: gupt21@gmail.com, jic23@kernel.org Cc: linux-iio@vger.kernel.org, linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, Matt Ranostay Subject: [PATCH v3 2/5] iio: addac: stx104: fix future recursive dependencies Date: Mon, 12 Sep 2022 10:31:59 -0700 Message-Id: <20220912173202.16723-3-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220912173202.16723-1-matt.ranostay@konsulko.com> References: <20220912173202.16723-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 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 Mon Sep 12 17:32:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 12973846 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 7EE8DC6FA92 for ; Mon, 12 Sep 2022 17:32:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230199AbiILRc1 (ORCPT ); Mon, 12 Sep 2022 13:32:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229783AbiILRcZ (ORCPT ); Mon, 12 Sep 2022 13:32:25 -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 7203C23BD2 for ; Mon, 12 Sep 2022 10:32:24 -0700 (PDT) Received: by mail-qk1-x72e.google.com with SMTP id g2so3723585qkk.1 for ; Mon, 12 Sep 2022 10:32:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=wUfUODMZKfU/KRMGIPcJ/EprHfUIajE7CfzqJDq54Sc=; b=Jygg5xjgKZ4satdBYz9QswEVF4wOOXfrBrmX9tITPCD68+PNZqohDyy0n7TrNSD+xE iDoEObH5ijvyFZxt/7e3RDoYbZmCTzAVXJJxAo3GL3PK311zUMbFSpQGkO7Pi3WnnhVz 0lar0zUEUaIKC5PXPBavY39f0QmO3TwthhVX0= 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=1rSXhvkZLmoO0crnyuI6Ct531MT6DGK9kQ5bmycFUpCjtgl2DIOgAC+DLM8zUK0nX/ DG8YaVStpD1lvMDA/s5m5UusKFQ9GlFEtSXG+MG+BIyAYwKSsxCQ6KqDiNmQwXHChEmj u+H74XVerU61at8/j8YdkeoyrxpsTBP9hr/cJY9mDHUbjHeIr9SpGmiFN5Grihah4KCp KoYo9190EArIn9pKstcMlBORzEn7OdXWkp695C8ZD6+AYV14TZQrfz3ML8echZCkWWxV wcl1oM8gQiE4/RhQTOzhbVnQhpMa07hAgkV4wdo0Y2wqFhh8x1FDtJtz1Ze9PEJ1JLVu 37HA== X-Gm-Message-State: ACgBeo1SD4/z4gxatuD6GWciP4K51Q3URqXydFLatM9LuEOSWRixlhCK TKWomEhnYvjgYV021ABRK5gi8w== X-Google-Smtp-Source: AA6agR514xTiZj839LW7iE31Mh7Sy1LuhS2wosEcaZ59xb4Smzbd8lfGrBN+/yE/C8CfV2FBUh2thQ== X-Received: by 2002:a05:620a:2456:b0:6ce:3cfe:dd62 with SMTP id h22-20020a05620a245600b006ce3cfedd62mr3864659qkn.380.1663003943583; Mon, 12 Sep 2022 10:32:23 -0700 (PDT) Received: from localhost.localdomain ([159.65.38.31]) by smtp.gmail.com with ESMTPSA id h63-20020a376c42000000b006b8d1914504sm8289394qkc.22.2022.09.12.10.32.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 10:32:23 -0700 (PDT) From: Matt Ranostay To: gupt21@gmail.com, jic23@kernel.org Cc: linux-iio@vger.kernel.org, linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, Matt Ranostay Subject: [PATCH v3 3/5] iio: dac: fix future recursive dependencies Date: Mon, 12 Sep 2022 10:32:00 -0700 Message-Id: <20220912173202.16723-4-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220912173202.16723-1-matt.ranostay@konsulko.com> References: <20220912173202.16723-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 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 Mon Sep 12 17:32:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 12973847 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 D8BACC6FA93 for ; Mon, 12 Sep 2022 17:32:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229783AbiILRc2 (ORCPT ); Mon, 12 Sep 2022 13:32:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229737AbiILRc0 (ORCPT ); Mon, 12 Sep 2022 13:32:26 -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 ECC1F26551 for ; Mon, 12 Sep 2022 10:32:25 -0700 (PDT) Received: by mail-qv1-xf30.google.com with SMTP id i15so7269621qvp.5 for ; Mon, 12 Sep 2022 10:32:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=oqYENd/2txABU+QCOqmWhZqh5LDN7sKRoTIhe4ZzfVA=; b=VbNGOBtc3nRLLsXMZwXV9fuEjFd1jHi8WmEQq6yUJbvN2q8TaPcNVvqRpqKGZGDwT9 WroiIBVfUpitWRDxVmVH0lBeuthEZeOkfwLwzly3JC80ij/6PrLpoc6THnxAzjoX8PCa fd20FfDpPl4LlHpchwwYBj1uF1mnmwdDiwQJA= 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=6GaofEbGxHRwAIb46o57vqHc/5oKFDmcwI2DTHfZMFhCK4L/vZuPOR4iJ9knMUmOSB suMUVvYY8eBr49gI6sokEphFaejc1zyZFikHfal3wTga+OGwbTI2iHxRd64UOgAPs+jW 5sxfP2YkiuTKT2EvQ+mcLhMzaaKUjPlNeL9lsFh4AvAojBaBK2pUcdKeUufZ5fS4XFTx PgdKwdJU+l2IJXl7ut8bz34qPBCfm0pyPDzWcBhVzS0I0xQUzRCqC4zg8MK8W48qIIK0 sQxUqrcRYcDb2pTJEVcp9YI0WpG3aHDVfatefRM7SnvOBHvcooT+p9qSg1QTbHO3f4ZP V9xA== X-Gm-Message-State: ACgBeo1il4he52NjJ3DgMTDXhqKLrvHJeOYn/wSVffUNlyQNHH0MdVi7 iIATYf6PzWClL2v4tjSVyb8eug== X-Google-Smtp-Source: AA6agR62JUhrOm1QBbF6atLS+PeF0vej4pYkLNmE3F03qk0GwIEtxJGXHFnnF0Tx1+5oPNGLzJyLkw== X-Received: by 2002:a05:6214:c8b:b0:4ac:c1f7:660f with SMTP id r11-20020a0562140c8b00b004acc1f7660fmr1748255qvr.52.1663003945044; Mon, 12 Sep 2022 10:32:25 -0700 (PDT) Received: from localhost.localdomain ([159.65.38.31]) by smtp.gmail.com with ESMTPSA id h63-20020a376c42000000b006b8d1914504sm8289394qkc.22.2022.09.12.10.32.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 10:32:24 -0700 (PDT) From: Matt Ranostay To: gupt21@gmail.com, jic23@kernel.org Cc: linux-iio@vger.kernel.org, linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, Matt Ranostay Subject: [PATCH v3 4/5] HID: mcp2221: switch i2c registration to devm functions Date: Mon, 12 Sep 2022 10:32:01 -0700 Message-Id: <20220912173202.16723-5-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220912173202.16723-1-matt.ranostay@konsulko.com> References: <20220912173202.16723-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 | 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 Mon Sep 12 17:32:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 12973848 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 29F52C6FA82 for ; Mon, 12 Sep 2022 17:32:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229698AbiILRcc (ORCPT ); Mon, 12 Sep 2022 13:32:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230206AbiILRca (ORCPT ); Mon, 12 Sep 2022 13:32:30 -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 CBAA028E09 for ; Mon, 12 Sep 2022 10:32:27 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id g23so2208806qtu.2 for ; Mon, 12 Sep 2022 10:32:27 -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=pU+uazCGd57RG/H8bU5+CIs55xRlWBja4huUwXKNCCRXf252l9m6pn1Hz9oI0I6VKX r7LRPOwKhpg4MshZVRA0aZnaBskbVYbO5tfZEre1KlVby4ozgUUU1x3/wuc9MDi/NFcT h8xoTiZXFCz+sp0SNk9k862bYwZpN2N18OLEs= 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=YXCSreOSuWl5OHpeMRxzd9j5z3eLBTFYoJjymEWMRQ0R7J1khCkmqLyoh9Ul5ppIUi /iMeyRvtN9Q7vYFzXL22ReZRQkAAlQ6EVf082q0F0DNJtQNa0snXnOL7HYtnS1aH/u1W e5Xz+2+NMm+yafVmGs3Ljl9RSrPSfm9LLlzHRpvhWjWFrvgDqu+8n53cS7TUsuUXvY48 gGsNwIbf6wqUbLnCSjBH2kB8Nyr/6XgQm/A6HByqh+gqnruwjaz3rj3WDs0uZxYCZpgI bHVFPoQ7WQLxKXfuZ23HbobnvT5Q9FokZV5KPSOYAAP2J8ogHA9laLeIIf0E9/mwCTPi GZlg== X-Gm-Message-State: ACgBeo2lcO2Rp7XaY/i/qscfwqC+Wlyal1trg75qfG07V9Uk5qDh25c/ Plyh16htOOmmICobQZt4toIjsQ== X-Google-Smtp-Source: AA6agR5nz30Bsl+4gu+YGS5kfsccHrvtsrwePGKlqUYERkUio8mi1WhI1VFvkLiFB1JV4mN4dGWoXA== X-Received: by 2002:ac8:5a8c:0:b0:35b:b2f7:7e96 with SMTP id c12-20020ac85a8c000000b0035bb2f77e96mr5802110qtc.659.1663003946691; Mon, 12 Sep 2022 10:32:26 -0700 (PDT) Received: from localhost.localdomain ([159.65.38.31]) by smtp.gmail.com with ESMTPSA id h63-20020a376c42000000b006b8d1914504sm8289394qkc.22.2022.09.12.10.32.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 10:32:26 -0700 (PDT) From: Matt Ranostay To: gupt21@gmail.com, jic23@kernel.org Cc: linux-iio@vger.kernel.org, linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, Matt Ranostay Subject: [PATCH v3 5/5] HID: mcp2221: add ADC/DAC support via iio subsystem Date: Mon, 12 Sep 2022 10:32:02 -0700 Message-Id: <20220912173202.16723-6-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220912173202.16723-1-matt.ranostay@konsulko.com> References: <20220912173202.16723-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 | 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: