[PATCH] usb: musb: Use proper timeout loop
Sascha Hauer
s.hauer at pengutronix.de
Thu Jul 2 22:10:23 PDT 2015
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 at 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
More information about the barebox
mailing list