[PATCH 05/12] USB: host: fixup USB device hierarchy

Sascha Hauer s.hauer at pengutronix.de
Sat Jul 19 02:16:00 PDT 2014


Make all USB devices children to the hub device they are
attached to.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/usb/core/hub.c | 1 +
 drivers/usb/core/usb.c | 3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 0f43955..26c2ca0 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -196,6 +196,7 @@ static void usb_hub_port_connect_change(struct usb_device *dev, int port)
 
 	/* Allocate a new device struct for it */
 	usb = usb_alloc_new_device();
+	usb->dev.parent = &dev->dev;
 	usb->host = dev->host;
 
 	if (portstatus & USB_PORT_STAT_HIGH_SPEED)
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index c289bbb..7c69e10 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -424,8 +424,6 @@ int usb_new_device(struct usb_device *dev)
 
 	dev->dev.id = DEVICE_ID_SINGLE;
 
-	if (dev->host->hw_dev)
-		dev->dev.parent = dev->host->hw_dev;
 	print_usb_device(dev);
 
 	err = register_device(&dev->dev);
@@ -500,6 +498,7 @@ int usb_host_detect(struct usb_host *host, int force)
 		return ret;
 
 	dev = usb_alloc_new_device();
+	dev->dev.parent = host->hw_dev;
 	dev->host = host;
 	usb_new_device(dev);
 
-- 
2.0.1




More information about the barebox mailing list