Skip to contentSkip to conversation

More precise error reporting for of_get_named_gpio

PATCH Applied Alexandre Courbot 3 participants 6 messages Jun 29, 2012 – Jul 5, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover More precise error reporting for of_get_named_gpio

of_get_named_gpio is a very convenient way to get a GPIO from a device tree. However it makes no difference between an invalid property or the absence of it and returns -EINVAL in both cases.

Sometimes a GPIO property can be optional, and so far we need to use a separate call to e.g. of_get_property. These two patches make it possible to differenciate both cases by having of_parse_phandle_with_args return -ENOENT instead of -EINVAL if the requested property does not exist, and of_get_named_gpio_flags propage the return value of of_parse_phandle_with_args instead of invariably returning -EINVAL/

Alexandre Courbot (2):
of: return -ENOENT when no property
gpio: propagate of_parse_phandle_with_args errors

 drivers/gpio/gpiolib-of.c | 2 +-
 drivers/of/base.c         | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
1.7.11.1
#1 lore raw

PATCH 1/2 of: return -ENOENT when no property

Make of_parse_phandle_with_args return -ENOENT instead of -EINVAL when no matching property is found, which allows to discriminate between absence of property and parsing error.

---
 drivers/of/base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/of/base.c +1 -1
index 7acd785..93165b7a 100644
@@ -902,7 +902,7 @@ int of_parse_phandle_with_args(struct device_node *np, const char *list_name,
 	/* Retrieve the phandle list property */
 	list = of_get_property(np, list_name, &size);
 	if (!list)
-		return -EINVAL;
+		return -ENOENT;
 	list_end = list + size / sizeof(*list);
 
 	/* Loop over the phandles until all the requested entry is found */
Signature · 1 line
1.7.11.1
#2 lore raw

Re: [PATCH 1/2] of: return -ENOENT when no property

Quoted 5 lines · Alexandre Courbot

Make of_parse_phandle_with_args return -ENOENT instead of -EINVAL when no matching property is found, which allows to discriminate between absence of property and parsing error.

Rob can you take this into the DT git?

Yours,
Linus Walleij

#3 lore raw

Re: [PATCH 1/2] of: return -ENOENT when no property

Quoted 9 lines · Linus Walleij
Quoted 5 lines · Alexandre Courbot

Make of_parse_phandle_with_args return -ENOENT instead of -EINVAL when no matching property is found, which allows to discriminate between absence of property and parsing error.

Rob can you take this into the DT git?

Yes.

Rob

#4 lore raw

PATCH 2/2 gpio: propagate of_parse_phandle_with_args errors

In reply to Alexandre Courbot

Make of_get_named_gpio_flags propagate any error it receives from of_parse_phandle_with_args instead of inconditionally returning -EINVAL.

---
 drivers/gpio/gpiolib-of.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpiolib-of.c +1 -1
index 8389d4a..a71aeca 100644
@@ -73,7 +73,7 @@ int of_get_named_gpio_flags(struct device_node *np, const char *propname,
 					 &gg_data.gpiospec);
 	if (ret) {
 		pr_debug("%s: can't parse gpios property\n", __func__);
-		return -EINVAL;
+		return ret;
 	}
 
 	gpiochip_find(&gg_data, of_gpiochip_find_and_xlate);
Signature · 1 line
1.7.11.1
#5 lore raw

Re: [PATCH 2/2] gpio: propagate of_parse_phandle_with_args errors

Quoted 4 lines · Alexandre Courbot

Make of_get_named_gpio_flags propagate any error it receives from of_parse_phandle_with_args instead of inconditionally returning -EINVAL.

Applied.

Thanks,
Linus Walleij