From: "Nuno Sá" <nuno.sa@analog.com>
To: "Alvin Šipraga" <alvin.sipraga@analog.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Xiaolong Chen <xiaolong.chen@gmail.com>,
Yuanbo Ye <yuan-bo.ye@motorola.com>, Tao Hu <taohu@motorola.com>,
Dmitry Torokhov <dtor@mail.ru>,
linux-gpio@vger.kernel.org, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Input: adp5588-keys - cache GPIO state before registering the gpiochip
Date: Tue, 18 Aug 2026 17:08:01 +0100 [thread overview]
Message-ID: <aoSDTjIbJmlS8CAA@nsa> (raw)
In-Reply-To: <20260818-adp5588-gpio-cache-v1-1-650a2674fc0d@analog.com>
On Tue, Aug 18, 2026 at 06:00:02PM +0200, Alvin Šipraga wrote:
> So as not to clobber any pre-programmed GPIO state in the execution
> of its gpiochip ops, the driver caches things during probe time.
> However, since those ops can be called both during and immediately after
> the call to devm_gpiochip_add_data(), it is imperative that things are
> cached before that. That's not the case right now, so reorder the two
> steps to prevent any clobbering.
>
> In a conrete example which motivated this change, a bootloader was
> preconfiguring an important GPIO output to HIGH before booting the
> kernel. Linux would then inadvertently set that output to LOW while
> configuring a GPIO hog on a discrete GPIO line within the same 8-bit
> bank (because the cached value was 0=LOW).
>
> Fixes: ba9f507a1bea ("Input: adp5588-keys - export unused GPIO pins")
> Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
> ---
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> drivers/input/keyboard/adp5588-keys.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c
> index 40371f5bd9ba..4f0ddff5baba 100644
> --- a/drivers/input/keyboard/adp5588-keys.c
> +++ b/drivers/input/keyboard/adp5588-keys.c
> @@ -446,12 +446,6 @@ static int adp5588_gpio_add(struct adp5588_kpad *kpad)
>
> mutex_init(&kpad->gpio_lock);
>
> - error = devm_gpiochip_add_data(dev, &kpad->gc, kpad);
> - if (error) {
> - dev_err(dev, "gpiochip_add failed: %d\n", error);
> - return error;
> - }
> -
> for (i = 0; i <= ADP5588_BANK(ADP5588_MAXGPIO); i++) {
> kpad->dat_out[i] = adp5588_read(kpad->client,
> GPIO_DAT_OUT1 + i);
> @@ -459,6 +453,12 @@ static int adp5588_gpio_add(struct adp5588_kpad *kpad)
> kpad->pull_dis[i] = adp5588_read(kpad->client, GPIO_PULL1 + i);
> }
>
> + error = devm_gpiochip_add_data(dev, &kpad->gc, kpad);
> + if (error) {
> + dev_err(dev, "gpiochip_add failed: %d\n", error);
> + return error;
> + }
> +
> return 0;
> }
>
>
> ---
> base-commit: 44f3468a0aef1aabdad551898ab7cfa2a9d20e99
> change-id: 20260818-adp5588-gpio-cache-23fb8d0a3190
>
> Best regards,
> --
> Alvin Šipraga <alvin.sipraga@analog.com>
>
prev parent reply other threads:[~2026-08-18 16:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 16:00 [PATCH] Input: adp5588-keys - cache GPIO state before registering the gpiochip Alvin Šipraga
2026-08-18 16:08 ` Nuno Sá [this message]
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=aoSDTjIbJmlS8CAA@nsa \
--to=nuno.sa@analog.com \
--cc=alvin.sipraga@analog.com \
--cc=dmitry.torokhov@gmail.com \
--cc=dtor@mail.ru \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.hennerich@analog.com \
--cc=taohu@motorola.com \
--cc=xiaolong.chen@gmail.com \
--cc=yuan-bo.ye@motorola.com \
/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