From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hans de Goede Date: Tue, 5 Apr 2016 11:00:53 +0200 Subject: [U-Boot] [U-Boot, 1/3] musb: sunxi: Do not allocate musb struct multiple times In-Reply-To: <1459622771-12704-1-git-send-email-hdegoede@redhat.com> References: <1459622771-12704-1-git-send-email-hdegoede@redhat.com> Message-ID: <57037EC5.1040303@redhat.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Marek, Simon, Any news on this patch-set ? Patch 1 is sunxi specific, but patch 2 is a generic musb patch and patch 3 (of which I've send a v2 fixing some compiler warnings) is a generic (dm) usb patch, so my plan was for these 3 patches to go upstream through Marek's usb tree, after a review of: https://patchwork.ozlabs.org/patch/605491/ by Simon. Regards, Hans On 02-04-16 20:46, Hans de Goede wrote: > The probe function of the musb host driver can be called multiple > times. The code assumes that it can safe 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 safe the > pointer elsewhere. > > Signed-off-by: Hans de Goede > --- > drivers/usb/musb-new/sunxi.c | 11 +++++++---- > 1 file 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 */ > 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"); >