usbdevice/core: misc cleanup

This commit is contained in:
Grissiom 2013-05-10 17:35:33 +08:00
parent ffb1e62020
commit 5de59429fe
1 changed files with 14 additions and 18 deletions

View File

@ -1294,25 +1294,24 @@ static void rt_usbd_thread_entry(void* parameter)
uep_t ep; uep_t ep;
/* receive message */ /* receive message */
if(rt_mq_recv(usb_mq, &msg, sizeof(struct udev_msg), RT_WAITING_FOREVER) if(rt_mq_recv(usb_mq,
!= RT_EOK ) continue; &msg, sizeof(struct udev_msg),
RT_WAITING_FOREVER) != RT_EOK )
continue;
switch (msg.type)
{
case USB_MSG_SETUP_NOTIFY:
device = rt_usbd_find_device(msg.dcd);
if(device != RT_NULL)
_setup_request(device, (ureq_t)msg.content.setup_msg.packet);
else
rt_kprintf("invalid usb device\n");
break;
case USB_MSG_DATA_NOTIFY:
device = rt_usbd_find_device(msg.dcd); device = rt_usbd_find_device(msg.dcd);
if(device == RT_NULL) if(device == RT_NULL)
{ {
rt_kprintf("invalid usb device\n"); rt_kprintf("invalid usb device\n");
break; continue;
} }
switch (msg.type)
{
case USB_MSG_SETUP_NOTIFY:
_setup_request(device, (ureq_t)msg.content.setup_msg.packet);
break;
case USB_MSG_DATA_NOTIFY:
ep = rt_usbd_find_endpoint(device, &cls, msg.content.ep_msg.ep_addr); ep = rt_usbd_find_endpoint(device, &cls, msg.content.ep_msg.ep_addr);
if(ep != RT_NULL) if(ep != RT_NULL)
ep->handler(device, cls, msg.content.ep_msg.size); ep->handler(device, cls, msg.content.ep_msg.size);
@ -1320,13 +1319,10 @@ static void rt_usbd_thread_entry(void* parameter)
rt_kprintf("invalid endpoint\n"); rt_kprintf("invalid endpoint\n");
break; break;
case USB_MSG_SOF: case USB_MSG_SOF:
device = rt_usbd_find_device(msg.dcd);
if(device != RT_NULL)
_sof_notify(device); _sof_notify(device);
else
rt_kprintf("invalid usb device\n");
break; break;
default: default:
rt_kprintf("unknown msg type\n");
break; break;
} }
} }