- 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
This commit is contained in:
Amaury Pouly 2010-03-08 13:00:24 +00:00
parent d0a170c176
commit ae208af9cc

View file

@ -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) { switch (req->bRequest) {
case USB_REQ_CLEAR_FEATURE: 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_recv(EP_CONTROL,NULL,0);
usb_drv_send(EP_CONTROL,response_data,2); usb_drv_send(EP_CONTROL,response_data,2);
break; break;
default: { default:
bool handled; request_handler_endoint_drivers(req);
control_handler_t control_handler; break;
}
}
control_handler= static void request_handler_endpoint(struct usb_ctrlrequest* req)
ep_data[EP_NUM(req->wIndex)].control_handler[EP_CONTROL]; {
if (!control_handler) switch(req->bRequestType & USB_TYPE_MASK) {
break; case USB_TYPE_STANDARD:
request_handler_endpoint_standard(req);
handled=control_handler(req, response_data); break;
if (!handled) { case USB_TYPE_CLASS:
/* nope. flag error */ request_handler_endoint_drivers(req);
logf("usb bad req %d",req->bRequest); break;
usb_drv_stall(EP_CONTROL,true,true); case USB_TYPE_VENDOR:
usb_core_ack_control(req); default:
} break;
break;
}
} }
} }