mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] gpiolib: reset lookup flags for each hogged line
@ 2026-11-04 11:59 Jinseob Kim
  2026-11-05  8:55 ` Bartosz Golaszewski
  0 siblings, 1 reply; 2+ messages in thread
From: Jinseob Kim @ 2026-11-04 11:59 UTC (permalink / raw)
  To: brgl; +Cc: linusw, linux-gpio, linux-kernel

gpiochip_add_hog() initializes lflags once before iterating over the GPIO
specifiers. In the non-OF path, an active-low line sets GPIO_ACTIVE_LOW,
but a later active-high line does not clear it. A single firmware hog
with mixed polarities therefore configures later active-high lines as
active-low, including inverting their initial output value.

Initialize the lookup flags for each line before translating its flags.
The OF helper already overwrites the flags for each specifier; the
non-OF path must also start with a fresh value.

Codex assisted with identifying the issue and developing the fix.

Fixes: 802c51a83e9a ("gpiolib: fix hogs with multiple lines")
Signed-off-by: Jinseob Kim <kimjinseob88@gmail.com>
---
Changes in v2:
- Split the functional fix from its KUnit regression test as requested.
- Keep only the lookup-flag reset in gpiolib.c for gpio/for-current.
- Move build/runtime details out of the permanent commit message.

Target: brgl/linux gpio/for-current at c2d0710318b8cd57d0ef6088d0ee4bbc1e827fd3.
The KUnit test is sent separately for the v7.5 development cycle.

Testing on this target: actual UML/KUnit, before 8 pass / 1 fail;
after 9 pass / 0 fail, with the same config and test source.
GCC W=1 and Clang W=1/private Sparse C=2 builds completed.
No physical GPIO or runtime OF hardware validation was performed.

Previous version: https://lore.kernel.org/linux-gpio/20261103224339.1180-1-kimjinseob88@gmail.com/
Review: https://lore.kernel.org/linux-gpio/qboynvhfmvltsuopwotpf3sqdwho3qobxmw5qldooedjqodfgy@x4l6hscj5unx/

 drivers/gpio/gpiolib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index fbdeda2f2..db613770d 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -975,7 +975,6 @@ int gpiochip_add_hog(struct gpio_chip *gc, struct fwnode_handle *fwnode)
 	 */
 	u32 cells = 2;
 
-	lflags = GPIO_LOOKUP_FLAGS_DEFAULT;
 	dflags = GPIOD_ASIS;
 	name = NULL;
 
@@ -1014,6 +1013,8 @@ int gpiochip_add_hog(struct gpio_chip *gc, struct fwnode_handle *fwnode)
 	fwnode_property_read_string(fwnode, "line-name", &name);
 
 	for (unsigned int i = 0; i < num_hogs; i++) {
+		lflags = GPIO_LOOKUP_FLAGS_DEFAULT;
+
 		if (is_of_node(fwnode)) {
 			/*
 			 * OF-nodes need some additional special handling for

base-commit: c2d0710318b8cd57d0ef6088d0ee4bbc1e827fd3

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] gpiolib: reset lookup flags for each hogged line
  2026-11-04 11:59 [PATCH v2] gpiolib: reset lookup flags for each hogged line Jinseob Kim
@ 2026-11-05  8:55 ` Bartosz Golaszewski
  0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2026-11-05  8:55 UTC (permalink / raw)
  To: brgl, Jinseob Kim; +Cc: Bartosz Golaszewski, linusw, linux-gpio, linux-kernel


On Wed, 04 Nov 2026 20:59:38 +0900, Jinseob Kim wrote:
> gpiochip_add_hog() initializes lflags once before iterating over the GPIO
> specifiers. In the non-OF path, an active-low line sets GPIO_ACTIVE_LOW,
> but a later active-high line does not clear it. A single firmware hog
> with mixed polarities therefore configures later active-high lines as
> active-low, including inverting their initial output value.
> 
> Initialize the lookup flags for each line before translating its flags.
> The OF helper already overwrites the flags for each specifier; the
> non-OF path must also start with a fresh value.
> 
> [...]

Applied, thanks!

[1/1] gpiolib: reset lookup flags for each hogged line
      https://git.kernel.org/brgl/c/c20464a78162cf8b3a1c9dc7e0d764e535bfe582

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-05  8:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-04 11:59 [PATCH v2] gpiolib: reset lookup flags for each hogged line Jinseob Kim
2026-11-05  8:55 ` Bartosz Golaszewski

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®