linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Arnd Bergmann <arnd@kernel.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	Linus Walleij <linus.walleij@linaro.org>,
	linux-gpio@vger.kernel.org,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Lee Jones <lee@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Gatien Chevallier <gatien.chevallier@foss.st.com>,
	Fabrice Gasnier <fabrice.gasnier@foss.st.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Charles Keepax <ckeepax@opensource.cirrus.com>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 09/21] input: gpio-keys: make legacy gpiolib optional
Date: Mon, 11 Aug 2025 13:34:43 +0300	[thread overview]
Message-ID: <b7e97aa3-8f2d-4a59-8a38-577717404865@gmail.com> (raw)
In-Reply-To: <20250808151822.536879-10-arnd@kernel.org>

Hi dee Ho peeps,

On 08/08/2025 18:17, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Most users of gpio-keys and gpio-keys-polled use modern gpiolib
> interfaces, but there are still number of ancient sh, arm32 and x86
> machines that have never been converted.
> 
> Add an #ifdef block for the parts of the driver that are only
> used on those legacy machines.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   drivers/input/keyboard/gpio_keys.c        | 5 +++--
>   drivers/input/keyboard/gpio_keys_polled.c | 2 ++
>   drivers/mfd/rohm-bd71828.c                | 2 ++
>   drivers/mfd/rohm-bd718x7.c                | 2 ++
>   include/linux/gpio_keys.h                 | 2 ++
>   5 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
> index f9db86da0818..984b20f773ed 100644
> --- a/drivers/input/keyboard/gpio_keys.c
> +++ b/drivers/input/keyboard/gpio_keys.c
> @@ -528,6 +528,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
>   			 */
>   			bdata->gpiod = NULL;
>   		}
> +#ifdef CONFIG_GPIOLIB_LEGACY
>   	} else if (gpio_is_valid(button->gpio)) {
>   		/*
>   		 * Legacy GPIO number, so request the GPIO here and
> @@ -546,6 +547,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
>   
>   		if (button->active_low ^ gpiod_is_active_low(bdata->gpiod))
>   			gpiod_toggle_active_low(bdata->gpiod);
> +#endif
>   	}
>   
>   	if (bdata->gpiod) {
> @@ -583,8 +585,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
>   			if (irq < 0) {
>   				error = irq;
>   				dev_err_probe(dev, error,
> -					      "Unable to get irq number for GPIO %d\n",
> -					      button->gpio);
> +					      "Unable to get irq number for GPIO\n");
>   				return error;
>   			}
>   			bdata->irq = irq;
> diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c
> index e6707d72210e..0ae0e53910ea 100644
> --- a/drivers/input/keyboard/gpio_keys_polled.c
> +++ b/drivers/input/keyboard/gpio_keys_polled.c
> @@ -301,6 +301,7 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
>   				return dev_err_probe(dev, PTR_ERR(bdata->gpiod),
>   						     "failed to get gpio\n");
>   			}
> +#ifdef CONFIG_GPIOLIB_LEGACY
>   		} else if (gpio_is_valid(button->gpio)) {
>   			/*
>   			 * Legacy GPIO number so request the GPIO here and
> @@ -323,6 +324,7 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
>   
>   			if (button->active_low ^ gpiod_is_active_low(bdata->gpiod))
>   				gpiod_toggle_active_low(bdata->gpiod);
> +#endif
>   		}
>   
>   		bdata->last_state = -1;
> diff --git a/drivers/mfd/rohm-bd71828.c b/drivers/mfd/rohm-bd71828.c
> index a14b7aa69c3c..fb68694fadca 100644
> --- a/drivers/mfd/rohm-bd71828.c
> +++ b/drivers/mfd/rohm-bd71828.c
> @@ -21,7 +21,9 @@
>   
>   static struct gpio_keys_button button = {
>   	.code = KEY_POWER,
> +#ifdef CONFIG_GPIOLIB_LEGACY
>   	.gpio = -1,
> +#endif
>   	.type = EV_KEY,
>   };
>   
> diff --git a/drivers/mfd/rohm-bd718x7.c b/drivers/mfd/rohm-bd718x7.c
> index 25e494a93d48..6c99ab62e31b 100644
> --- a/drivers/mfd/rohm-bd718x7.c
> +++ b/drivers/mfd/rohm-bd718x7.c
> @@ -20,7 +20,9 @@
>   
>   static struct gpio_keys_button button = {
>   	.code = KEY_POWER,
> +#ifdef CONFIG_GPIOLIB_LEGACY
>   	.gpio = -1,
> +#endif
>   	.type = EV_KEY,
>   };
>   
> diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h
> index 80fa930b04c6..e8d6dc290efb 100644
> --- a/include/linux/gpio_keys.h
> +++ b/include/linux/gpio_keys.h
> @@ -25,7 +25,9 @@ struct device;
>    */
>   struct gpio_keys_button {
>   	unsigned int code;
> +#ifdef CONFIG_GPIOLIB_LEGACY
>   	int gpio;
> +#endif
>   	int active_low;
>   	const char *desc;
>   	unsigned int type;

AFAIR, these ROHM PMICs (bd718[15, 27, 28, 37, 47, 50, 78, 85]) all 
provide a 'button IRQ', from a power button. (Or, couple of IRQs but 
let's skip the details) The gpio-keys is used to send the KEY_POWER 
event when IRQ is detected.

The IRQ comes from the PMIC, and the regmap_irq chip provided by the MFD 
provides it. This IRQ information is delivered to the gpio-keys from the 
MFD driver via platform data. That's basically what these "button" 
structs are here for. No GPIO line information (only the IRQ number) is 
needed to be delivered to the gpio-keys. This problematic assignment:

 > +#ifdef CONFIG_GPIOLIB_LEGACY
 >   	.gpio = -1,
 > +#endif

is only needed to invalidate the gpio information so that the gpio-keys 
wont use it, only the IRQ.

As such, this patch seems Ok to me, you can treat this as an ack :) 
This, however made me ponder following - is this the tight way to handle 
the power-button IRQ? I don't see any other MFD devices doing this in 
same way, although I am pretty sure there are other PMICs with similar 
power-button IRQ...

I see for example the "drivers/mfd/rt5120.c" to invoke 
"drivers/input/misc/rt5120-pwrkey.c" instead of using the gpio-keys. 
This, however, feels like code duplication to me. I'd rather kept using 
the gpio-keys, but seeing:

git grep KEY_POWER drivers/mfd/
drivers/mfd/rohm-bd71828.c:     .code = KEY_POWER,
drivers/mfd/rohm-bd718x7.c:     .code = KEY_POWER,

makes me wonder if there is more widely used (better) way?

Yours,
	-- Matti

  reply	other threads:[~2025-08-11 10:34 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-08 15:17 [PATCH 00/21] gpiolib: fence off legacy interfaces Arnd Bergmann
2025-08-08 15:17 ` [PATCH 01/21] ARM: select legacy gpiolib interfaces where used Arnd Bergmann
2025-08-11  8:49   ` Krzysztof Kozlowski
2025-08-08 15:17 ` [PATCH 02/21] m68k: coldfire: select legacy gpiolib interface for mcfqspi Arnd Bergmann
2025-08-08 15:17 ` [PATCH 03/21] mips: select legacy gpiolib interfaces where used Arnd Bergmann
2025-08-08 15:17 ` [PATCH 04/21] sh: select legacy gpiolib interface Arnd Bergmann
2025-08-12 18:28   ` Rob Landley
2025-08-12 21:28     ` Arnd Bergmann
2025-08-08 15:17 ` [PATCH 05/21] x86/platform: select legacy gpiolib interfaces where used Arnd Bergmann
2025-08-09 10:00   ` Andy Shevchenko
2025-08-09 19:44     ` Arnd Bergmann
2025-08-10 15:12       ` Hans de Goede
2025-08-11  2:27         ` Dmitry Torokhov
2025-08-08 15:17 ` [PATCH 06/21] x86/olpc: select GPIOLIB_LEGACY Arnd Bergmann
2025-08-12 17:01   ` Borislav Petkov
2025-08-08 15:17 ` [PATCH 07/21] mfd: wm8994: remove dead legacy-gpio code Arnd Bergmann
2025-08-11 13:14   ` Bartosz Golaszewski
2025-08-08 15:17 ` [PATCH 08/21] ASoC: add GPIOLIB_LEGACY dependency where needed Arnd Bergmann
2025-08-08 15:17 ` [PATCH 09/21] input: gpio-keys: make legacy gpiolib optional Arnd Bergmann
2025-08-11 10:34   ` Matti Vaittinen [this message]
2025-08-11 12:52     ` Andy Shevchenko
2025-08-11 19:21       ` Dmitry Torokhov
2025-08-11 20:09         ` Andy Shevchenko
2025-08-12  5:11           ` Matti Vaittinen
2025-08-08 15:17 ` [PATCH 10/21] leds: gpio: make legacy gpiolib interface optional Arnd Bergmann
2025-08-18 15:37   ` Linus Walleij
2025-08-19 12:19   ` Lee Jones
2025-08-19 12:59     ` Arnd Bergmann
2025-08-20  7:16       ` Lee Jones
2025-08-20 12:00         ` Arnd Bergmann
2025-08-20 13:15           ` Andy Shevchenko
2025-08-20 13:15             ` Andy Shevchenko
2025-08-08 15:17 ` [PATCH 11/21] media: em28xx: add special case for legacy gpiolib interface Arnd Bergmann
2025-08-08 15:17 ` [PATCH 12/21] mfd: arizona: make legacy gpiolib interface optional Arnd Bergmann
2025-09-02 12:44   ` Lee Jones
2025-09-02 13:47     ` Arnd Bergmann
2025-09-03  8:05       ` Lee Jones
2025-09-03  9:26         ` Arnd Bergmann
2025-08-08 15:17 ` [PATCH 13/21] mfd: si476x: add GPIOLIB_LEGACY dependency Arnd Bergmann
2025-08-08 15:17 ` [PATCH 14/21] mfd: aat2870: " Arnd Bergmann
2025-08-08 15:17 ` [PATCH 15/21] dsa: b53: hide legacy gpiolib usage on non-mips Arnd Bergmann
2025-08-09 10:01   ` Jonas Gorski
2025-08-09 20:55     ` Arnd Bergmann
2025-08-08 15:18 ` [PATCH 16/21] ath10k: remove gpio number assignment Arnd Bergmann
2025-08-08 15:18 ` [PATCH 17/21] nfc: marvell: convert to gpio descriptors Arnd Bergmann
2025-08-09 10:09   ` Andy Shevchenko
2025-08-11 21:43     ` Dmitry Torokhov
2025-08-13 12:35       ` Andy Shevchenko
2025-08-11  7:49   ` Bartosz Golaszewski
2025-08-13  7:48   ` Krzysztof Kozlowski
2025-08-08 15:18 ` [PATCH 18/21] nfc: s3fwrn5: " Arnd Bergmann
2025-08-11 22:08   ` Dmitry Torokhov
2025-08-08 15:18 ` [PATCH 19/21] usb: udc: pxa: remove unused platform_data Arnd Bergmann
2025-08-09 10:15   ` Andy Shevchenko
2025-08-11 22:12   ` Dmitry Torokhov
2025-08-08 15:18 ` [PATCH 20/21] ASoC: pxa: add GPIOLIB_LEGACY dependency Arnd Bergmann
2025-08-08 15:18 ` [PATCH 21/21] gpiolib: turn off legacy interface by default Arnd Bergmann
2025-08-09 10:18   ` Andy Shevchenko
2025-08-09 19:47     ` Arnd Bergmann
2025-08-11 12:49       ` Andy Shevchenko
2025-08-11 13:10 ` [PATCH 00/21] gpiolib: fence off legacy interfaces Bartosz Golaszewski
2025-08-12 16:23 ` (subset) " Mark Brown
2025-09-02 12:56 ` Lee Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b7e97aa3-8f2d-4a59-8a38-577717404865@gmail.com \
    --to=mazziesaccount@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=fabrice.gasnier@foss.st.com \
    --cc=gatien.chevallier@foss.st.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=lee@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).