Skip to content

Commit 4b2b9a8

Browse files
authored
Merge pull request #3871 from OpenNuvoton/rtt_usbhost_issue
Fix USB host core bugs.
2 parents 40479b8 + f4d86ce commit 4b2b9a8

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

components/drivers/usb/usbhost/class/udisk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ rt_err_t rt_udisk_run(struct uhintf* intf)
186186
{
187187
int i = 0;
188188
rt_err_t ret;
189-
char dname[4];
189+
char dname[8];
190190
char sname[8];
191191
rt_uint8_t max_lun, *sector, sense[18], inquiry[36];
192192
struct dfs_partition part[MAX_PARTITION_COUNT];

components/drivers/usb/usbhost/core/hub.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,13 @@ static rt_err_t rt_usbh_hub_port_change(uhub_t hub)
417417

418418
if(reconnect)
419419
{
420-
if(hub->child[i] != RT_NULL && hub->child[i]->status != DEV_STATUS_IDLE)
420+
if(hub->child[i] != RT_NULL && hub->child[i]->status != DEV_STATUS_IDLE)
421+
{
421422
rt_usbh_detach_instance(hub->child[i]);
423+
424+
/* Child device have been detach. Set hub->child[i] to NULL. */
425+
hub->child[i] = RT_NULL;
426+
}
422427

423428
ret = rt_usbh_hub_port_debounce(hub, i + 1);
424429
if(ret != RT_EOK) continue;
@@ -532,7 +537,12 @@ static rt_err_t rt_usbh_hub_enable(void *arg)
532537
}
533538

534539
/* get hub ports number */
535-
hub->num_ports = hub->hub_desc.num_ports;
540+
/* If hub device supported ports over USB_HUB_PORT_NUM(Ex: 8 port hub). Set hub->num_ports to USB_HUB_PORT_NUM */
541+
if(hub->hub_desc.num_ports > USB_HUB_PORT_NUM)
542+
hub->num_ports = USB_HUB_PORT_NUM;
543+
else
544+
hub->num_ports = hub->hub_desc.num_ports;
545+
536546
hub->hcd = device->hcd;
537547
hub->self = device;
538548

@@ -607,7 +617,6 @@ static rt_err_t rt_usbh_hub_disable(void* arg)
607617
}
608618

609619
if(hub != RT_NULL) rt_free(hub);
610-
if(intf != RT_NULL) rt_free(intf);
611620

612621
return RT_EOK;
613622
}

0 commit comments

Comments
 (0)