> From: "Tvrtko A. Ursulin" <[EMAIL PROTECTED]>
> Date: Sat, 7 Dec 2002 17:27:52 +0100
> So I wonder, what this patch does? Should it be submitted to the main tree?
The patch you quoted defeats the whole purpose
of debouncing, shortcutting the loop. The loop is broken as
it is in 2.4.20, so killing it helps. It does not make the
patch any less broken, this is why it is not going to be
submitted to Marcelo.
Please try the attached patch, and also send me the output
of your dmesg, taken after the test. There is a special printout
there to diagnose the problem.
-- Pete
--- linux-2.4.20/drivers/usb/hub.c 2002-12-06 18:07:21.000000000 -0800
+++ linux-2.4.20-usb/drivers/usb/hub.c 2002-12-07 11:41:33.000000000 -0800
@@ -639,35 +639,48 @@
* Not covered by the spec - but easy to deal with.
*
* This implementation uses 400ms minimum debounce timeout and checks
- * every 100ms for transient disconnects to restart the delay.
+ * every 25ms for transient disconnects to restart the delay.
*/
#define HUB_DEBOUNCE_TIMEOUT 400
-#define HUB_DEBOUNCE_STEP 100
+#define HUB_DEBOUNCE_STEP 25
+#define HUB_DEBOUNCE_STABLE 4
/* return: -1 on error, 0 on success, 1 on disconnect. */
static int usb_hub_port_debounce(struct usb_device *hub, int port)
{
int ret;
- unsigned delay_time;
+ int delay_time, stable_count;
u16 portchange, portstatus;
+ unsigned connection;
- for (delay_time = 0; delay_time < HUB_DEBOUNCE_TIMEOUT; /* empty */ ) {
-
- /* wait debounce step increment */
+ connection = 0;
+ stable_count = 0;
+ for (delay_time = 0; delay_time < HUB_DEBOUNCE_TIMEOUT; delay_time +=
+HUB_DEBOUNCE_STEP) {
wait_ms(HUB_DEBOUNCE_STEP);
ret = usb_hub_port_status(hub, port, &portstatus, &portchange);
if (ret < 0)
return -1;
+ if ((portstatus & USB_PORT_STAT_CONNECTION) == connection) {
+ if (connection) {
+ if (++stable_count == HUB_DEBOUNCE_STABLE)
+ break;
+ }
+ } else {
+ stable_count = 0;
+ }
+ connection = portstatus & USB_PORT_STAT_CONNECTION;
+
if ((portchange & USB_PORT_STAT_C_CONNECTION)) {
usb_clear_port_feature(hub, port+1,
USB_PORT_FEAT_C_CONNECTION);
- delay_time = 0;
}
- else
- delay_time += HUB_DEBOUNCE_STEP;
}
+
+/* P3 */ printk("Debounce: hub %d port %d: delay %dms stable %d status 0x%x\n",
+ hub->devnum, port, delay_time, stable_count, portstatus);
+
return ((portstatus&USB_PORT_STAT_CONNECTION)) ? 0 : 1;
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel