/* This function will allocate an usb device instance from system. */
uinst_t rt_usbh_alloc_instance(uhcd_t uhcd)
/* This function will allocate an usb device instance from system. */
uinst_t rt_usbh_alloc_instance(uhcd_t uhcd)
{
    int i;
    rt_enter_critical();
    for(i=0; i<USB_MAX_DEVICE; i++)
    {
        if(dev[i].status != DEV_STATUS_IDLE) continue;
        rt_memset(&dev[i], 0, sizeof(struct uinstance));
        dev[i].status = DEV_STATUS_BUSY;
        dev[i].index = i + 1;
        dev[i].address = 0;
        dev[i].max_packet_size = 0x8;
        rt_list_init(&dev[i].pipe);
        dev[i].hcd = uhcd;
        rt_exit_critical();
        return &dev[i];
    }
    rt_exit_critical();
    return RT_NULL;
}