linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] gpio: shared: fix some corner cases
@ 2025-11-26 16:49 Bartosz Golaszewski
  2025-11-26 16:49 ` [PATCH 1/2] gpio: shared: ignore special __symbols__ node when traversing device tree Bartosz Golaszewski
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2025-11-26 16:49 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski, Jon Hunter,
	Cosmin Tanislav

Here are fixes for two more bugs reported in linux-next.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
Bartosz Golaszewski (2):
      gpio: shared: ignore special __symbols__ node when traversing device tree
      gpio: shared: ignore GPIO hogs when traversing the device tree

 drivers/gpio/gpiolib-shared.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
---
base-commit: 3fc91e5912eb3761d7b19e6ee8eb92749e856316
change-id: 20251126-gpio-shared-fixes-080ab392483f

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


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

* [PATCH 1/2] gpio: shared: ignore special __symbols__ node when traversing device tree
  2025-11-26 16:49 [PATCH 0/2] gpio: shared: fix some corner cases Bartosz Golaszewski
@ 2025-11-26 16:49 ` Bartosz Golaszewski
  2025-11-26 20:56   ` Jon Hunter
  2025-11-26 16:49 ` [PATCH 2/2] gpio: shared: ignore GPIO hogs when traversing the " Bartosz Golaszewski
  2025-11-28  8:30 ` [PATCH 0/2] gpio: shared: fix some corner cases Bartosz Golaszewski
  2 siblings, 1 reply; 5+ messages in thread
From: Bartosz Golaszewski @ 2025-11-26 16:49 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski, Jon Hunter

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

The __symbols__ node is a special, internal node and its properties must
not be considered when scanning the device-tree for shared GPIOs.

Fixes: a060b8c511ab ("gpiolib: implement low-level, shared GPIO support")
Reported-by: Jon Hunter <jonathanh@nvidia.com>
Closes: https://lore.kernel.org/all/0829a21c-f97d-41b6-90bc-2acaec42caab@nvidia.com/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpiolib-shared.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/gpio/gpiolib-shared.c b/drivers/gpio/gpiolib-shared.c
index 3803b5c938f9933dab01c6d777c349ed3b42ce9b..62f32489a8a6f70c567ed93645f1e36a81612def 100644
--- a/drivers/gpio/gpiolib-shared.c
+++ b/drivers/gpio/gpiolib-shared.c
@@ -73,6 +73,19 @@ gpio_shared_find_entry(struct fwnode_handle *controller_node,
 	return NULL;
 }
 
+/* Handle all special nodes that we should ignore. */
+static bool gpio_shared_of_node_ignore(struct device_node *node)
+{
+	/*
+	 * __symbols__ is a special, internal node and should not be considered
+	 * when scanning for shared GPIOs.
+	 */
+	if (of_node_name_eq(node, "__symbols__"))
+		return true;
+
+	return false;
+}
+
 static int gpio_shared_of_traverse(struct device_node *curr)
 {
 	struct gpio_shared_entry *entry;
@@ -84,6 +97,9 @@ static int gpio_shared_of_traverse(struct device_node *curr)
 	const char *suffix;
 	int ret, count, i;
 
+	if (gpio_shared_of_node_ignore(curr))
+		return 0;
+
 	for_each_property_of_node(curr, prop) {
 		/*
 		 * The standard name for a GPIO property is "foo-gpios"

-- 
2.51.0


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

* [PATCH 2/2] gpio: shared: ignore GPIO hogs when traversing the device tree
  2025-11-26 16:49 [PATCH 0/2] gpio: shared: fix some corner cases Bartosz Golaszewski
  2025-11-26 16:49 ` [PATCH 1/2] gpio: shared: ignore special __symbols__ node when traversing device tree Bartosz Golaszewski
@ 2025-11-26 16:49 ` Bartosz Golaszewski
  2025-11-28  8:30 ` [PATCH 0/2] gpio: shared: fix some corner cases Bartosz Golaszewski
  2 siblings, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2025-11-26 16:49 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski, Cosmin Tanislav

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

GPIO hogs have a "gpios" property but it's not a phandle to a remote
node - it references the parent GPIO controller. We must not try to
parse it as a phandle.

Fixes: a060b8c511ab ("gpiolib: implement low-level, shared GPIO support")
Reported-by: Cosmin Tanislav <demonsingur@gmail.com>
Closes: https://lore.kernel.org/all/2d96e464-e17c-4ff5-9a08-b215b77da04f@gmail.com/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpiolib-shared.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpio/gpiolib-shared.c b/drivers/gpio/gpiolib-shared.c
index 62f32489a8a6f70c567ed93645f1e36a81612def..7e049f2153a3fcc51803dd185fe5db60daea789f 100644
--- a/drivers/gpio/gpiolib-shared.c
+++ b/drivers/gpio/gpiolib-shared.c
@@ -83,6 +83,13 @@ static bool gpio_shared_of_node_ignore(struct device_node *node)
 	if (of_node_name_eq(node, "__symbols__"))
 		return true;
 
+	/*
+	 * GPIO hogs have a "gpios" property which is not a phandle and can't
+	 * possibly refer to a shared GPIO.
+	 */
+	if (of_property_present(node, "gpio-hog"))
+		return true;
+
 	return false;
 }
 

-- 
2.51.0


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

* Re: [PATCH 1/2] gpio: shared: ignore special __symbols__ node when traversing device tree
  2025-11-26 16:49 ` [PATCH 1/2] gpio: shared: ignore special __symbols__ node when traversing device tree Bartosz Golaszewski
@ 2025-11-26 20:56   ` Jon Hunter
  0 siblings, 0 replies; 5+ messages in thread
From: Jon Hunter @ 2025-11-26 20:56 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij, Bartosz Golaszewski
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski,
	linux-tegra@vger.kernel.org



On 26/11/2025 16:49, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> The __symbols__ node is a special, internal node and its properties must
> not be considered when scanning the device-tree for shared GPIOs.
> 
> Fixes: a060b8c511ab ("gpiolib: implement low-level, shared GPIO support")
> Reported-by: Jon Hunter <jonathanh@nvidia.com>
> Closes: https://lore.kernel.org/all/0829a21c-f97d-41b6-90bc-2acaec42caab@nvidia.com/
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
>   drivers/gpio/gpiolib-shared.c | 16 ++++++++++++++++
>   1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/gpio/gpiolib-shared.c b/drivers/gpio/gpiolib-shared.c
> index 3803b5c938f9933dab01c6d777c349ed3b42ce9b..62f32489a8a6f70c567ed93645f1e36a81612def 100644
> --- a/drivers/gpio/gpiolib-shared.c
> +++ b/drivers/gpio/gpiolib-shared.c
> @@ -73,6 +73,19 @@ gpio_shared_find_entry(struct fwnode_handle *controller_node,
>   	return NULL;
>   }
>   
> +/* Handle all special nodes that we should ignore. */
> +static bool gpio_shared_of_node_ignore(struct device_node *node)
> +{
> +	/*
> +	 * __symbols__ is a special, internal node and should not be considered
> +	 * when scanning for shared GPIOs.
> +	 */
> +	if (of_node_name_eq(node, "__symbols__"))
> +		return true;
> +
> +	return false;
> +}
> +
>   static int gpio_shared_of_traverse(struct device_node *curr)
>   {
>   	struct gpio_shared_entry *entry;
> @@ -84,6 +97,9 @@ static int gpio_shared_of_traverse(struct device_node *curr)
>   	const char *suffix;
>   	int ret, count, i;
>   
> +	if (gpio_shared_of_node_ignore(curr))
> +		return 0;
> +
>   	for_each_property_of_node(curr, prop) {
>   		/*
>   		 * The standard name for a GPIO property is "foo-gpios"
> 

Fixes it for me!

Tested-by: Jon Hunter <jonathanh@nvidia.com>
Acked-by: Jon Hunter <jonathanh@nvidia.com>

Thanks
Jon

-- 
nvpublic


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

* Re: [PATCH 0/2] gpio: shared: fix some corner cases
  2025-11-26 16:49 [PATCH 0/2] gpio: shared: fix some corner cases Bartosz Golaszewski
  2025-11-26 16:49 ` [PATCH 1/2] gpio: shared: ignore special __symbols__ node when traversing device tree Bartosz Golaszewski
  2025-11-26 16:49 ` [PATCH 2/2] gpio: shared: ignore GPIO hogs when traversing the " Bartosz Golaszewski
@ 2025-11-28  8:30 ` Bartosz Golaszewski
  2 siblings, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2025-11-28  8:30 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Bartosz Golaszewski
  Cc: Bartosz Golaszewski, linux-gpio, linux-kernel, Jon Hunter,
	Cosmin Tanislav

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


On Wed, 26 Nov 2025 17:49:04 +0100, Bartosz Golaszewski wrote:
> Here are fixes for two more bugs reported in linux-next.
> 
> 

Applied, thanks!

[1/2] gpio: shared: ignore special __symbols__ node when traversing device tree
      https://git.kernel.org/brgl/linux/c/cfab6dc0700c3b9120dab726fc184c3b4500cc5b
[2/2] gpio: shared: ignore GPIO hogs when traversing the device tree
      https://git.kernel.org/brgl/linux/c/114e594e6cb791ce7c839ccfbe153ecfa3e7abce

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

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

end of thread, other threads:[~2025-11-28  8:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-26 16:49 [PATCH 0/2] gpio: shared: fix some corner cases Bartosz Golaszewski
2025-11-26 16:49 ` [PATCH 1/2] gpio: shared: ignore special __symbols__ node when traversing device tree Bartosz Golaszewski
2025-11-26 20:56   ` Jon Hunter
2025-11-26 16:49 ` [PATCH 2/2] gpio: shared: ignore GPIO hogs when traversing the " Bartosz Golaszewski
2025-11-28  8:30 ` [PATCH 0/2] gpio: shared: fix some corner cases Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).