diff mbox series

[v2,7/9] usb: musb-new: Migrate to use ofnode API

Message ID 20200220023224.32146-8-kever.yang@rock-chips.com
State New
Headers show
Series usb: Covert to support Live DT | expand

Commit Message

Kever Yang Feb. 20, 2020, 2:32 a.m. UTC
Use ofnode_ instead of fdt_ APIs so that the driver can support live DT.

Signed-off-by: Kever Yang <kever.yang at rock-chips.com>
---

Changes in v2: None

 drivers/usb/musb-new/ti-musb.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
index 00759f3e83..69252a7222 100644
--- a/drivers/usb/musb-new/ti-musb.c
+++ b/drivers/usb/musb-new/ti-musb.c
@@ -285,28 +285,26 @@  U_BOOT_DRIVER(ti_musb_peripheral) = {
 #if CONFIG_IS_ENABLED(OF_CONTROL)
 static int ti_musb_wrapper_bind(struct udevice *parent)
 {
-	const void *fdt = gd->fdt_blob;
-	int node;
+	ofnode node;
 	int ret;
 
-	for (node = fdt_first_subnode(fdt, dev_of_offset(parent)); node > 0;
-	     node = fdt_next_subnode(fdt, node)) {
+	ofnode_for_each_subnode(node, parent->node) {
 		struct udevice *dev;
-		const char *name = fdt_get_name(fdt, node, NULL);
+		const char *name = ofnode_get_name(node);
 		enum usb_dr_mode dr_mode;
 		struct driver *drv;
 
 		if (strncmp(name, "usb@", 4))
 			continue;
 
-		dr_mode = usb_get_dr_mode(node);
+		dr_mode = usb_get_dr_mode(ofnode_to_offset(node));
 		switch (dr_mode) {
 		case USB_DR_MODE_PERIPHERAL:
 			/* Bind MUSB device */
 			ret = device_bind_driver_to_node(parent,
 							 "ti-musb-peripheral",
 							 name,
-							 offset_to_ofnode(node),
+							 node,
 							 &dev);
 			if (ret)
 				pr_err("musb - not able to bind usb peripheral node\n");
@@ -316,7 +314,7 @@  static int ti_musb_wrapper_bind(struct udevice *parent)
 			ret = device_bind_driver_to_node(parent,
 							 "ti-musb-host",
 							 name,
-							 offset_to_ofnode(node),
+							 node,
 							 &dev);
 			if (ret)
 				pr_err("musb - not able to bind usb host node\n");