All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael Walle" <mwalle@kernel.org>
To: "Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>,
	"Linus Walleij" <linusw@kernel.org>,
	"Bartosz Golaszewski" <brgl@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-gpio@vger.kernel.org>
Subject: Re: [PATCH] gpiolib: remove redundant callback check
Date: Fri, 09 Jan 2026 15:05:36 +0100	[thread overview]
Message-ID: <DFK46PUEYQFD.1ZE4WO3YCYQJ9@kernel.org> (raw)
In-Reply-To: <20260109105557.20024-1-bartosz.golaszewski@oss.qualcomm.com>

[-- Attachment #1: Type: text/plain, Size: 1358 bytes --]

Hi,

On Fri Jan 9, 2026 at 11:55 AM CET, Bartosz Golaszewski wrote:
> The presence of the .get_direction() callback is already checked in
> gpiochip_get_direction(). Remove the duplicated check which also returns
> the wrong error code to user-space.
>
> Fixes: e623c4303ed1 ("gpiolib: sanitize the return value of gpio_chip::get_direction()")
> Reported-by: Michael Walle <mwalle@kernel.org>
> Closes: https://lore.kernel.org/all/DFJAFK3DTBOZ.3G2P3A5IH34GF@kernel.org/
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> ---
>  drivers/gpio/gpiolib.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 0a14085f3871..5eb918da7ea2 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -468,9 +468,6 @@ int gpiod_get_direction(struct gpio_desc *desc)
>  	    test_bit(GPIOD_FLAG_IS_OUT, &flags))
>  		return 0;
>  
> -	if (!guard.gc->get_direction)
> -		return -ENOTSUPP;
> -

Not sure, if that will make it better or worse though.

>  	ret = gpiochip_get_direction(guard.gc, offset);

Because that will then do a WARN_ON(!.get_direction) and will spam
the kernel log in case of the gpio-shared-proxy. Also the return
code will change from ENOTSUPP to EOPNOTSUPP.

-michael

>  	if (ret < 0)
>  		return ret;


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 297 bytes --]

  reply	other threads:[~2026-01-09 14:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-09 10:55 [PATCH] gpiolib: remove redundant callback check Bartosz Golaszewski
2026-01-09 14:05 ` Michael Walle [this message]
2026-01-09 14:36   ` Bartosz Golaszewski
2026-01-12  8:41 ` 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=DFK46PUEYQFD.1ZE4WO3YCYQJ9@kernel.org \
    --to=mwalle@kernel.org \
    --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 \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.