From: sashiko-bot@kernel.org
To: "Mehmet Fide" <mehmet.fide@gmail.com>
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH v5 2/3] gpiolib: add get_config() and gpiochip_generic_get_config()
Date: Thu, 03 Sep 2026 08:14:31 +0000 [thread overview]
Message-ID: <20260903081432.278721F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260903075940.2089367-3-mehmet.fide@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] The fallback stub for `pinctrl_gpio_get_config()` returns 0 without modifying the output `config` parameter, causing callers to use query enums or uninitialized memory as hardware states.
- [High] `gpiochip_generic_config()` returns 0 (success) when `CONFIG_PINCTRL` is disabled, silently ignoring hardware configuration requests and creating an API inconsistency.
--
commit 5e30160f0acecf52b9ebfedbbaf09c6e99e8ce08
Author: Mehmet Fide <mehmet.fide@screeningeagle.com>
Subject: gpiolib: add get_config() and gpiochip_generic_get_config()
This commit introduces a new get_config() callback for gpiochip and provides
gpiochip_generic_get_config() as the generic pin control backend implementation.
This allows a chip to read back a line's configuration, which is useful for
determining line direction when the pin controller owns it.
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index ef8ccaf17c9ce..fb3ef6754a9ee 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -2440,6 +2440,29 @@ int gpiochip_generic_config(struct gpio_chip *gc, unsigned int offset,
> }
> EXPORT_SYMBOL_GPL(gpiochip_generic_config);
[Severity: High]
This isn't a bug introduced by this patch, but right above this new function,
gpiochip_generic_config() delegates to pinctrl_gpio_set_config(). When
CONFIG_PINCTRL is disabled, it skips the pin_ranges check and calls the stub,
which silently returns 0:
include/linux/pinctrl/consumer.h:pinctrl_gpio_set_config() {
return 0;
}
Does this cause hardware configuration requests to be silently ignored while
reporting success to the caller? The new getter correctly avoids this by
returning -ENOTSUPP when the backend is disabled. Should the pre-existing
setter stub also be updated to return -ENOTSUPP to ensure consistent API
behavior?
>
> +/**
> + * gpiochip_generic_get_config() - read back the configuration of a pin
> + * @gc: the gpiochip owning the GPIO
> + * @offset: the offset of the GPIO to query
> + * @config: the packed parameter to query, replaced by its bare argument
> + *
> + * Returns:
> + * 0 on success, or negative errno on failure.
> + */
> +int gpiochip_generic_get_config(struct gpio_chip *gc, unsigned int offset,
> + unsigned long *config)
> +{
> +#ifdef CONFIG_PINCTRL
> + if (list_empty(&gc->gpiodev->pin_ranges))
> + return -ENOTSUPP;
> +
> + return pinctrl_gpio_get_config(gc, offset, config);
> +#else
> + return -ENOTSUPP;
> +#endif
[Severity: High]
This is a pre-existing issue, but I notice this helper explicitly works
around the behavior of the fallback stub for pinctrl_gpio_get_config().
Since the stub returns 0 without modifying the output config parameter:
include/linux/pinctrl/consumer.h:pinctrl_gpio_get_config() {
return 0;
}
direct callers (such as pin_control_gpio_get_direction() in
drivers/gpio/gpio-by-pinctrl.c) are left reading uninitialized memory or
query enum values as hardware states when CONFIG_PINCTRL is disabled.
Should the root stub in include/linux/pinctrl/consumer.h be fixed to return
-ENOTSUPP directly to prevent other callers from breaking?
> +}
> +EXPORT_SYMBOL_GPL(gpiochip_generic_get_config);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260903075940.2089367-1-mehmet.fide@gmail.com?part=2
next prev parent reply other threads:[~2026-09-03 8:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 7:59 [PATCH v5 0/3] gpio: mmio: report the line direction on chips without direction registers Mehmet Fide
2026-09-03 7:59 ` [PATCH v5 1/3] pinctrl: imx: answer OUTPUT_ENABLE/INPUT_ENABLE queries from the pad register Mehmet Fide
2026-09-03 7:59 ` [PATCH v5 2/3] gpiolib: add get_config() and gpiochip_generic_get_config() Mehmet Fide
2026-09-03 8:14 ` sashiko-bot [this message]
2026-09-03 7:59 ` [PATCH v5 3/3] gpio: mmio: track the direction of chips without direction registers Mehmet Fide
2026-09-03 8:27 ` [PATCH v5 0/3] gpio: mmio: report the line direction on " Bartosz Golaszewski
2026-09-03 8:38 ` Mehmet Fide
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=20260903081432.278721F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=imx@lists.linux.dev \
--cc=mehmet.fide@gmail.com \
--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