Re: [patch] HID descriptor STALL fix for the HID gadget

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.

Sebastian Bauer wrote:

Basically, the USB HID gadget does respond to a request of getting the
HID descriptor via a STALL
although it could easily deliver the descriptor. A possible fix, which
is really tiny, is attached to the
mentioned bug (https://bugzilla.kernel.org/show_bug.cgi?id=36232 or
https://bugzilla.kernel.org/attachment.cgi?id=60052 for the attachment).

Ah, you have a patch for this, great.
Then please just send it to us, in the format described in
Documentation/SubmittingPatches, in email, so we can apply it.  We can't
apply patches from bugzilla.

Okay, here is the patch regenerated from linux-next. Hope this is fine. The patch changes the hid gadget such that a request for the HID descriptor is handled by copying the descriptor into the response buffer, rather than falling through the default case, in which the request is answered by a STALL.

diff --git a/drivers/usb/gadget/f_hid.c b/drivers/usb/gadget/f_hid.c
index 403a48b..83a266b 100644
--- a/drivers/usb/gadget/f_hid.c
+++ b/drivers/usb/gadget/f_hid.c
@@ -367,6 +367,13 @@ static int hidg_setup(struct usb_function *f,
        case ((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8
                  | USB_REQ_GET_DESCRIPTOR):
                switch (value >> 8) {
+               case HID_DT_HID:
+                       VDBG(cdev, "USB_REQ_GET_DESCRIPTOR: HID\n");
+                       length = min_t(unsigned short, length,
+                                                  hidg_desc.bLength);
+                       memcpy(req->buf, &hidg_desc, length);
+                       goto respond;
+                       break;

   *break* is useless after *goto*.

WBR, Sergei

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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux