From: sashiko-bot@kernel.org
To: "Arnd Bergmann" <arnd@kernel.org>
Cc: dmitry.torokhov@gmail.com, lee@kernel.org,
linux-leds@vger.kernel.org, linux-input@vger.kernel.org
Subject: Re: [PATCH 2/6] [v6] Input: gpio-keys: make legacy gpiolib optional
Date: Fri, 10 Jul 2026 21:31:36 +0000 [thread overview]
Message-ID: <20260710213137.586DE1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260710211854.1371746-3-arnd@kernel.org>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] Legacy platforms that specify both a valid GPIO and an IRQ for a button are forced into purely interrupt-driven mode, degrading them to simulated pulse buttons.
- [Low] The patch includes a non-existent header file `linux/gpio/legacy.h`, unconditionally breaking the build.
Pre-existing issues:
- [High] The Rohm MFD drivers dynamically mutate a globally shared static struct during probe, breaking reentrancy and violating MFD guidelines.
--
--- Patch [2]: [PATCH 2/6] [v6] Input: gpio-keys: make legacy gpiolib optional ---
commit 1e2acc08348477940313314a2e3563828ed3ae8b
Author: Arnd Bergmann <arnd@arndb.de>
Input: gpio-keys: make legacy gpiolib optional
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.
Link: https://lore.kernel.org/all/b3c94552-c104-42e3-be15-7e8362e8039e@gmail.com/
Link: https://lore.kernel.org/all/afJXG4_rtaj3l2Dk@google.com/
Link: https://lore.kernel.org/all/ajQ-CtU131FAJ9ES@google.com/
> diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
> --- a/drivers/input/keyboard/gpio_keys.c
> +++ b/drivers/input/keyboard/gpio_keys.c
> @@ -23,8 +23,8 @@
> #include <linux/input.h>
> #include <linux/gpio_keys.h>
> #include <linux/workqueue.h>
> -#include <linux/gpio.h>
> #include <linux/gpio/consumer.h>
> +#include <linux/gpio/legacy.h>
[Severity: Low]
Does this header file exist in the source tree? Because this include is
outside of any #ifdef blocks, it looks like it will unconditionally break
the build for anyone compiling with CONFIG_KEYBOARD_GPIO enabled.
> #include <linux/of.h>
> #include <linux/of_irq.h>
> #include <linux/spinlock.h>
[ ... ]
> @@ -528,7 +528,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
> */
> bdata->gpiod = NULL;
> }
> - } else if (gpio_is_valid(button->gpio)) {
> +#ifdef CONFIG_GPIOLIB_LEGACY
> + } else if (!button->irq && gpio_is_valid(button->gpio)) {
[Severity: High]
Does this new !button->irq condition inadvertently break legacy boards that
legitimately supply both a valid .gpio and an .irq?
For example, in arch/arm/mach-sa1100/assabet.c, assabet_keys_buttons defines
buttons with both .gpio = 0 and .irq = IRQ_GPIO0. Since the GPIO is no
longer requested when an IRQ is present, wouldn't the driver fall back to
purely interrupt-driven mode?
If so, this would lack a GPIO descriptor to read the physical button level,
turning holdable physical buttons into simulated momentary pulses via the
auto-release timer.
> /*
> * Legacy GPIO number, so request the GPIO here and
> * convert it to descriptor.
[ ... ]
> diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c
> --- a/drivers/input/keyboard/gpio_keys_polled.c
> +++ b/drivers/input/keyboard/gpio_keys_polled.c
> @@ -18,8 +18,8 @@
> #include <linux/input.h>
> #include <linux/ioport.h>
> #include <linux/platform_device.h>
> -#include <linux/gpio.h>
> #include <linux/gpio/consumer.h>
> +#include <linux/gpio/legacy.h>
[Severity: Low]
Similar to gpio_keys.c, does this unconditionally break the build since
linux/gpio/legacy.h is missing from the tree?
> #include <linux/gpio_keys.h>
> #include <linux/property.h>
[ ... ]
> diff --git a/drivers/mfd/rohm-bd71828.c b/drivers/mfd/rohm-bd71828.c
> --- a/drivers/mfd/rohm-bd71828.c
> +++ b/drivers/mfd/rohm-bd71828.c
> @@ -39,7 +39,6 @@
>
> static struct gpio_keys_button button = {
> .code = KEY_POWER,
> - .gpio = -1,
> .type = EV_KEY,
> .wakeup = 1,
> };
[Severity: High]
This isn't a bug introduced by this patch, but this static struct is modified
dynamically during bd71828_i2c_probe() when assigning button.irq = ret.
Since mfd_add_devices() only shallow-copies the platform data, doesn't
mutating a globally shared static struct during probe break reentrancy?
Multiple instances of the PMIC or repeated probes due to unbind/deferral
could clobber each other's IRQ number here.
> diff --git a/drivers/mfd/rohm-bd718x7.c b/drivers/mfd/rohm-bd718x7.c
> --- a/drivers/mfd/rohm-bd718x7.c
> +++ b/drivers/mfd/rohm-bd718x7.c
> @@ -20,7 +20,6 @@
>
> static struct gpio_keys_button button = {
> .code = KEY_POWER,
> - .gpio = -1,
> .type = EV_KEY,
> };
[Severity: High]
This is a pre-existing issue, but just like in rohm-bd71828.c, mutating this
shared static struct during bd718xx_i2c_probe() violates MFD guidelines and
could cause race conditions with concurrent or repeated probes.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260710211854.1371746-1-arnd@kernel.org?part=2
next prev parent reply other threads:[~2026-07-10 21:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 21:18 [PATCH v6 0/6] gpiolib: fence off legacy interfaces Arnd Bergmann
2026-07-10 21:18 ` [PATCH 1/6] [v6] Input: soc_button_array - select CONFIG_GPIOLIB_LEGACY Arnd Bergmann
2026-07-10 21:26 ` sashiko-bot
2026-07-10 21:18 ` [PATCH 2/6] [v6] Input: gpio-keys: make legacy gpiolib optional Arnd Bergmann
2026-07-10 21:31 ` sashiko-bot [this message]
2026-07-10 21:18 ` [PATCH 3/6] [v6] leds: gpio: make legacy gpiolib interface optional Arnd Bergmann
2026-07-10 21:32 ` sashiko-bot
2026-07-10 21:18 ` [PATCH 4/6] [v6] sh: select legacy gpiolib interface Arnd Bergmann
2026-07-10 21:26 ` sashiko-bot
2026-07-10 21:18 ` [PATCH 5/6] [v6] x86/olpc: select GPIOLIB_LEGACY Arnd Bergmann
2026-07-10 21:28 ` sashiko-bot
2026-07-10 21:18 ` [PATCH 6/6] [v6] gpiolib: turn off legacy interface by default Arnd Bergmann
2026-07-10 21:35 ` sashiko-bot
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=20260710213137.586DE1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=arnd@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=lee@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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