More precise error reporting for of_get_named_gpio
Subsystems (2)
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
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
@@ -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
PATCH 2/2 gpio: propagate of_parse_phandle_with_args errors
In reply to Alexandre CourbotMake 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
@@ -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
Re: [PATCH 1/2] of: return -ENOENT when no property
In reply to Alexandre CourbotQuoted 5 lines · Alexandre Courbot
Make
of_parse_phandle_with_argsreturn-ENOENTinstead of-EINVALwhen no matching property is found, which allows to discriminate between absence of property and parsing error.Signed-off-by Alexandre Courbot <[email protected]>
Rob can you take this into the DT git?
Yours,
Linus Walleij
Linus Walleij
AppliedRe: [PATCH 2/2] gpio: propagate of_parse_phandle_with_args errors
In reply to Alexandre CourbotQuoted 4 lines · Alexandre Courbot
Make
of_get_named_gpio_flagspropagate any error it receives fromof_parse_phandle_with_argsinstead of inconditionally returning-EINVAL.Signed-off-by Alexandre Courbot <[email protected]>
Applied.
Thanks,
Linus Walleij
Re: [PATCH 1/2] of: return -ENOENT when no property
In reply to Linus WalleijQuoted 9 lines · Linus Walleij
Quoted 5 lines · Alexandre Courbot
Make
of_parse_phandle_with_argsreturn-ENOENTinstead of-EINVALwhen no matching property is found, which allows to discriminate between absence of property and parsing error.Signed-off-by Alexandre Courbot <[email protected]>Rob can you take this into the DT git?
Yes.
Rob