mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-02-19 05:51:24 +08:00
Fix USB host core issues.
1. Limit >4 USB ports hubs. 2. Double free intf. 3. dname buffer size is too small. 4. Reset child pointer after detaching instance.
This commit is contained in:
parent
82ac7d1eea
commit
f4d86cec7f
@ -186,7 +186,7 @@ rt_err_t rt_udisk_run(struct uhintf* intf)
|
|||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
rt_err_t ret;
|
rt_err_t ret;
|
||||||
char dname[4];
|
char dname[8];
|
||||||
char sname[8];
|
char sname[8];
|
||||||
rt_uint8_t max_lun, *sector, sense[18], inquiry[36];
|
rt_uint8_t max_lun, *sector, sense[18], inquiry[36];
|
||||||
struct dfs_partition part[MAX_PARTITION_COUNT];
|
struct dfs_partition part[MAX_PARTITION_COUNT];
|
||||||
|
@ -417,8 +417,13 @@ static rt_err_t rt_usbh_hub_port_change(uhub_t hub)
|
|||||||
|
|
||||||
if(reconnect)
|
if(reconnect)
|
||||||
{
|
{
|
||||||
if(hub->child[i] != RT_NULL && hub->child[i]->status != DEV_STATUS_IDLE)
|
if(hub->child[i] != RT_NULL && hub->child[i]->status != DEV_STATUS_IDLE)
|
||||||
|
{
|
||||||
rt_usbh_detach_instance(hub->child[i]);
|
rt_usbh_detach_instance(hub->child[i]);
|
||||||
|
|
||||||
|
/* Child device have been detach. Set hub->child[i] to NULL. */
|
||||||
|
hub->child[i] = RT_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ret = rt_usbh_hub_port_debounce(hub, i + 1);
|
ret = rt_usbh_hub_port_debounce(hub, i + 1);
|
||||||
if(ret != RT_EOK) continue;
|
if(ret != RT_EOK) continue;
|
||||||
@ -532,7 +537,12 @@ static rt_err_t rt_usbh_hub_enable(void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* get hub ports number */
|
/* get hub ports number */
|
||||||
hub->num_ports = hub->hub_desc.num_ports;
|
/* If hub device supported ports over USB_HUB_PORT_NUM(Ex: 8 port hub). Set hub->num_ports to USB_HUB_PORT_NUM */
|
||||||
|
if(hub->hub_desc.num_ports > USB_HUB_PORT_NUM)
|
||||||
|
hub->num_ports = USB_HUB_PORT_NUM;
|
||||||
|
else
|
||||||
|
hub->num_ports = hub->hub_desc.num_ports;
|
||||||
|
|
||||||
hub->hcd = device->hcd;
|
hub->hcd = device->hcd;
|
||||||
hub->self = device;
|
hub->self = device;
|
||||||
|
|
||||||
@ -607,7 +617,6 @@ static rt_err_t rt_usbh_hub_disable(void* arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(hub != RT_NULL) rt_free(hub);
|
if(hub != RT_NULL) rt_free(hub);
|
||||||
if(intf != RT_NULL) rt_free(intf);
|
|
||||||
|
|
||||||
return RT_EOK;
|
return RT_EOK;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user