[PATCH v2 3/9] usb: cdns3: Migrate to use ofnode API for bind function

Kever Yang kever.yang at rock-chips.com
Thu Feb 20 03:32:18 CET 2020


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/cdns3/core.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
index f947e6983c..75c3d4f200 100644
--- a/drivers/usb/cdns3/core.c
+++ b/drivers/usb/cdns3/core.c
@@ -384,23 +384,21 @@ static const struct udevice_id cdns3_ids[] = {
 
 int cdns3_bind(struct udevice *parent)
 {
-	int from = dev_of_offset(parent);
-	const void *fdt = gd->fdt_blob;
 	enum usb_dr_mode dr_mode;
 	struct udevice *dev;
 	const char *driver;
 	const char *name;
-	int node;
+	ofnode node;
 	int ret;
 
-	node = fdt_node_offset_by_compatible(fdt, from, "cdns,usb3");
-	if (node < 0) {
+	node = ofnode_by_compatible(parent->node, "cdns,usb3");
+	if (!ofnode_valid(node)) {
 		ret = -ENODEV;
 		goto fail;
 	}
 
-	name = fdt_get_name(fdt, node, NULL);
-	dr_mode = usb_get_dr_mode(node);
+	name = ofnode_get_name(node);
+	dr_mode = usb_get_dr_mode(ofnode_to_offset(node));
 
 	switch (dr_mode) {
 #if defined(CONFIG_SPL_USB_HOST_SUPPORT) || \
@@ -422,8 +420,7 @@ int cdns3_bind(struct udevice *parent)
 		goto fail;
 	};
 
-	ret = device_bind_driver_to_node(parent, driver, name,
-					 offset_to_ofnode(node), &dev);
+	ret = device_bind_driver_to_node(parent, driver, name, node, &dev);
 	if (ret) {
 		printf("%s: not able to bind usb device mode\n",
 		       __func__);
-- 
2.17.1



More information about the U-Boot mailing list