public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/3] musb: sunxi: Do not allocate musb struct multiple times
@ 2016-04-02 18:46 Hans de Goede
  2016-04-02 18:46 ` [U-Boot] [PATCH 2/3] musb: Properly call musb_stop() on probe failure Hans de Goede
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Hans de Goede @ 2016-04-02 18:46 UTC (permalink / raw)
  To: u-boot

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 <hdegoede@redhat.com>
---
 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 <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");
-- 
2.7.2

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-04-06 12:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-02 18:46 [U-Boot] [PATCH 1/3] musb: sunxi: Do not allocate musb struct multiple times Hans de Goede
2016-04-02 18:46 ` [U-Boot] [PATCH 2/3] musb: Properly call musb_stop() on probe failure Hans de Goede
2016-04-02 18:46 ` [U-Boot] [PATCH 3/3] dm: usb: Do not reprobe usb hosts on "usb tree" command Hans de Goede
2016-04-02 18:57 ` [U-Boot] [PATCH 1/3] musb: sunxi: Do not allocate musb struct multiple times Peter Korsgaard
2016-04-02 21:39   ` Hans de Goede
2016-04-05  9:37     ` Ian Campbell
2016-04-05  9:00 ` [U-Boot] [U-Boot, " Hans de Goede
2016-04-05 23:12   ` Marek Vasut
2016-04-06 12:21     ` Hans de Goede
2016-04-06 12:34       ` Marek Vasut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox