diff mbox series

[1/5] dm: gpio: Fix gpio_get_list_count failing with livetree

Message ID 20210301204603.2730666-2-sean.anderson@seco.com
State Superseded
Delegated to: Tom Rini
Headers show
Series sysinfo: Add gpio sysinfo driver | expand

Commit Message

Sean Anderson March 1, 2021, 8:45 p.m. UTC
of_parse_phandle_with_args (called by dev_read_phandle_with_args) does not
support getting the length of a phandle list by using the index -1.
Instead, use dev_count_phandle_with_args which supports exactly this
use-case.

Fixes: 3669e0e759 ("dm: gpio: Add better functions to request GPIOs")

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

 drivers/gpio/gpio-uclass.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Simon Glass March 5, 2021, 4:08 a.m. UTC | #1
On Mon, 1 Mar 2021 at 15:46, Sean Anderson <sean.anderson@seco.com> wrote:
>
> of_parse_phandle_with_args (called by dev_read_phandle_with_args) does not
> support getting the length of a phandle list by using the index -1.
> Instead, use dev_count_phandle_with_args which supports exactly this
> use-case.
>
> Fixes: 3669e0e759 ("dm: gpio: Add better functions to request GPIOs")
>
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> ---
>
>  drivers/gpio/gpio-uclass.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 8dc647dc9f..8de6fe58a4 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -1214,8 +1214,8 @@  int gpio_get_list_count(struct udevice *dev, const char *list_name)
 {
 	int ret;
 
-	ret = dev_read_phandle_with_args(dev, list_name, "#gpio-cells", 0, -1,
-					 NULL);
+	ret = dev_count_phandle_with_args(dev, list_name, "#gpio-cells",
+					  -ENOENT);
 	if (ret) {
 		debug("%s: Node '%s', property '%s', GPIO count failed: %d\n",
 		      __func__, dev->name, list_name, ret);