]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
musb-new: omap2430: no host data access in gadget mode
authorAndreas Kemnade <andreas@kemnade.info>
Mon, 9 Jan 2023 07:13:30 +0000 (08:13 +0100)
committerTom Rini <trini@konsulko.com>
Wed, 18 Jan 2023 17:46:13 +0000 (12:46 -0500)
Avoid accessing structures (usb_bus_priv) only present when musb is
in host mode.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
drivers/usb/musb-new/omap2430.c

index 7d15b94a6c437ff56a1db0370b4548806dbb2854..0d1fb03727d51164e90cb0606b1db8e564461013 100644 (file)
@@ -214,37 +214,35 @@ static int omap2430_musb_of_to_plat(struct udevice *dev)
 
 static int omap2430_musb_probe(struct udevice *dev)
 {
-#ifdef CONFIG_USB_MUSB_HOST
-       struct musb_host_data *host = dev_get_priv(dev);
-#else
-       struct musb *musbp;
-#endif
        struct omap2430_musb_plat *plat = dev_get_plat(dev);
-       struct usb_bus_priv *priv = dev_get_uclass_priv(dev);
        struct omap_musb_board_data *otg_board_data;
        int ret = 0;
        void *base = dev_read_addr_ptr(dev);
-
-       priv->desc_before_addr = true;
+       struct musb *musbp;
 
        otg_board_data = &plat->otg_board_data;
 
-#ifdef CONFIG_USB_MUSB_HOST
-       host->host = musb_init_controller(&plat->plat,
-                                         (struct device *)otg_board_data,
-                                         plat->base);
-       if (!host->host) {
-               return -EIO;
+       if (CONFIG_IS_ENABLED(USB_MUSB_HOST)) {
+               struct musb_host_data *host = dev_get_priv(dev);
+               struct usb_bus_priv *priv = dev_get_uclass_priv(dev);
+
+               priv->desc_before_addr = true;
+
+               host->host = musb_init_controller(&plat->plat,
+                                                 (struct device *)otg_board_data,
+                                                 plat->base);
+               if (!host->host)
+                       return -EIO;
+
+               return musb_lowlevel_init(host);
        }
 
-       ret = musb_lowlevel_init(host);
-#else
        musbp = musb_register(&plat->plat, (struct device *)otg_board_data,
                              plat->base);
        if (IS_ERR_OR_NULL(musbp))
                return -EINVAL;
-#endif
-       return ret;
+
+       return 0;
 }
 
 static int omap2430_musb_remove(struct udevice *dev)