summaryrefslogtreecommitdiff
path: root/firmware/usbstack
diff options
context:
space:
mode:
authorAmaury Pouly <pamaury@rockbox.org>2010-03-08 13:00:24 +0000
committerAmaury Pouly <pamaury@rockbox.org>2010-03-08 13:00:24 +0000
commitae208af9cc9a266eefabdd9a999a6501924d81f1 (patch)
treeed10bdab57535dccf81b86bb5978b30972773b41 /firmware/usbstack
parentd0a170c1769f13f1e42bc306979f6a36085f7344 (diff)
downloadrockbox-ae208af9cc9a266eefabdd9a999a6501924d81f1.zip
rockbox-ae208af9cc9a266eefabdd9a999a6501924d81f1.tar.gz
rockbox-ae208af9cc9a266eefabdd9a999a6501924d81f1.tar.bz2
rockbox-ae208af9cc9a266eefabdd9a999a6501924d81f1.tar.xz
- Fix the control_handler selection in usb_core when a request in sent to an endpoint (use endpoint dir and not EP_CONTROL !)
- Only interpret standard endpoint requests (previous code didn't check the request type) and pass all others to usb drivers. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25069 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/usbstack')
-rw-r--r--firmware/usbstack/usb_core.c57
1 files changed, 38 insertions, 19 deletions
diff --git a/firmware/usbstack/usb_core.c b/firmware/usbstack/usb_core.c
index 7b80d0b..a5865da 100644
--- a/firmware/usbstack/usb_core.c
+++ b/firmware/usbstack/usb_core.c
@@ -729,7 +729,26 @@ static void request_handler_interface(struct usb_ctrlrequest* req)
}
}
-static void request_handler_endpoint(struct usb_ctrlrequest* req)
+static void request_handler_endoint_drivers(struct usb_ctrlrequest* req)
+{
+ bool handled = false;
+ control_handler_t control_handler = NULL;
+
+ if(EP_NUM(req->wIndex) < USB_NUM_ENDPOINTS)
+ control_handler = ep_data[EP_NUM(req->wIndex)].control_handler[EP_DIR(req->wIndex)];
+
+ if(control_handler)
+ handled = control_handler(req, response_data);
+
+ if (!handled) {
+ /* nope. flag error */
+ logf("usb bad req %d",req->bRequest);
+ usb_drv_stall(EP_CONTROL,true,true);
+ usb_core_ack_control(req);
+ }
+}
+
+static void request_handler_endpoint_standard(struct usb_ctrlrequest* req)
{
switch (req->bRequest) {
case USB_REQ_CLEAR_FEATURE:
@@ -755,24 +774,24 @@ static void request_handler_endpoint(struct usb_ctrlrequest* req)
usb_drv_recv(EP_CONTROL,NULL,0);
usb_drv_send(EP_CONTROL,response_data,2);
break;
- default: {
- bool handled;
- control_handler_t control_handler;
-
- control_handler=
- ep_data[EP_NUM(req->wIndex)].control_handler[EP_CONTROL];
- if (!control_handler)
- break;
-
- handled=control_handler(req, response_data);
- if (!handled) {
- /* nope. flag error */
- logf("usb bad req %d",req->bRequest);
- usb_drv_stall(EP_CONTROL,true,true);
- usb_core_ack_control(req);
- }
- break;
- }
+ default:
+ request_handler_endoint_drivers(req);
+ break;
+ }
+}
+
+static void request_handler_endpoint(struct usb_ctrlrequest* req)
+{
+ switch(req->bRequestType & USB_TYPE_MASK) {
+ case USB_TYPE_STANDARD:
+ request_handler_endpoint_standard(req);
+ break;
+ case USB_TYPE_CLASS:
+ request_handler_endoint_drivers(req);
+ break;
+ case USB_TYPE_VENDOR:
+ default:
+ break;
}
}