mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
	Linus Walleij <linusw@kernel.org>,
	Bartosz Golaszewski <brgl@kernel.org>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] gpiolib: normalize the return value of gc->set() on behalf of buggy drivers
Date: Thu, 19 Feb 2026 00:57:58 -0800	[thread overview]
Message-ID: <48629460-701F-438F-8E1A-6F428C49FF6E@gmail.com> (raw)
In-Reply-To: <20260219-gpiolib-set-normalize-v1-1-f0d53a009db4@oss.qualcomm.com>

On February 19, 2026 12:52:37 AM PST, Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> wrote:
>Commit 86ef402d805d ("gpiolib: sanitize the return value of
>gpio_chip::get()") started checking the return value of the .set()
>callback in struct gpio_chip. Now - almost a year later - it turns out
>that there are quite a few drivers in tree that can break with this
>change. Partially revert it: normalize the return value in GPIO core but
>also emit a warning.
>
>Cc: stable@vger.kernel.org
>Fixes: 86ef402d805d ("gpiolib: sanitize the return value of gpio_chip::get()")
>Reported-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>Closes: https://lore.kernel.org/all/aZSkqGTqMp_57qC7@google.com/
>Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
>---
> drivers/gpio/gpiolib.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
>index c52200eaaaff82b12f22dd1ee8459bdd8ec10d81..9f7a1a1ebd8365fe933c989caf9e8c544fd9ba0f 100644
>--- a/drivers/gpio/gpiolib.c
>+++ b/drivers/gpio/gpiolib.c
>@@ -2914,8 +2914,12 @@ static int gpiochip_set(struct gpio_chip *gc, unsigned int offset, int value)
> 		return -EOPNOTSUPP;
> 
> 	ret = gc->set(gc, offset, value);
>-	if (ret > 0)
>-		ret = -EBADE;
>+	if (ret > 0) {
>+		gpiochip_warn(gc,
>+			"invalid return value from gc->set(): %d, consider fixing the driver\n",
>+			ret);
>+		ret = !!ret;
>+	}
> 
> 	return ret;
> }

You want to patch gpiochip_get(). It could be that set() is similarly troublesome, but the report is about get() not working.

Thanks. 
Hi Bartosz, 
-- 
Dmitry

  reply	other threads:[~2026-02-19  8:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-19  8:52 Bartosz Golaszewski
2026-02-19  8:57 ` Dmitry Torokhov [this message]
2026-02-19  9:17   ` Bartosz Golaszewski

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=48629460-701F-438F-8E1A-6F428C49FF6E@gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=bartosz.golaszewski@oss.qualcomm.com \
    --cc=brgl@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®