Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=6d8fc4d28deaf828606c19fb743fbe94aeab4caf
Commit:     6d8fc4d28deaf828606c19fb743fbe94aeab4caf
Parent:     88fafff9d73c0a506c0b08e7cd637c89d8b604e1
Author:     Alan Stern <[EMAIL PROTECTED]>
AuthorDate: Wed Oct 18 12:35:24 2006 -0400
Committer:  Greg Kroah-Hartman <[EMAIL PROTECTED]>
CommitDate: Fri Dec 1 14:23:27 2006 -0800

    USB HID: Handle STALL on interrupt endpoint
    
    The USB HID driver doesn't include any code to handle a STALL on the
    interrupt endpoint.  While this may be uncommon, it does happen
    sometimes.  This patch (as805) adds a fix.
    
    Signed-off-by: Alan Stern <[EMAIL PROTECTED]>
    Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
---
 drivers/usb/input/hid-core.c |   39 ++++++++++++++++++++++++++-------------
 drivers/usb/input/hid.h      |    1 +
 2 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 6d08a3b..5de931c 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -968,20 +968,29 @@ static void hid_retry_timeout(unsigned l
                hid_io_error(hid);
 }
 
-/* Workqueue routine to reset the device */
+/* Workqueue routine to reset the device or clear a halt */
 static void hid_reset(void *_hid)
 {
        struct hid_device *hid = (struct hid_device *) _hid;
-       int rc_lock, rc;
-
-       dev_dbg(&hid->intf->dev, "resetting device\n");
-       rc = rc_lock = usb_lock_device_for_reset(hid->dev, hid->intf);
-       if (rc_lock >= 0) {
-               rc = usb_reset_composite_device(hid->dev, hid->intf);
-               if (rc_lock)
-                       usb_unlock_device(hid->dev);
+       int rc_lock, rc = 0;
+
+       if (test_bit(HID_CLEAR_HALT, &hid->iofl)) {
+               dev_dbg(&hid->intf->dev, "clear halt\n");
+               rc = usb_clear_halt(hid->dev, hid->urbin->pipe);
+               clear_bit(HID_CLEAR_HALT, &hid->iofl);
+               hid_start_in(hid);
+       }
+
+       else if (test_bit(HID_RESET_PENDING, &hid->iofl)) {
+               dev_dbg(&hid->intf->dev, "resetting device\n");
+               rc = rc_lock = usb_lock_device_for_reset(hid->dev, hid->intf);
+               if (rc_lock >= 0) {
+                       rc = usb_reset_composite_device(hid->dev, hid->intf);
+                       if (rc_lock)
+                               usb_unlock_device(hid->dev);
+               }
+               clear_bit(HID_RESET_PENDING, &hid->iofl);
        }
-       clear_bit(HID_RESET_PENDING, &hid->iofl);
 
        switch (rc) {
        case 0:
@@ -1023,9 +1032,8 @@ static void hid_io_error(struct hid_devi
 
                /* Retries failed, so do a port reset */
                if (!test_and_set_bit(HID_RESET_PENDING, &hid->iofl)) {
-                       if (schedule_work(&hid->reset_work))
-                               goto done;
-                       clear_bit(HID_RESET_PENDING, &hid->iofl);
+                       schedule_work(&hid->reset_work);
+                       goto done;
                }
        }
 
@@ -1049,6 +1057,11 @@ static void hid_irq_in(struct urb *urb)
                        hid->retry_delay = 0;
                        hid_input_report(HID_INPUT_REPORT, urb, 1);
                        break;
+               case -EPIPE:            /* stall */
+                       clear_bit(HID_IN_RUNNING, &hid->iofl);
+                       set_bit(HID_CLEAR_HALT, &hid->iofl);
+                       schedule_work(&hid->reset_work);
+                       return;
                case -ECONNRESET:       /* unlink */
                case -ENOENT:
                case -ESHUTDOWN:        /* unplug */
diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h
index 0e76e6d..2a9bf07 100644
--- a/drivers/usb/input/hid.h
+++ b/drivers/usb/input/hid.h
@@ -385,6 +385,7 @@ struct hid_control_fifo {
 #define HID_IN_RUNNING         3
 #define HID_RESET_PENDING      4
 #define HID_SUSPENDED          5
+#define HID_CLEAR_HALT         6
 
 struct hid_input {
        struct list_head list;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to