[PATCH 08/12] usb: add bus device
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Sun Oct 14 17:01:14 EDT 2012
automatically add usb_device to it if they do not have a parent already
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
drivers/usb/core/usb.c | 11 +++++++++++
include/usb/usb.h | 1 +
2 files changed, 12 insertions(+)
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 9dc931b..0d610d6 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -437,6 +437,11 @@ static int usb_new_device(struct usb_device *dev)
print_usb_device(dev);
+ if (!dev->dev.parent) {
+ dev->dev.parent = &usb_bus;
+ dev_add_child(dev->dev.parent, &dev->dev);
+ }
+
register_device(&dev->dev);
list_add_tail(&dev->list, &usb_device_list);
@@ -1411,6 +1416,11 @@ static void usb_remove(struct device_d *dev)
usbdrv->disconnect(usbdev);
}
+struct device_d usb_bus = {
+ .name = "usb",
+ .id = DEVICE_ID_SINGLE,
+};
+
struct bus_type usb_bus_type = {
.name = "usb",
.match = usb_match,
@@ -1420,6 +1430,7 @@ struct bus_type usb_bus_type = {
static int usb_bus_init(void)
{
+ register_device(&usb_bus);
return bus_register(&usb_bus_type);
}
pure_initcall(usb_bus_init);
diff --git a/include/usb/usb.h b/include/usb/usb.h
index 4649ee2..a0c26c1 100644
--- a/include/usb/usb.h
+++ b/include/usb/usb.h
@@ -193,6 +193,7 @@ struct usb_driver {
struct driver_d driver;
};
+extern struct device_d usb_bus;
extern struct bus_type usb_bus_type;
int usb_driver_register(struct usb_driver *);
--
1.7.10.4
More information about the barebox
mailing list