From: sashiko-bot@kernel.org
To: "Mehmet Fide" <mehmet.fide@gmail.com>
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH v4 3/3] gpio: mmio: track the direction of chips without direction registers
Date: Thu, 03 Sep 2026 07:50:21 +0000 [thread overview]
Message-ID: <20260903075021.7AF3F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260903073143.2068494-4-mehmet.fide@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Incorrect parsing of packed pin configuration value in `gpio_mmio_seed_dir_from_pinctrl()` due to conflicting API contract.
--
commit 38b44b07fd26f5fd809a77e8d6044980715db7d8
Author: Mehmet Fide <mehmet.fide@screeningeagle.com>
gpio: mmio: track the direction of chips without direction registers
This commit tracks the direction of generic GPIO chips with a pinctrl
backend and no direction registers. It keeps the direction in the existing
shadow and updates it under the chip lock, reading the state once during
line request from the pin controller.
> diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c
> index 7e4b3e8d609f3..0709ffaab4dec 100644
> --- a/drivers/gpio/gpio-mmio.c
> +++ b/drivers/gpio/gpio-mmio.c
[ ... ]
> @@ -601,20 +622,51 @@ static int gpio_mmio_setup_direction(struct gpio_generic_chip *chip,
[ ... ]
> +static void gpio_mmio_seed_dir_from_pinctrl(struct gpio_chip *gc,
> + unsigned int gpio)
> +{
> + struct gpio_generic_chip *chip = to_gpio_generic_chip(gc);
> + unsigned long config;
> +
> + if (!gc->get_config || chip->reg_dir_out || chip->reg_dir_in)
> + return;
> +
> + config = pinconf_to_config_packed(PIN_CONFIG_OUTPUT_ENABLE, 0);
> + if (gc->get_config(gc, gpio, &config))
> + return;
> +
> + guard(raw_spinlock_irqsave)(&chip->lock);
> + if (config)
> + chip->sdir |= gpio_mmio_line2mask(gc, gpio);
> + else
> + chip->sdir &= ~gpio_mmio_line2mask(gc, gpio);
> +}
[Severity: Medium]
Are we correctly parsing the packed pin configuration value here?
The documentation for gc->get_config in include/linux/gpio/driver.h states it
uses the packed config format where the packed parameter and argument come out.
Because the packed format places the non-zero parameter ID
(PIN_CONFIG_OUTPUT_ENABLE) in the lower 8 bits, will evaluating config directly
as a boolean always be true?
If a conforming custom GPIO driver implements gc->get_config according to the
documented API, will its direction be unconditionally forced to output mode by
this check?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260903073143.2068494-1-mehmet.fide@gmail.com?part=3
next prev parent reply other threads:[~2026-09-03 7:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 7:31 [PATCH v4 0/3] gpio: mmio: report the line direction on chips without direction registers Mehmet Fide
2026-09-03 7:31 ` [PATCH v4 1/3] pinctrl: imx: answer OUTPUT_ENABLE/INPUT_ENABLE queries from the pad register Mehmet Fide
2026-09-03 7:43 ` sashiko-bot
2026-09-03 7:59 ` Mehmet Fide
2026-09-03 7:31 ` [PATCH v4 2/3] gpiolib: add get_config() and gpiochip_generic_get_config() Mehmet Fide
2026-09-03 7:45 ` sashiko-bot
2026-09-03 7:59 ` Mehmet Fide
2026-09-03 7:31 ` [PATCH v4 3/3] gpio: mmio: track the direction of chips without direction registers Mehmet Fide
2026-09-03 7:50 ` sashiko-bot [this message]
2026-09-03 7:59 ` 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=20260903075021.7AF3F1F000E9@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 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.