[PATCH 2/6] usb: musb-new: Use ofnode and dev APIs

Simon Glass sjg at chromium.org
Mon Jun 1 16:58:06 CEST 2026


Hi Peng,

On 2026-05-26T09:09:56, Peng Fan (OSS) <peng.fan at oss.nxp.com> wrote:
> usb: musb-new: Use ofnode and dev APIs
>
> Convert the TI MUSB driver to use dev and ofnode-based device tree APIs
> instead of legacy FDT interfaces.
>
> Replace dev_of_offset(), fdt_get_alias(), fdtdec_get_int(), and related
> helpers with their ofnode equivalents such as
> dev_ofnode(), ofnode_get_aliases_node(), ofnode_equal(), and
> dev_read_s32_default().
>
> The USB index lookup is updated to compare ofnode handles instead of device
> tree path strings. Also remove direct dependency on gd->fdt_blob.
>
> No functional changes.
>
> Signed-off-by: Peng Fan <peng.fan at nxp.com>
>
> drivers/usb/musb-new/ti-musb.c | 31 ++++++++++++++-----------------
>  1 file changed, 14 insertions(+), 17 deletions(-)

> diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
> @@ -51,29 +51,25 @@ static void ti_musb_set_phy_power(struct udevice *dev, u8 on)
> -static int ti_musb_get_usb_index(int node)
> +static int ti_musb_get_usb_index(ofnode node)
>  {
> -     const void *fdt = gd->fdt_blob;
>       int i = 0;
> -     char path[64];
> -     const char *alias_path;
> +     ofnode alias_path;
>       char alias[16];

Please rename alias_path to alias_node since it is no longer a path string.

> diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
> @@ -51,29 +51,25 @@ static void ti_musb_set_phy_power(struct udevice *dev, u8 on)
>               i++;
> -     } while (alias_path);
> +     } while (ofnode_valid(alias_path));

This trailing check has always been dead - alias_path is guaranteed
valid here (we returned -ENOENT above otherwise) and the loop only
exits via the inner returns. Since you are touching this function,
please convert it to while (1) so the control flow is obvious.

> diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
> @@ -81,15 +77,16 @@ static int ti_musb_get_usb_index(int node)
> -     plat->base = devfdt_get_addr_index_ptr(dev, 1);
> +     plat->base = dev_read_addr_index_ptr(dev, 1);
> +     if (!plat->base)
> +             return -EINVAL;

The added NULL check is a real behaviour change. Previously a missing
reg[1] would silently leave plat->base as NULL and the driver would
carry on. Please mention this in the commit message.

> diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
> @@ -51,29 +51,25 @@ static void ti_musb_set_phy_power(struct udevice *dev, u8 on)
> -     const void *fdt = gd->fdt_blob;
>       int i = 0;

The last reference to gd in the file is gone (yay!), so
DECLARE_GLOBAL_DATA_PTR on line 23 and the #include
<asm/global_data.h> are now unused. Please drop them.

Regards,
Simon


More information about the U-Boot mailing list