devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] More precise error reporting for of_get_named_gpio
@ 2012-06-29  4:57 Alexandre Courbot
  2012-06-29  4:57 ` [PATCH 1/2] of: return -ENOENT when no property Alexandre Courbot
  2012-06-29  4:57 ` [PATCH 2/2] gpio: propagate of_parse_phandle_with_args errors Alexandre Courbot
  0 siblings, 2 replies; 6+ messages in thread
From: Alexandre Courbot @ 2012-06-29  4:57 UTC (permalink / raw)
  To: Rob Herring, Grant Likely, Linus Walleij
  Cc: linux-kernel, devicetree-discuss, Alexandre Courbot

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

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

* [PATCH 1/2] of: return -ENOENT when no property
  2012-06-29  4:57 [PATCH 0/2] More precise error reporting for of_get_named_gpio Alexandre Courbot
@ 2012-06-29  4:57 ` Alexandre Courbot
  2012-07-05 13:26   ` Linus Walleij
  2012-06-29  4:57 ` [PATCH 2/2] gpio: propagate of_parse_phandle_with_args errors Alexandre Courbot
  1 sibling, 1 reply; 6+ messages in thread
From: Alexandre Courbot @ 2012-06-29  4:57 UTC (permalink / raw)
  To: Rob Herring, Grant Likely, Linus Walleij
  Cc: linux-kernel, devicetree-discuss, 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.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 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

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

* [PATCH 2/2] gpio: propagate of_parse_phandle_with_args errors
  2012-06-29  4:57 [PATCH 0/2] More precise error reporting for of_get_named_gpio Alexandre Courbot
  2012-06-29  4:57 ` [PATCH 1/2] of: return -ENOENT when no property Alexandre Courbot
@ 2012-06-29  4:57 ` Alexandre Courbot
  2012-07-05 13:27   ` Linus Walleij
  1 sibling, 1 reply; 6+ messages in thread
From: Alexandre Courbot @ 2012-06-29  4:57 UTC (permalink / raw)
  To: Rob Herring, Grant Likely, Linus Walleij
  Cc: linux-kernel, devicetree-discuss, Alexandre Courbot

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 <acourbot@nvidia.com>
---
 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

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

* Re: [PATCH 1/2] of: return -ENOENT when no property
  2012-06-29  4:57 ` [PATCH 1/2] of: return -ENOENT when no property Alexandre Courbot
@ 2012-07-05 13:26   ` Linus Walleij
  2012-07-05 14:20     ` Rob Herring
  0 siblings, 1 reply; 6+ messages in thread
From: Linus Walleij @ 2012-07-05 13:26 UTC (permalink / raw)
  To: Alexandre Courbot, Rob Herring
  Cc: Grant Likely, Linus Walleij, linux-kernel, devicetree-discuss

On Fri, Jun 29, 2012 at 6:57 AM, Alexandre Courbot <acourbot@nvidia.com> wrote:

> 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 <acourbot@nvidia.com>

Rob can you take this into the DT git?

Yours,
Linus Walleij

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

* Re: [PATCH 2/2] gpio: propagate of_parse_phandle_with_args errors
  2012-06-29  4:57 ` [PATCH 2/2] gpio: propagate of_parse_phandle_with_args errors Alexandre Courbot
@ 2012-07-05 13:27   ` Linus Walleij
  0 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2012-07-05 13:27 UTC (permalink / raw)
  To: Alexandre Courbot
  Cc: Rob Herring, Grant Likely, Linus Walleij, linux-kernel,
	devicetree-discuss

On Fri, Jun 29, 2012 at 6:57 AM, Alexandre Courbot <acourbot@nvidia.com> wrote:

> 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 <acourbot@nvidia.com>

Applied.

Thanks,
Linus Walleij

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

* Re: [PATCH 1/2] of: return -ENOENT when no property
  2012-07-05 13:26   ` Linus Walleij
@ 2012-07-05 14:20     ` Rob Herring
  0 siblings, 0 replies; 6+ messages in thread
From: Rob Herring @ 2012-07-05 14:20 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Alexandre Courbot, Grant Likely, Linus Walleij, linux-kernel,
	devicetree-discuss

On 07/05/2012 08:26 AM, Linus Walleij wrote:
> On Fri, Jun 29, 2012 at 6:57 AM, Alexandre Courbot <acourbot@nvidia.com> wrote:
> 
>> 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 <acourbot@nvidia.com>
> 
> Rob can you take this into the DT git?

Yes.

Rob

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

end of thread, other threads:[~2012-07-05 14:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-29  4:57 [PATCH 0/2] More precise error reporting for of_get_named_gpio Alexandre Courbot
2012-06-29  4:57 ` [PATCH 1/2] of: return -ENOENT when no property Alexandre Courbot
2012-07-05 13:26   ` Linus Walleij
2012-07-05 14:20     ` Rob Herring
2012-06-29  4:57 ` [PATCH 2/2] gpio: propagate of_parse_phandle_with_args errors Alexandre Courbot
2012-07-05 13:27   ` Linus Walleij

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).