usb: musb-new: Fix improper musb host pointer

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>
This commit is contained in:
Jagan Teki 2018-07-20 12:43:56 +05:30
parent b71d9e8b38
commit 8b8d59f323
5 changed files with 19 additions and 15 deletions

View File

@ -74,8 +74,8 @@ static void cm_t3517_musb_init(void)
CONF2_REFFREQ_13MHZ | CONF2_SESENDEN | CONF2_REFFREQ_13MHZ | CONF2_SESENDEN |
CONF2_VBDTCTEN | CONF2_DATPOL); CONF2_VBDTCTEN | CONF2_DATPOL);
if (musb_register(&cm_t3517_musb_pdata, &cm_t3517_musb_board_data, if (!musb_register(&cm_t3517_musb_pdata, &cm_t3517_musb_board_data,
(void *)AM35XX_IPSS_USBOTGSS_BASE)) (void *)AM35XX_IPSS_USBOTGSS_BASE))
printf("Failed initializing AM35x MUSB!\n"); printf("Failed initializing AM35x MUSB!\n");
} }
#else #else

View File

@ -419,8 +419,8 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
} }
#endif /* CONFIG_USB_MUSB_GADGET */ #endif /* CONFIG_USB_MUSB_GADGET */
int musb_register(struct musb_hdrc_platform_data *plat, void *bdata, struct musb *musb_register(struct musb_hdrc_platform_data *plat, void *bdata,
void *ctl_regs) void *ctl_regs)
{ {
struct musb **musbp; struct musb **musbp;
@ -436,14 +436,14 @@ int musb_register(struct musb_hdrc_platform_data *plat, void *bdata,
break; break;
#endif #endif
default: default:
return -EINVAL; return ERR_PTR(-EINVAL);
} }
*musbp = musb_init_controller(plat, (struct device *)bdata, ctl_regs); *musbp = musb_init_controller(plat, (struct device *)bdata, ctl_regs);
if (!*musbp) { if (IS_ERR(*musbp)) {
printf("Failed to init the controller\n"); printf("Failed to init the controller\n");
return -EIO; return ERR_CAST(*musbp);
} }
return 0; return *musbp;
} }

View File

@ -251,9 +251,11 @@ static int musb_usb_probe(struct udevice *dev)
ret = musb_lowlevel_init(mdata); ret = musb_lowlevel_init(mdata);
#else #else
pic32_musb_plat.mode = MUSB_PERIPHERAL; 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 #endif
if (ret == 0) if ((ret == 0) && mdata->host)
printf("PIC32 MUSB OTG\n"); printf("PIC32 MUSB OTG\n");
return ret; return ret;

View File

@ -444,9 +444,11 @@ static int musb_usb_probe(struct udevice *dev)
printf("Allwinner mUSB OTG (Host)\n"); printf("Allwinner mUSB OTG (Host)\n");
#else #else
pdata.mode = MUSB_PERIPHERAL; pdata.mode = MUSB_PERIPHERAL;
ret = musb_register(&pdata, &glue->dev, base); host->host = musb_register(&pdata, &glue->dev, base);
if (!ret) if (!host->host)
printf("Allwinner mUSB OTG (Peripheral)\n"); return -EIO;
printf("Allwinner mUSB OTG (Peripheral)\n");
#endif #endif
return ret; return ret;

View File

@ -150,7 +150,7 @@ extern int tusb6010_platform_retime(unsigned is_refclk);
/* /*
* U-Boot specfic stuff * U-Boot specfic stuff
*/ */
int musb_register(struct musb_hdrc_platform_data *plat, void *bdata, struct musb *musb_register(struct musb_hdrc_platform_data *plat, void *bdata,
void *ctl_regs); void *ctl_regs);
#endif /* __LINUX_USB_MUSB_H */ #endif /* __LINUX_USB_MUSB_H */