All of lore.kernel.org
 help / color / mirror / Atom feed
From: Orjan Friberg <of@flatfrog.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] MUSB timeout broken
Date: Mon, 4 Jul 2011 16:37:34 +0200	[thread overview]
Message-ID: <4E11D02E.7030803@flatfrog.com> (raw)

The following construct (musb_hcd.c, usb_lowlevel_init)

    timeout = musb_cfg.timeout;
         while (timeout--)
                 if (readb(&musbr->devctl) & MUSB_DEVCTL_HM)
                         break;

will leave timeout == -1 when the timeout is reached, hence the timeout 
detecting code that follows will not trigger:

         /* if musb core is not in host mode, then return */
         if (!timeout)
                 return -1;


Without the patch below, doing a 'usb reset' without a device connected 
makes it impossible to discover connected devices later.  I have not 
investigated why this happens since the timeout logic was broken (and 
correcting that fixed the issue at hand).

Changed to pre-decrement since I assume the timeout value is not *that* 
exact.

Thanks,
Orjan

diff --git a/drivers/usb/musb/musb_hcd.c b/drivers/usb/musb/musb_hcd.c
index 974bb31..adcf7f7 100644
--- a/drivers/usb/musb/musb_hcd.c
+++ b/drivers/usb/musb/musb_hcd.c
@@ -1114,7 +1114,7 @@ int usb_lowlevel_init(void)
          * should be a usb device connected.
          */
         timeout = musb_cfg.timeout;
-       while (timeout--)
+       while (--timeout)
                 if (readb(&musbr->devctl) & MUSB_DEVCTL_HM)
                         break;




-- 
Orjan Friberg
FlatFrog Laboratories AB

             reply	other threads:[~2011-07-04 14:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-04 14:37 Orjan Friberg [this message]
2011-07-04 15:07 ` [U-Boot] [PATCH] MUSB timeout broken Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E11D02E.7030803@flatfrog.com \
    --to=of@flatfrog.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.