Skip to contentSkip to conversation

gpio: dwapb_gpio: fix broken dev->node

PATCH New Simon Goldschmidt 2 participants 2 messages May 23, 2019 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: dwapb_gpio: fix broken dev->node

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

---

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(-)
drivers/gpio/dwapb_gpio.c +2 -3
index d6887a396a..2eb1547b4f 100644
@@ -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++;
 	}
 
Signature · 1 line
2.20.1
Applied
#1 lore raw

PATCH 1/1 gpio: dwapb_gpio: fix broken dev->node

Quoted 32 lines · Simon Goldschmidt

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

---

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(-)
drivers/gpio/dwapb_gpio.c +0 -1
index d6887a396a..2eb1547b4f 100644
@@ -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,

drivers/gpio/dwapb_gpio.c static int gpio_dwapb_bind(struct udevice *dev) · line 195

Quoted 10 lines
drivers/gpio/dwapb_gpio.c +2 -2
-				  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

Signature · 2 lines
Best regards,
Marek Vasut