[PATCH 03/10] usb: cdns3: Migrate to use ofnode API for bind function

Kever Yang kever.yang at rock-chips.com
Wed Feb 19 02:54:40 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>
---

 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 8c8e02169e..d6ccd3e73c 100644
--- a/drivers/usb/cdns3/core.c
+++ b/drivers/usb/cdns3/core.c
@@ -382,23 +382,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) || \
@@ -420,8 +418,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