The probe function of the musb host driver can be called multiple
times. The code assumes that it can save the pointer to the allocated
musb struct in the driver model priv_auto_alloc data, but this data
gets free-ed on a probe failure or on removal, so we must save the
pointer elsewhere.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
/* musb_core does not call enable / disable in a balanced manner <sigh> */
static bool enabled = false;
+static struct musb *sunxi_musb;
static int sunxi_musb_enable(struct musb *musb)
{
priv->desc_before_addr = true;
- if (!host->host) {
- host->host = musb_init_controller(&musb_plat, NULL,
+ if (!sunxi_musb) {
+ sunxi_musb = musb_init_controller(&musb_plat, NULL,
(void *)SUNXI_USB0_BASE);
- if (!host->host)
- return -EIO;
}
+ host->host = sunxi_musb;
+ if (!host->host)
+ return -EIO;
+
ret = musb_lowlevel_init(host);
if (ret == 0)
printf("MUSB OTG\n");