From patchwork Thu Feb 20 02:32:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kever Yang X-Patchwork-Id: 236612 List-Id: U-Boot discussion From: kever.yang at rock-chips.com (Kever Yang) Date: Thu, 20 Feb 2020 10:32:18 +0800 Subject: [PATCH v2 3/9] usb: cdns3: Migrate to use ofnode API for bind function In-Reply-To: <20200220023224.32146-1-kever.yang@rock-chips.com> References: <20200220023224.32146-1-kever.yang@rock-chips.com> Message-ID: <20200220023224.32146-4-kever.yang@rock-chips.com> Use ofnode_ instead of fdt_ APIs so that the driver can support live DT. Signed-off-by: Kever Yang --- 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__);