From patchwork Thu Feb 20 02:32:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kever Yang X-Patchwork-Id: 236613 List-Id: U-Boot discussion From: kever.yang at rock-chips.com (Kever Yang) Date: Thu, 20 Feb 2020 10:32:19 +0800 Subject: [PATCH v2 4/9] usb: dwc3-generic: 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-5-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/dwc3/dwc3-generic.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index 3e116b2c5c..820cc7075c 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -284,20 +284,18 @@ struct dwc3_glue_ops ti_ops = { static int dwc3_glue_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)) { - const char *name = fdt_get_name(fdt, node, NULL); + ofnode_for_each_subnode(node, parent->node) { + const char *name = ofnode_get_name(node); enum usb_dr_mode dr_mode; struct udevice *dev; const char *driver = NULL; debug("%s: subnode name: %s\n", __func__, name); - 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: @@ -322,7 +320,7 @@ static int dwc3_glue_bind(struct udevice *parent) continue; ret = device_bind_driver_to_node(parent, driver, name, - offset_to_ofnode(node), &dev); + node, &dev); if (ret) { debug("%s: not able to bind usb device mode\n", __func__);