summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2016-04-02 20:46:09 +0200
committerMarek Vasut <marex@denx.de>2016-04-10 17:18:43 +0200
commit38b4a3e14397582549b3bb1b301fd9b5c7fc89d2 (patch)
tree425bc83eb20938875ef34a7d4c50ca474f3542f1 /drivers/usb
parentcf1254738537b24308699a4ea0081e52723933b0 (diff)
downloadu-boot-imx-38b4a3e14397582549b3bb1b301fd9b5c7fc89d2.zip
u-boot-imx-38b4a3e14397582549b3bb1b301fd9b5c7fc89d2.tar.gz
u-boot-imx-38b4a3e14397582549b3bb1b301fd9b5c7fc89d2.tar.bz2
musb: sunxi: Do not allocate musb struct multiple times
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>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/musb-new/sunxi.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
index be1d2ec..3081afc 100644
--- a/drivers/usb/musb-new/sunxi.c
+++ b/drivers/usb/musb-new/sunxi.c
@@ -201,6 +201,7 @@ static irqreturn_t sunxi_musb_interrupt(int irq, void *__hci)
/* 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)
{
@@ -320,13 +321,15 @@ int musb_usb_probe(struct udevice *dev)
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");