All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch] USB UHCI portstatus correction
@ 2010-06-20  9:23 Aleš Nesrsta
  2010-06-25 19:45 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 1 reply; 8+ messages in thread
From: Aleš Nesrsta @ 2010-06-20  9:23 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 263 bytes --]

Hi,

I found some mistake in uhci.c in grub_uhci_portstatus when enable=0.
There is proposal of correction.

Without correction portstatus reported false timeout when enable=0
because it is waiting for reset to be done but none is performed...

Best regards
Ales

[-- Attachment #2: usb_patch_uhci_100620_0 --]
[-- Type: text/x-patch, Size: 1375 bytes --]

diff -urB ./usb/bus/usb/uhci.c ./usb_patched/bus/usb/uhci.c
--- ./usb/bus/usb/uhci.c	2010-06-20 10:20:58.000000000 +0200
+++ ./usb_patched/bus/usb/uhci.c	2010-06-20 10:59:03.000000000 +0200
@@ -612,8 +612,23 @@
   status = grub_uhci_readreg16 (u, reg);
   grub_dprintf ("uhci", "detect=0x%02x\n", status);
 
+  if (!enable) /* We don't need reset port */
+    {
+      /* Disable the port.  */
+      grub_uhci_writereg16 (u, reg, 0 << 2);
+      grub_dprintf ("uhci", "waiting for the port to be disabled\n");
+      endtime = grub_get_time_ms () + 1000;
+      while ((grub_uhci_readreg16 (u, reg) & (1 << 2)))
+        if (grub_get_time_ms () > endtime)
+          return grub_error (GRUB_ERR_IO, "UHCI Timed out");
+
+      status = grub_uhci_readreg16 (u, reg);
+      grub_dprintf ("uhci", ">3detect=0x%02x\n", status);
+      return GRUB_ERR_NONE;
+    }
+    
   /* Reset the port.  */
-  grub_uhci_writereg16 (u, reg, enable << 9);
+  grub_uhci_writereg16 (u, reg, 1 << 9);
 
   /* Wait for the reset to complete.  XXX: How long exactly?  */
   grub_millisleep (50); /* For root hub should be nominaly 50ms */
@@ -623,7 +638,7 @@
   grub_millisleep (10);
 
   /* Enable the port.  */
-  grub_uhci_writereg16 (u, reg, enable << 2);
+  grub_uhci_writereg16 (u, reg, 1 << 2);
   grub_millisleep (10);
 
   grub_dprintf ("uhci", "waiting for the port to be enabled\n");

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

end of thread, other threads:[~2010-07-13 10:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-20  9:23 [Patch] USB UHCI portstatus correction Aleš Nesrsta
2010-06-25 19:45 ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-06-25 22:03   ` Aleš Nesrsta
2010-06-28 16:48     ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-07-05 17:12       ` Aleš Nesrsta
2010-07-05 23:57         ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-07-06 17:19           ` Aleš Nesrsta
2010-07-13 10:00             ` Vladimir 'φ-coder/phcoder' Serbinenko

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.