On Tue, 23 Jul 2013, Josef Schimke wrote:

> @@ -80,20 +80,26 @@ static int hid_start_in(struct hid_devic
>       unsigned long flags;
>       int rc = 0;
>       struct usbhid_device *usbhid = hid->driver_data;
> +     int i;
>  
>       spin_lock_irqsave(&usbhid->lock, flags);
>       if (hid->open > 0 &&
>                       !test_bit(HID_DISCONNECTED, &usbhid->iofl) &&
>                       !test_bit(HID_SUSPENDED, &usbhid->iofl) &&
>                       !test_and_set_bit(HID_IN_RUNNING, &usbhid->iofl)) {
> -             rc = usb_submit_urb(usbhid->urbin, GFP_ATOMIC);
> -             if (rc != 0) {
> -                     clear_bit(HID_IN_RUNNING, &usbhid->iofl);
> -                     if (rc == -ENOSPC)
> -                             set_bit(HID_NO_BANDWIDTH, &usbhid->iofl);
> -             } else {
> -                     clear_bit(HID_NO_BANDWIDTH, &usbhid->iofl);
> +             for (i = 0; i < usbhid->n_inurbs; i++) {
> +                     rc = usb_submit_urb(usbhid->inurbs[i], GFP_ATOMIC);
> +                     if (rc != 0) {
> +                             clear_bit(HID_IN_RUNNING, &usbhid->iofl);
> +                             if (rc == -ENOSPC)
> +                                     set_bit(HID_NO_BANDWIDTH, 
> &usbhid->iofl);
> +
> +                             break;

If submitting the second URB fails, you probably want to cancel the 
first URB.

> @@ -120,7 +126,7 @@ static void hid_reset(struct work_struct
>  
>       if (test_bit(HID_CLEAR_HALT, &usbhid->iofl)) {
>               dev_dbg(&usbhid->intf->dev, "clear halt\n");
> -             rc = usb_clear_halt(hid_to_usb_dev(hid), usbhid->urbin->pipe);
> +             rc = usb_clear_halt(hid_to_usb_dev(hid), 
> usbhid->inurbs[0]->pipe);
>               clear_bit(HID_CLEAR_HALT, &usbhid->iofl);
>               hid_start_in(hid);
>       }

Before clearing the halt, you should make sure that neither URB is 
running.  Probably the best way is to call usb_unlink_urb() for the 
other URB whenever one gets an error.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to