diff mbox series

[U-Boot] gpio: dwapb_gpio: fix broken dev->node

Message ID 20190523184355.21045-1-simon.k.r.goldschmidt@gmail.com
State Accepted, archived
Delegated to: Marek Vasut
Headers show
Series [U-Boot] gpio: dwapb_gpio: fix broken dev->node | expand

Commit Message

Simon Goldschmidt May 23, 2019, 6:43 p.m. UTC
commit 1b898ff ("gpio: dwapb_gpio: convert to livetree") introduced
a bug in that dev->node of the gpio chip was accidentally set to the
of_node of its bank subnode.

What it meant to do was assign subdev->node, not dev->node.

While this doesn't affect too many use cases, iterating over the gpio
chip's properties doesn't work any more after that, so fix this
properly by calling 'device_bind_ofnode()' to bind the sub-device
instead of calling 'device_bind()' and then assigning subdev->node
manually.

Fixes: commit 1b898ff ("gpio: dwapb_gpio: convert to livetree")
Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
---

This applies on top of 0aec330931c5 in u-boot-socfpga/master which it
should be squashed into.
---
 drivers/gpio/dwapb_gpio.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Marek Vasut May 23, 2019, 10 p.m. UTC | #1
On 5/23/19 8:43 PM, Simon Goldschmidt wrote:
> commit 1b898ff ("gpio: dwapb_gpio: convert to livetree") introduced
> a bug in that dev->node of the gpio chip was accidentally set to the
> of_node of its bank subnode.
> 
> What it meant to do was assign subdev->node, not dev->node.
> 
> While this doesn't affect too many use cases, iterating over the gpio
> chip's properties doesn't work any more after that, so fix this
> properly by calling 'device_bind_ofnode()' to bind the sub-device
> instead of calling 'device_bind()' and then assigning subdev->node
> manually.
> 
> Fixes: commit 1b898ff ("gpio: dwapb_gpio: convert to livetree")
> Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
> ---
> 
> This applies on top of 0aec330931c5 in u-boot-socfpga/master which it
> should be squashed into.
> ---
>  drivers/gpio/dwapb_gpio.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
> index d6887a396a..2eb1547b4f 100644
> --- a/drivers/gpio/dwapb_gpio.c
> +++ b/drivers/gpio/dwapb_gpio.c
> @@ -185,12 +185,11 @@ static int gpio_dwapb_bind(struct udevice *dev)
>  			plat->name = ofnode_get_name(node);
>  		}
>  
> -		ret = device_bind(dev, dev->driver, plat->name,
> -				  plat, -1, &subdev);
> +		ret = device_bind_ofnode(dev, dev->driver, plat->name,
> +					 plat, node, &subdev);
>  		if (ret)
>  			return ret;
>  
> -		subdev->node = node;
>  		bank++;
>  	}
>  
> 
Applied, thanks
diff mbox series

Patch

diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
index d6887a396a..2eb1547b4f 100644
--- a/drivers/gpio/dwapb_gpio.c
+++ b/drivers/gpio/dwapb_gpio.c
@@ -185,12 +185,11 @@  static int gpio_dwapb_bind(struct udevice *dev)
 			plat->name = ofnode_get_name(node);
 		}
 
-		ret = device_bind(dev, dev->driver, plat->name,
-				  plat, -1, &subdev);
+		ret = device_bind_ofnode(dev, dev->driver, plat->name,
+					 plat, node, &subdev);
 		if (ret)
 			return ret;
 
-		subdev->node = node;
 		bank++;
 	}