]> git.baikalelectronics.ru Git - uboot.git/commitdiff
usb: musb-new: Fix improper musb host pointer
authorJagan Teki <jagan@amarulasolutions.com>
Fri, 20 Jul 2018 07:13:56 +0000 (12:43 +0530)
committerJagan Teki <jagan@amarulasolutions.com>
Thu, 23 Aug 2018 12:01:24 +0000 (17:31 +0530)
When MUSB is operating in peripheral mode, probe registering
musb core using musb_register which intern return int value
for validation. so there is no scope to preserve struct musb
pointer but the same can be used in .remove musb_stop.
So fix this by return musb_register with struct musb pointer.

Cc: Igor Grinberg <grinberg@compulab.co.il>
Cc: Purna Chandra Mandal <purna.mandal@microchip.com>
Tested-by: Chen-Yu Tsai <wens@csie.org> # A33-OlinuXino
Tested-by: Jagan Teki <jagan@amarulasolutions.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
board/compulab/cm_t3517/cm_t3517.c
drivers/usb/musb-new/musb_uboot.c
drivers/usb/musb-new/pic32.c
drivers/usb/musb-new/sunxi.c
include/linux/usb/musb.h

index 09cb27def045ab6eced126413d8ff154b425450e..668bb7631ae3babc11b4d1e928e0774a83341de5 100644 (file)
@@ -74,8 +74,8 @@ static void cm_t3517_musb_init(void)
                        CONF2_REFFREQ_13MHZ | CONF2_SESENDEN |
                        CONF2_VBDTCTEN | CONF2_DATPOL);
 
-       if (musb_register(&cm_t3517_musb_pdata, &cm_t3517_musb_board_data,
-                         (void *)AM35XX_IPSS_USBOTGSS_BASE))
+       if (!musb_register(&cm_t3517_musb_pdata, &cm_t3517_musb_board_data,
+                          (void *)AM35XX_IPSS_USBOTGSS_BASE))
                printf("Failed initializing AM35x MUSB!\n");
 }
 #else
index 2b04fbd046e7dba99dd6e4ae97389be10e9983eb..2bf918eab4635387c5315e19642c433b579e8e14 100644 (file)
@@ -419,8 +419,8 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
 }
 #endif /* CONFIG_USB_MUSB_GADGET */
 
-int musb_register(struct musb_hdrc_platform_data *plat, void *bdata,
-                       void *ctl_regs)
+struct musb *musb_register(struct musb_hdrc_platform_data *plat, void *bdata,
+                          void *ctl_regs)
 {
        struct musb **musbp;
 
@@ -436,14 +436,14 @@ int musb_register(struct musb_hdrc_platform_data *plat, void *bdata,
                break;
 #endif
        default:
-               return -EINVAL;
+               return ERR_PTR(-EINVAL);
        }
 
        *musbp = musb_init_controller(plat, (struct device *)bdata, ctl_regs);
-       if (!*musbp) {
+       if (IS_ERR(*musbp)) {
                printf("Failed to init the controller\n");
-               return -EIO;
+               return ERR_CAST(*musbp);
        }
 
-       return 0;
+       return *musbp;
 }
index f04719d7af57872d90d09c8a3513ceeb7fd591df..3a19900e21c1a9d525c2784c71f2601599922c93 100644 (file)
@@ -251,9 +251,11 @@ static int musb_usb_probe(struct udevice *dev)
        ret = musb_lowlevel_init(mdata);
 #else
        pic32_musb_plat.mode = MUSB_PERIPHERAL;
-       ret = musb_register(&pic32_musb_plat, &pdata->dev, mregs);
+       mdata->host = musb_register(&pic32_musb_plat, &pdata->dev, mregs);
+       if (!mdata->host)
+               return -EIO;
 #endif
-       if (ret == 0)
+       if ((ret == 0) && mdata->host)
                printf("PIC32 MUSB OTG\n");
 
        return ret;
index 08de9c69c71c2462cb6b815d891e51c06395d18d..b846afb094d1e330ad6a0f8563313842785982ee 100644 (file)
@@ -444,9 +444,11 @@ static int musb_usb_probe(struct udevice *dev)
                printf("Allwinner mUSB OTG (Host)\n");
 #else
        pdata.mode = MUSB_PERIPHERAL;
-       ret = musb_register(&pdata, &glue->dev, base);
-       if (!ret)
-               printf("Allwinner mUSB OTG (Peripheral)\n");
+       host->host = musb_register(&pdata, &glue->dev, base);
+       if (!host->host)
+               return -EIO;
+
+       printf("Allwinner mUSB OTG (Peripheral)\n");
 #endif
 
        return ret;
index 9104414cf0dcb27c8b3c635474014f0d2b01fe0e..a31ce67a81f319bc18393892c298ec7b1e54c19d 100644 (file)
@@ -150,7 +150,7 @@ extern int tusb6010_platform_retime(unsigned is_refclk);
 /*
  * U-Boot specfic stuff
  */
-int musb_register(struct musb_hdrc_platform_data *plat, void *bdata,
-                       void *ctl_regs);
+struct musb *musb_register(struct musb_hdrc_platform_data *plat, void *bdata,
+                          void *ctl_regs);
 
 #endif /* __LINUX_USB_MUSB_H */