[PATCH v2 3/6] usb: musb-new: Update phandle handling
Peng Fan (OSS)
peng.fan at oss.nxp.com
Tue Jun 2 13:21:42 CEST 2026
From: Peng Fan <peng.fan at nxp.com>
Replace ofnode_get_by_phandle(dev_read_u32_default()) with
ofnode_parse_phandle() for resolving the "phys" and "ti,ctrl_mod"
phandle references in ti_musb_of_to_plat().
ofnode_parse_phandle() handles the phandle lookup in a single call and
works with both live and flat device trees. Add ofnode_valid() checks
after each resolution so the driver returns -EINVAL early instead of
operating on invalid nodes.
Signed-off-by: Peng Fan <peng.fan at nxp.com>
---
drivers/usb/musb-new/ti-musb.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
index 1c80b78b031..73be026af85 100644
--- a/drivers/usb/musb-new/ti-musb.c
+++ b/drivers/usb/musb-new/ti-musb.c
@@ -85,8 +85,14 @@ static int ti_musb_of_to_plat(struct udevice *dev)
if (!plat->base)
return -EINVAL;
- phys_node = ofnode_get_by_phandle(dev_read_u32_default(dev, "phys", 0));
- ctrl_mod_node = ofnode_get_by_phandle(ofnode_read_u32_default(phys_node, "ti,ctrl_mod", 0));
+ phys_node = ofnode_parse_phandle(node, "phys", 0);
+ if (!ofnode_valid(phys_node))
+ return -EINVAL;
+
+ ctrl_mod_node = ofnode_parse_phandle(phys_node, "ti,ctrl_mod", 0);
+ if (!ofnode_valid(ctrl_mod_node))
+ return -EINVAL;
+
plat->ctrl_mod_base = (void *)ofnode_get_addr(ctrl_mod_node);
usb_index = ti_musb_get_usb_index(node);
switch (usb_index) {
--
2.51.0
More information about the U-Boot
mailing list