2012-06-29 04:56:29

by Alexandre Courbot

[permalink] [raw]
Subject: [PATCH 0/2] 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(-)

--
1.7.11.1


2012-06-29 04:56:43

by Alexandre Courbot

[permalink] [raw]
Subject: [PATCH 2/2] gpio: propagate of_parse_phandle_with_args errors

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

Signed-off-by: Alexandre Courbot <[email protected]>
---
drivers/gpio/gpiolib-of.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 8389d4a..a71aeca 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -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);
--
1.7.11.1

2012-06-29 04:56:41

by Alexandre Courbot

[permalink] [raw]
Subject: [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.

Signed-off-by: Alexandre Courbot <[email protected]>
---
drivers/of/base.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 7acd785..93165b7a 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -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 */
--
1.7.11.1