X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=common%2Fusb_hub.c;h=e1de813adf82225ab4f7204088a698eeb782b0e4;hb=19de81502be9e4dd1132b4b9641f66a587b8b0e2;hp=f621ddb9ab5debe7c6b65514f2b04ee408167bfc;hpb=413978d118bb7d7b0a8488d97d802f2899cd81ce;p=oweals%2Fu-boot.git diff --git a/common/usb_hub.c b/common/usb_hub.c index f621ddb9ab..e1de813adf 100644 --- a/common/usb_hub.c +++ b/common/usb_hub.c @@ -26,10 +26,14 @@ #include #include #include +#include #include #include #include #include +#ifdef CONFIG_SANDBOX +#include +#endif #include #include @@ -229,7 +233,7 @@ int legacy_hub_port_reset(struct usb_device *dev, int port, #ifdef CONFIG_DM_USB int hub_port_reset(struct udevice *dev, int port, unsigned short *portstat) { - struct usb_device *udev = dev_get_parentdata(dev); + struct usb_device *udev = dev_get_parent_priv(dev); return legacy_hub_port_reset(udev, port, portstat); } @@ -465,7 +469,12 @@ static int usb_hub_configure(struct usb_device *dev) unsigned short portstatus, portchange; int ret; ulong start = get_timer(0); + uint delay = CONFIG_SYS_HZ; +#ifdef CONFIG_SANDBOX + if (state_get_skip_delays()) + delay = 0; +#endif #ifdef CONFIG_DM_USB debug("\n\nScanning '%s' port %d\n", dev->dev->name, i + 1); #else @@ -489,11 +498,15 @@ static int usb_hub_configure(struct usb_device *dev) portstatus = le16_to_cpu(portsts->wPortStatus); portchange = le16_to_cpu(portsts->wPortChange); - if ((portchange & USB_PORT_STAT_C_CONNECTION) == - (portstatus & USB_PORT_STAT_CONNECTION)) + /* No connection change happened, wait a bit more. */ + if (!(portchange & USB_PORT_STAT_C_CONNECTION)) + continue; + + /* Test if the connection came up, and if so, exit. */ + if (portstatus & USB_PORT_STAT_CONNECTION) break; - } while (get_timer(start) < CONFIG_SYS_HZ * 10); + } while (get_timer(start) < delay); if (ret < 0) continue; @@ -605,7 +618,7 @@ int usb_hub_probe(struct usb_device *dev, int ifnum) #ifdef CONFIG_DM_USB int usb_hub_scan(struct udevice *hub) { - struct usb_device *udev = dev_get_parentdata(hub); + struct usb_device *udev = dev_get_parent_priv(hub); return usb_hub_configure(udev); }