mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] usb: musb: Use proper timeout loop
@ 2015-07-03  5:10 Sascha Hauer
  0 siblings, 0 replies; only message in thread
From: Sascha Hauer @ 2015-07-03  5:10 UTC (permalink / raw)
  To: Barebox List

Poll for a well defined time in musb_init. The current counting loop
takes too short for some devices. Tested on OMAP3 with a rather slowish
memory stick.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/usb/musb/musb_core.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index ccb7029..84a05c4 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -119,8 +119,6 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("platform:" MUSB_DRIVER_NAME);
 
-#define MUSB_HOST_TIMEOUT 0x5fffff
-
 /*-------------------------------------------------------------------------*/
 
 #ifndef CONFIG_BLACKFIN
@@ -1025,17 +1023,18 @@ int musb_init(struct usb_host *host)
 {
 	struct musb *musb = to_musb(host);
 	void *mbase;
-	int timeout = MUSB_HOST_TIMEOUT;
+	u64 start;
 	u8 power;
 
 	musb_start(musb);
 	mbase = musb->mregs;
-	do {
+	start = get_time_ns();
+	while (1) {
 		if (musb_readb(mbase, MUSB_DEVCTL) & MUSB_DEVCTL_HM)
 			break;
-	} while (--timeout);
-	if (!timeout)
-		return -ENODEV;
+		if (is_timeout(start, 4 * SECOND))
+			return -ENODEV;
+	}
 
 	power = musb_readb(mbase, MUSB_POWER);
 	musb_writeb(mbase, MUSB_POWER, MUSB_POWER_RESET | power);
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-07-03  5:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-03  5:10 [PATCH] usb: musb: Use proper timeout loop Sascha Hauer

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