gpio: shared: fix some corner cases
Subsystems (2)
cover gpio: shared: fix some corner cases
Here are fixes for two more bugs reported in linux-next.
---
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,
Signature · 1 line
Bartosz Golaszewski <[email protected]>
PATCH 1/2 gpio: shared: ignore special __symbols__ node when traversing device tree
From: Bartosz Golaszewski <[email protected]>
The __symbols__ node is a special, internal node and its properties must not be considered when scanning the device-tree for shared GPIOs.
--- drivers/gpio/gpiolib-shared.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/gpio/gpiolib-shared.c +16 -0
@@ -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"
Signature · 1 line
2.51.0
Re: [PATCH 1/2] gpio: shared: ignore special __symbols__ node when traversing device tree
Quoted 39 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
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 <[email protected]>Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/gpio/gpiolib-shared.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/gpio/gpiolib-shared.c +13
-0@@ -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;
drivers/gpio/gpiolib-shared.c static int gpio_shared_of_traverse(struct device_node *curr) · line 105
Quoted 9 lines
drivers/gpio/gpiolib-shared.c +3
-0@@ -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!
Thanks
Jon
Signature · 1 line
nvpublic
PATCH 2/2 gpio: shared: ignore GPIO hogs when traversing the device tree
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
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.
--- drivers/gpio/gpiolib-shared.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpio/gpiolib-shared.c +7 -0
@@ -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; }
Signature · 1 line
2.51.0
Bartosz Golaszewski
AppliedFrom: Bartosz Golaszewski <[email protected]>
Quoted 3 lines · Bartosz Golaszewski
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,
Signature · 1 line
Bartosz Golaszewski <[email protected]>