summaryrefslogtreecommitdiff
path: root/firmware/usbstack
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-09-17 10:30:17 +0100
committerAidan MacDonald <amachronic@protonmail.com>2021-09-20 17:38:56 -0400
commit99f333c64f13c3f9a62b9f5e184ae87f053bf65a (patch)
treed4c31cd346cc13b173965d56df8041613baa9ab2 /firmware/usbstack
parent483563a1b2cd5d463557580498d75a693dd79077 (diff)
downloadrockbox-99f333c64f13c3f9a62b9f5e184ae87f053bf65a.tar.gz
rockbox-99f333c64f13c3f9a62b9f5e184ae87f053bf65a.zip
usb_hid: fix accidental fallthrough
Successful SET REPORT requests would spuriously fail because of the fall through to GET REPORT. Change-Id: I8e7d1a1120afc6975d07d47b11c12c9e9ca51dd2
Diffstat (limited to 'firmware/usbstack')
-rw-r--r--firmware/usbstack/usb_hid.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/firmware/usbstack/usb_hid.c b/firmware/usbstack/usb_hid.c
index 5885b60e32..885ae4c24a 100644
--- a/firmware/usbstack/usb_hid.c
+++ b/firmware/usbstack/usb_hid.c
@@ -785,27 +785,39 @@ bool usb_hid_control_request(struct usb_ctrlrequest *req, unsigned char *dest)
785 (req->bRequest == USB_HID_SET_IDLE) ? "set idle" : 785 (req->bRequest == USB_HID_SET_IDLE) ? "set idle" :
786 ((req->bRequest == USB_HID_SET_REPORT) ? "set report" : 786 ((req->bRequest == USB_HID_SET_REPORT) ? "set report" :
787 ((req->bRequest == USB_HID_GET_REPORT) ? "get report" : ""))); 787 ((req->bRequest == USB_HID_GET_REPORT) ? "get report" : "")));
788
789 int rc;
788 switch (req->bRequest) 790 switch (req->bRequest)
789 { 791 {
790 case USB_HID_SET_REPORT: 792 case USB_HID_SET_REPORT:
791 if (usb_hid_set_report(req)) 793 rc = usb_hid_set_report(req);
792 break; 794 break;
793 case USB_HID_GET_REPORT: 795 case USB_HID_GET_REPORT:
794 if (usb_hid_get_report(req, &dest)) 796 rc = usb_hid_get_report(req, &dest);
795 break; 797 break;
796 case USB_HID_SET_IDLE: 798 case USB_HID_SET_IDLE:
797 if (dest != orig_dest) 799 rc = 0;
798 { 800 break;
799 usb_drv_recv(EP_CONTROL, NULL, 0); /* ack */ 801 default:
800 usb_drv_send(EP_CONTROL, orig_dest, dest - orig_dest); 802 /* all other requests are errors */
801 } 803 rc = -1;
802 else 804 break;
803 {
804 usb_drv_send(EP_CONTROL, NULL, 0); /* ack */
805 }
806 return true;
807 } 805 }
808 break; 806
807 if(rc != 0)
808 break;
809
810 if (dest != orig_dest)
811 {
812 usb_drv_recv(EP_CONTROL, NULL, 0); /* ack */
813 usb_drv_send(EP_CONTROL, orig_dest, dest - orig_dest);
814 }
815 else
816 {
817 usb_drv_send(EP_CONTROL, NULL, 0); /* ack */
818 }
819
820 return true;
809 } 821 }
810 822
811 case USB_TYPE_VENDOR: 823 case USB_TYPE_VENDOR: