From patchwork Wed Nov 29 13:51:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 748845 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="oSVidB/y" Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8F4DDD for ; Wed, 29 Nov 2023 05:51:48 -0800 (PST) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-50bc9931c82so15293e87.3 for ; Wed, 29 Nov 2023 05:51:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701265906; x=1701870706; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=IJVDxJRhkC1R0NB1OybcfNwTfEmKrwSlSr9/Hamx9NY=; b=oSVidB/yApS3ENl61PqtUewxp5QIx7oVzU5HNK2Smd9caAOOFnNOoYJDfAK4qZf69I Kx1bQIHM8BtA0wUH0/EOpLFdgmZdGtNqtWKgxWFH24rBfxQXeNee/41yYlg7uylAY4j8 z0fdnkbtX1Lr8sdpaSBlXqT2hdF+WPCvmAgUafTxGiEAwQBwBXURzvLjmwlO2ZvhHyaS odn42+iU57aOlRMn4uRsocZEeH5w9iQN/NIPX9U6/TKZBlHJA3vv/9apqo3G+3rpqMm+ YiHg69BL7ZxyCNoqFxl0uS9Qjd2+KM4/QvVzLsTg1Gexvw+ZEY1vOK205FMFBAoP6LB8 zUwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701265906; x=1701870706; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IJVDxJRhkC1R0NB1OybcfNwTfEmKrwSlSr9/Hamx9NY=; b=IpbLps0udfewcw2LJ8XWBiuyTb17HZcatrpROTqpM3kW5v6YBLBQvgp9W0AW6+6HOI 1BSlomeCnD/g1XTvXzwDMxy/Rcmw8D2hm0b3atdJgWvJGwA54RCrgBvOBrNGuD8IZA3Q uGDSVNwUYtuNoyWX5HVW+4NzZZHyUmaVWCxMt+RmRNOpMPH78x7xPddEv/6b0oTa4WQR vSkOouG2ysV/R0yEHyPXyRCv8dIAvDhK8hiXhXFk72FaW93YGazjtmLrWzilG8tiaOuR 5VkYlysUlsmf6mb33SsNSqw7vnnfvSf8GVgoTKdphTsn/rmLrympQfX6mmZsVGAWju84 Ylrw== X-Gm-Message-State: AOJu0YxvE8rNdOXKZ+JjwDVKr+d2p8DxOKx9PggODdz03ZgI1B72OBWK vjyj3BPPptHU6w8444zsYYQUZ/UaK5HFt6HyhsE= X-Google-Smtp-Source: AGHT+IHprW1qmodT+TbJta5oVD18X/Vp5LiOuWOUJ+39saDp9YaTJu2M14OtyTRYBLNr9DelpSKpNw== X-Received: by 2002:a05:6512:e81:b0:50b:c8a0:5657 with SMTP id bi1-20020a0565120e8100b0050bc8a05657mr531485lfb.17.1701265906583; Wed, 29 Nov 2023 05:51:46 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a28-20020ac2521c000000b0050ab88758b8sm2164280lfl.84.2023.11.29.05.51.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 05:51:46 -0800 (PST) From: Linus Walleij Date: Wed, 29 Nov 2023 14:51:45 +0100 Subject: [PATCH 1/4] Input: navpoint - Convert to use GPIO descriptor Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231129-descriptors-input-v1-1-9433162914a3@linaro.org> References: <20231129-descriptors-input-v1-0-9433162914a3@linaro.org> In-Reply-To: <20231129-descriptors-input-v1-0-9433162914a3@linaro.org> To: Dmitry Torokhov , Tony Lindgren Cc: linux-input@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 The Navpoint driver uses a GPIO line, convert this to use a GPIO descriptor. There are no in-kernel users but outoftree users can easily be added or converted using a GPIO descriptor table as with numerous other drivers. Signed-off-by: Linus Walleij --- drivers/input/mouse/navpoint.c | 41 +++++++++++++++-------------------------- include/linux/input/navpoint.h | 1 - 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/drivers/input/mouse/navpoint.c b/drivers/input/mouse/navpoint.c index c00dc1275da2..ba757783c258 100644 --- a/drivers/input/mouse/navpoint.c +++ b/drivers/input/mouse/navpoint.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -32,7 +32,7 @@ struct navpoint { struct ssp_device *ssp; struct input_dev *input; struct device *dev; - int gpio; + struct gpio_desc *gpiod; int index; u8 data[1 + HEADER_LENGTH(0xff)]; }; @@ -170,16 +170,14 @@ static void navpoint_up(struct navpoint *navpoint) dev_err(navpoint->dev, "timeout waiting for SSSR[CSS] to clear\n"); - if (gpio_is_valid(navpoint->gpio)) - gpio_set_value(navpoint->gpio, 1); + gpiod_set_value(navpoint->gpiod, 1); } static void navpoint_down(struct navpoint *navpoint) { struct ssp_device *ssp = navpoint->ssp; - if (gpio_is_valid(navpoint->gpio)) - gpio_set_value(navpoint->gpio, 0); + gpiod_set_value(navpoint->gpiod, 0); pxa_ssp_write_reg(ssp, SSCR0, 0); @@ -216,18 +214,9 @@ static int navpoint_probe(struct platform_device *pdev) return -EINVAL; } - if (gpio_is_valid(pdata->gpio)) { - error = gpio_request_one(pdata->gpio, GPIOF_OUT_INIT_LOW, - "SYNAPTICS_ON"); - if (error) - return error; - } - ssp = pxa_ssp_request(pdata->port, pdev->name); - if (!ssp) { - error = -ENODEV; - goto err_free_gpio; - } + if (!ssp) + return -ENODEV; /* HaRET does not disable devices before jumping into Linux */ if (pxa_ssp_read_reg(ssp, SSCR0) & SSCR0_SSE) { @@ -242,10 +231,18 @@ static int navpoint_probe(struct platform_device *pdev) goto err_free_mem; } + navpoint->gpiod = gpiod_get_optional(&pdev->dev, + NULL, GPIOD_OUT_LOW); + if (IS_ERR(navpoint->gpiod)) { + error = PTR_ERR(navpoint->gpiod); + dev_err(&pdev->dev, "error getting GPIO\n"); + goto err_free_mem; + } + gpiod_set_consumer_name(navpoint->gpiod, "SYNAPTICS_ON"); + navpoint->ssp = ssp; navpoint->input = input; navpoint->dev = &pdev->dev; - navpoint->gpio = pdata->gpio; input->name = pdev->name; input->dev.parent = &pdev->dev; @@ -288,17 +285,12 @@ static int navpoint_probe(struct platform_device *pdev) input_free_device(input); kfree(navpoint); pxa_ssp_free(ssp); -err_free_gpio: - if (gpio_is_valid(pdata->gpio)) - gpio_free(pdata->gpio); return error; } static void navpoint_remove(struct platform_device *pdev) { - const struct navpoint_platform_data *pdata = - dev_get_platdata(&pdev->dev); struct navpoint *navpoint = platform_get_drvdata(pdev); struct ssp_device *ssp = navpoint->ssp; @@ -308,9 +300,6 @@ static void navpoint_remove(struct platform_device *pdev) kfree(navpoint); pxa_ssp_free(ssp); - - if (gpio_is_valid(pdata->gpio)) - gpio_free(pdata->gpio); } static int navpoint_suspend(struct device *dev) diff --git a/include/linux/input/navpoint.h b/include/linux/input/navpoint.h index d464ffb4db52..5192ae3f5ec1 100644 --- a/include/linux/input/navpoint.h +++ b/include/linux/input/navpoint.h @@ -5,5 +5,4 @@ struct navpoint_platform_data { int port; /* PXA SSP port for pxa_ssp_request() */ - int gpio; /* GPIO for power on/off */ }; From patchwork Wed Nov 29 13:51:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 748354 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vXEFJcAs" Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07E17DE for ; Wed, 29 Nov 2023 05:51:50 -0800 (PST) Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-50bba815f30so2585669e87.2 for ; Wed, 29 Nov 2023 05:51:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701265908; x=1701870708; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=/rhQHcx3LLcsvi8JsQdTsfI9bgCOlf/fMigiqEoXsPs=; b=vXEFJcAstXiaAnzdX1XtoXw9BOH2o+1qXPpY0bnLEgjJLOPUCR+F3eccv1cv9H8oUx t2TPgQfjaketUo0tMhl7y4g5V9Zba1Khla+fFWZ8T5sCZtMIBX2ViAmWFii64Ts5NoNp umT9Ev8KqDti3scLkOMMK6qkrqO/29yq5j6WrspkBo8zscw7VCGJtZbl6h8Mxi4F74nQ DBmNSYTxJEB+WER3fRcnrLg1GN3bB85yS9TUGfcYYMGBmidrUHb6OLof/p2Ln6EfYS5/ PzBXCCMjhvB8tl/IJu/7ElNqO98x0JscfrSw4Op0k8ksQHEsqu/qdl4HnRkWjS1rQT4m A7iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701265908; x=1701870708; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/rhQHcx3LLcsvi8JsQdTsfI9bgCOlf/fMigiqEoXsPs=; b=ovV6e1J7fsxaqgrtiy4bdk+QM9iZiEV84C/gqouAQOxHT8wA75NfJ8PHbEbZO7d53+ xws7tlhDrQSXPyc5Sg5nj/hDgJb2Mz8fDsqqsI+l1NPUMOEr3w6Na0ZunCJNZryDFnYR dSK6brdsaSBKXuo0gAznC+FNhrOt786GO3wK9MGr8/hyNa4OTds3+36IaQEtjGxpZGsd M+riy/emHTdgweEEj56h8jCs3f4Fec894tdUQwl2yvsUk4SuRQ6v3OaqLD4bNWe9f1+K 2P2utwu1bO3t5+3877rb4K99e3b6rZfUfbtFSSDXpdarMoZsK/9eL1oHs5pCM4Hd6V5d podA== X-Gm-Message-State: AOJu0YwBntTZDO5qyPIm+Ti6stKuxx71nFXmrg0vSwECz+jVg2RJ6ylO 7mpyO3ys6fPXr/lDtMXP5l0bTgDx1AXiC5XWoD8= X-Google-Smtp-Source: AGHT+IGChNKjkESbJaRp/2YhhSchIiU+eXNhaGZZuGROQ4g/oBNKRbUy3N7ubX7TpW+KphpbHy+rRg== X-Received: by 2002:a05:6512:114d:b0:509:4599:12d9 with SMTP id m13-20020a056512114d00b00509459912d9mr16538440lfg.6.1701265908147; Wed, 29 Nov 2023 05:51:48 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a28-20020ac2521c000000b0050ab88758b8sm2164280lfl.84.2023.11.29.05.51.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 05:51:46 -0800 (PST) From: Linus Walleij Date: Wed, 29 Nov 2023 14:51:46 +0100 Subject: [PATCH 2/4] Input: tca6416-keypad - Drop unused include Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231129-descriptors-input-v1-2-9433162914a3@linaro.org> References: <20231129-descriptors-input-v1-0-9433162914a3@linaro.org> In-Reply-To: <20231129-descriptors-input-v1-0-9433162914a3@linaro.org> To: Dmitry Torokhov , Tony Lindgren Cc: linux-input@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 The TCA6416 keypad driver is including the legacy GPIO header for no reason, it is not using any of its symbols. Drop the header. Signed-off-by: Linus Walleij --- drivers/input/keyboard/tca6416-keypad.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/input/keyboard/tca6416-keypad.c b/drivers/input/keyboard/tca6416-keypad.c index 8af59ced1ec2..677bc4baa5d1 100644 --- a/drivers/input/keyboard/tca6416-keypad.c +++ b/drivers/input/keyboard/tca6416-keypad.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include From patchwork Wed Nov 29 13:51:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 748844 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="IAvuDLua" Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63C7BCE for ; Wed, 29 Nov 2023 05:51:51 -0800 (PST) Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-50bc501081fso959796e87.1 for ; Wed, 29 Nov 2023 05:51:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701265909; x=1701870709; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=LMcH7HqNFaUybso4IhgNmtpCYxX1qk/8kEmmSQTbt3I=; b=IAvuDLuanRoOFGopz/xY0jtYmSQ7dkBUpmoGd+W3QF6aDvaBJdSt3B6H9YM1FIwJZ5 ZPorNBxb8WnneM2Fc1czP+rJnpdbc+pQn8nMdQAguefiqiPMOQiE7+YcAjX5ynF6fMB4 6ZY6K2nKecoJP2rZcpOXOt19mRvHMv0W74E2MONuvXvr0jwxHFAReNOUspD+Dg8wWoIy vy31/vJ0w/NuwAqsB1GyAnUepRxE+3M9g/uX20oq4kfapDkhu+tIhxUNkqoO+nd6HeqJ Hdlg7MFoQ4PGokMXzxQZbgfhaqlaX2perKiYGnd5bGYkl8jxj0hW/Of3F//EuDcsLzJ0 5rLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701265909; x=1701870709; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LMcH7HqNFaUybso4IhgNmtpCYxX1qk/8kEmmSQTbt3I=; b=SZkxKBKts25JUOx/569gvSO2uOcf18cq6Y6nNREw1ZUac6+k6McjoP+4r4ZQ/Jg9fv B3GP+6cmwzX0z0pOdVfHu4SpKrwPIIfhCNa3bftftSryinoz1XItrVjPctcBrifSPpsG lhFoMthM9PaJAfmCGLKRW0wsKpXx8EyuFwn9bCvy83rnTBAsUXm2RdtZKQBSsDs81kt/ d4Nhvgq7aRF1oOhtl+yX2B3vN8v/+GkGtr7eD+Y6IbShXDHiaAFGPbPb95IUynK8pPfY FucqYBVYtp0IP4MrfAx7HoML5Orgrg+51v1H5QhEbG3INFnKvpHYXR8fdQ2Gp6j7KGC4 BGhA== X-Gm-Message-State: AOJu0YyLrNnkWzS37m/VkUJAMxSJI34HviKs2VrMdBIQ2dUK18A6Y7HU J0kCm6rDDCjEt7MRbP7XRIOCeE9IvO2LJ7t6tIo= X-Google-Smtp-Source: AGHT+IHqWWTkkhifST4wKln0gZfMHhT9KI+NavqVpBNdbuyFbsloFN8Wktxe2RYaDdcmk7NP5eIBKw== X-Received: by 2002:a05:6512:31cb:b0:50b:a690:953f with SMTP id j11-20020a05651231cb00b0050ba690953fmr11509559lfe.18.1701265909467; Wed, 29 Nov 2023 05:51:49 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a28-20020ac2521c000000b0050ab88758b8sm2164280lfl.84.2023.11.29.05.51.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 05:51:48 -0800 (PST) From: Linus Walleij Date: Wed, 29 Nov 2023 14:51:47 +0100 Subject: [PATCH 3/4] Input: omap-keypad - Drop optional GPIO support Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231129-descriptors-input-v1-3-9433162914a3@linaro.org> References: <20231129-descriptors-input-v1-0-9433162914a3@linaro.org> In-Reply-To: <20231129-descriptors-input-v1-0-9433162914a3@linaro.org> To: Dmitry Torokhov , Tony Lindgren Cc: linux-input@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 The driver supports passing some GPIO lines for rows and columns through the driver data, but there is no in-kernel user of this. Further the use seems convoluted because the GPIO lines are unused in the driver, then explicitly free:ed when removing it without being requested when probing it, which is assymetric and just a recepie for disaster. Remove the support for these unused GPIOs, if need be support can be reestablished in an organized fashion using GPIO descriptors. Signed-off-by: Linus Walleij Reviewed-by: Tony Lindgren --- drivers/input/keyboard/omap-keypad.c | 16 +--------------- include/linux/platform_data/keypad-omap.h | 3 --- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c index 454fb8675657..99023b9de35f 100644 --- a/drivers/input/keyboard/omap-keypad.c +++ b/drivers/input/keyboard/omap-keypad.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -49,9 +48,6 @@ struct omap_kp { static DECLARE_TASKLET_DISABLED_OLD(kp_tasklet, omap_kp_tasklet); -static unsigned int *row_gpios; -static unsigned int *col_gpios; - static irqreturn_t omap_kp_interrupt(int irq, void *dev_id) { /* disable keyboard interrupt and schedule for handling */ @@ -180,7 +176,7 @@ static int omap_kp_probe(struct platform_device *pdev) struct omap_kp *omap_kp; struct input_dev *input_dev; struct omap_kp_platform_data *pdata = dev_get_platdata(&pdev->dev); - int i, col_idx, row_idx, ret; + int col_idx, row_idx, ret; unsigned int row_shift, keycodemax; if (!pdata->rows || !pdata->cols || !pdata->keymap_data) { @@ -209,11 +205,6 @@ static int omap_kp_probe(struct platform_device *pdev) if (pdata->delay) omap_kp->delay = pdata->delay; - if (pdata->row_gpios && pdata->col_gpios) { - row_gpios = pdata->row_gpios; - col_gpios = pdata->col_gpios; - } - omap_kp->rows = pdata->rows; omap_kp->cols = pdata->cols; @@ -276,11 +267,6 @@ static int omap_kp_probe(struct platform_device *pdev) err3: device_remove_file(&pdev->dev, &dev_attr_enable); err2: - for (i = row_idx - 1; i >= 0; i--) - gpio_free(row_gpios[i]); - for (i = col_idx - 1; i >= 0; i--) - gpio_free(col_gpios[i]); - kfree(omap_kp); input_free_device(input_dev); diff --git a/include/linux/platform_data/keypad-omap.h b/include/linux/platform_data/keypad-omap.h index 3e7c64c854f4..f3f1311cdf3a 100644 --- a/include/linux/platform_data/keypad-omap.h +++ b/include/linux/platform_data/keypad-omap.h @@ -19,9 +19,6 @@ struct omap_kp_platform_data { bool rep; unsigned long delay; bool dbounce; - /* specific to OMAP242x*/ - unsigned int *row_gpios; - unsigned int *col_gpios; }; /* Group (0..3) -- when multiple keys are pressed, only the From patchwork Wed Nov 29 13:51:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 748353 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="HuuG7Tf7" Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BDBBE6 for ; Wed, 29 Nov 2023 05:51:52 -0800 (PST) Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-50bb92811c0so929492e87.1 for ; Wed, 29 Nov 2023 05:51:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701265910; x=1701870710; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=0/WsO25oVrNPSsIiQTRTA56r+srmgXJ6yKUYJL3dXxU=; b=HuuG7Tf7zaHE5IiomQ84G4gfp08KZq4Rm8CUrdMwwhqxobWiN7vxGFigvfZEJ8yMZk l9cJowSGUASU3Do1lwjg0vYJrfQVdZJhmNeBqdBf3rYHnAr+FrmRyvq/oMlDu1wrv5qZ 6bfe2Ix2CMQA7PSAWq1xU+hpojML9x+Db3jy0f1vmvD8w2+4guMmG8RMLp4lztyfRqwg yCjTjNqjeuUqXOQehka2+XU1PQiT0gHDerH7/AU/0Dbf0sSImIsPsF2zUAHPCtnsqKmQ 3MYa71cJ9sPufJWUcxKCQWXDw0/fNG8GOp6XLyB5MkaeFpbzQGcKddKmz8qOWYe7QiT5 7tmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701265910; x=1701870710; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0/WsO25oVrNPSsIiQTRTA56r+srmgXJ6yKUYJL3dXxU=; b=CXR6KZKv7r9CiJ6qZL7AwGmTS8ZoEpEerEvbSy5EayoHxx2YDIIp6RujzTqcWO5Pa7 +tu1Ns2u6vWPueau7UtWmFuxZ0z+vot59D9IXOt+l29ZjP6cRCnkbi081pWxsGFJLCTO Dph708SxFcj7wbMYOmdBg6PnHbXx1FIXgEk/iVf4W8TRvpOcVbVhk5mNE9+HEsJXOU4I QJNgQJvVlVqD+wVYcajypi3DoAht6Prag+API/8cnRCR8TqMbIJbDtZSvVZilt9RLVdI gInMBoG6pOU621gifOdMhW4D3ckTTz0vIuUPoXvDrscpjSqUPFTlUpjGVkOypxc5VoQJ ujJw== X-Gm-Message-State: AOJu0YxEbmTNWim/B2X92Vcq38T/LV1MYlXgGsZw/XtTxxKp9eMUKPbO 8aGqOuw7IWCdkb0KPZDT8/xXHGT8MMzxXETDfeo= X-Google-Smtp-Source: AGHT+IFVCeLnx8W6HKSTMwYGJPSCe8mFdeYYyeec+lswRttmQ9fnaE+G2h7GmlMFe82v3ymxpxF4aA== X-Received: by 2002:a05:6512:2812:b0:50a:a6ea:405f with SMTP id cf18-20020a056512281200b0050aa6ea405fmr6596712lfb.4.1701265910170; Wed, 29 Nov 2023 05:51:50 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a28-20020ac2521c000000b0050ab88758b8sm2164280lfl.84.2023.11.29.05.51.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 05:51:49 -0800 (PST) From: Linus Walleij Date: Wed, 29 Nov 2023 14:51:48 +0100 Subject: [PATCH 4/4] Input: as5011 - Convert to GPIO descriptor Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231129-descriptors-input-v1-4-9433162914a3@linaro.org> References: <20231129-descriptors-input-v1-0-9433162914a3@linaro.org> In-Reply-To: <20231129-descriptors-input-v1-0-9433162914a3@linaro.org> To: Dmitry Torokhov , Tony Lindgren Cc: linux-input@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 This driver does not have any in-tree users but is passing a legacy GPIO number through platform data. Convert it to use a GPIO descriptor, new users or outoftree users can easily be implemented using GPIO descriptor tables or software nodes. Signed-off-by: Linus Walleij --- drivers/input/joystick/as5011.c | 24 +++++++++++------------- include/linux/input/as5011.h | 1 - 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/input/joystick/as5011.c b/drivers/input/joystick/as5011.c index bf8b1cc0ea9c..f1822c19a289 100644 --- a/drivers/input/joystick/as5011.c +++ b/drivers/input/joystick/as5011.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include @@ -61,7 +61,7 @@ MODULE_LICENSE("GPL"); struct as5011_device { struct input_dev *input_dev; struct i2c_client *i2c_client; - unsigned int button_gpio; + struct gpio_desc *button_gpiod; unsigned int button_irq; unsigned int axis_irq; }; @@ -114,7 +114,7 @@ static int as5011_i2c_read(struct i2c_client *client, static irqreturn_t as5011_button_interrupt(int irq, void *dev_id) { struct as5011_device *as5011 = dev_id; - int val = gpio_get_value_cansleep(as5011->button_gpio); + int val = gpiod_get_value_cansleep(as5011->button_gpiod); input_report_key(as5011->input_dev, BTN_JOYSTICK, !val); input_sync(as5011->input_dev); @@ -248,7 +248,6 @@ static int as5011_probe(struct i2c_client *client) as5011->i2c_client = client; as5011->input_dev = input_dev; - as5011->button_gpio = plat_data->button_gpio; as5011->axis_irq = plat_data->axis_irq; input_dev->name = "Austria Microsystem as5011 joystick"; @@ -262,18 +261,20 @@ static int as5011_probe(struct i2c_client *client) input_set_abs_params(as5011->input_dev, ABS_Y, AS5011_MIN_AXIS, AS5011_MAX_AXIS, AS5011_FUZZ, AS5011_FLAT); - error = gpio_request(as5011->button_gpio, "AS5011 button"); - if (error < 0) { - dev_err(&client->dev, "Failed to request button gpio\n"); + as5011->button_gpiod = devm_gpiod_get(&client->dev, NULL, GPIOD_IN); + if (IS_ERR(as5011->button_gpiod)) { + error = PTR_ERR(as5011->button_gpiod); + dev_err(&client->dev, "Failed to request button GPIO\n"); goto err_free_mem; } + gpiod_set_consumer_name(as5011->button_gpiod, "AS5011 button"); - irq = gpio_to_irq(as5011->button_gpio); + irq = gpiod_to_irq(as5011->button_gpiod); if (irq < 0) { dev_err(&client->dev, "Failed to get irq number for button gpio\n"); error = irq; - goto err_free_button_gpio; + goto err_free_mem; } as5011->button_irq = irq; @@ -286,7 +287,7 @@ static int as5011_probe(struct i2c_client *client) if (error < 0) { dev_err(&client->dev, "Can't allocate button irq %d\n", as5011->button_irq); - goto err_free_button_gpio; + goto err_free_mem; } error = as5011_configure_chip(as5011, plat_data); @@ -317,8 +318,6 @@ static int as5011_probe(struct i2c_client *client) free_irq(as5011->axis_irq, as5011); err_free_button_irq: free_irq(as5011->button_irq, as5011); -err_free_button_gpio: - gpio_free(as5011->button_gpio); err_free_mem: input_free_device(input_dev); kfree(as5011); @@ -332,7 +331,6 @@ static void as5011_remove(struct i2c_client *client) free_irq(as5011->axis_irq, as5011); free_irq(as5011->button_irq, as5011); - gpio_free(as5011->button_gpio); input_unregister_device(as5011->input_dev); kfree(as5011); diff --git a/include/linux/input/as5011.h b/include/linux/input/as5011.h index 5fba52a56cd6..5705d5de3aea 100644 --- a/include/linux/input/as5011.h +++ b/include/linux/input/as5011.h @@ -7,7 +7,6 @@ */ struct as5011_platform_data { - unsigned int button_gpio; unsigned int axis_irq; /* irq number */ unsigned long axis_irqflags; char xp, xn; /* threshold for x axis */