diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/gadget/function/f_hid.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c index 13dfc9915b1d..f7f35a36c09a 100644 --- a/drivers/usb/gadget/function/f_hid.c +++ b/drivers/usb/gadget/function/f_hid.c | |||
@@ -437,12 +437,20 @@ static int hidg_setup(struct usb_function *f, | |||
437 | | USB_REQ_GET_DESCRIPTOR): | 437 | | USB_REQ_GET_DESCRIPTOR): |
438 | switch (value >> 8) { | 438 | switch (value >> 8) { |
439 | case HID_DT_HID: | 439 | case HID_DT_HID: |
440 | { | ||
441 | struct hid_descriptor hidg_desc_copy = hidg_desc; | ||
442 | |||
440 | VDBG(cdev, "USB_REQ_GET_DESCRIPTOR: HID\n"); | 443 | VDBG(cdev, "USB_REQ_GET_DESCRIPTOR: HID\n"); |
444 | hidg_desc_copy.desc[0].bDescriptorType = HID_DT_REPORT; | ||
445 | hidg_desc_copy.desc[0].wDescriptorLength = | ||
446 | cpu_to_le16(hidg->report_desc_length); | ||
447 | |||
441 | length = min_t(unsigned short, length, | 448 | length = min_t(unsigned short, length, |
442 | hidg_desc.bLength); | 449 | hidg_desc_copy.bLength); |
443 | memcpy(req->buf, &hidg_desc, length); | 450 | memcpy(req->buf, &hidg_desc_copy, length); |
444 | goto respond; | 451 | goto respond; |
445 | break; | 452 | break; |
453 | } | ||
446 | case HID_DT_REPORT: | 454 | case HID_DT_REPORT: |
447 | VDBG(cdev, "USB_REQ_GET_DESCRIPTOR: REPORT\n"); | 455 | VDBG(cdev, "USB_REQ_GET_DESCRIPTOR: REPORT\n"); |
448 | length = min_t(unsigned short, length, | 456 | length = min_t(unsigned short, length, |
@@ -632,6 +640,10 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f) | |||
632 | hidg_fs_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); | 640 | hidg_fs_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); |
633 | hidg_hs_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); | 641 | hidg_hs_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); |
634 | hidg_fs_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); | 642 | hidg_fs_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); |
643 | /* | ||
644 | * We can use hidg_desc struct here but we should not relay | ||
645 | * that its content won't change after returning from this function. | ||
646 | */ | ||
635 | hidg_desc.desc[0].bDescriptorType = HID_DT_REPORT; | 647 | hidg_desc.desc[0].bDescriptorType = HID_DT_REPORT; |
636 | hidg_desc.desc[0].wDescriptorLength = | 648 | hidg_desc.desc[0].wDescriptorLength = |
637 | cpu_to_le16(hidg->report_desc_length); | 649 | cpu_to_le16(hidg->report_desc_length); |