We register devices for OTG controllers only to associate a .mode device parameter with them. Follow-up commits will need to refer to previously registered OTG controllers, so let's register a bus type for them and use it to maintain a list of controllers. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- drivers/usb/otg/otgdev.c | 11 +++++++++++ include/linux/usb/usb.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/drivers/usb/otg/otgdev.c b/drivers/usb/otg/otgdev.c index d0a1cecc85cf..e035c988af2d 100644 --- a/drivers/usb/otg/otgdev.c +++ b/drivers/usb/otg/otgdev.c @@ -63,6 +63,10 @@ static struct device otg_device = { .id = DEVICE_ID_SINGLE, }; +struct bus_type otg_bus_type = { + .name = "usbotg" /* "otg" is already taken for the alias */ +}; + int usb_register_otg_device(struct device *parent, int (*set_mode)(void *ctx, enum usb_dr_mode mode), void *ctx) { @@ -72,6 +76,7 @@ int usb_register_otg_device(struct device *parent, otg = xzalloc(sizeof(*otg)); otg->dev.priv = otg; otg->dev.parent = parent; + otg->dev.bus = &otg_bus_type; otg->dev.id = DEVICE_ID_DYNAMIC; dev_set_name(&otg->dev, "otg"); @@ -90,3 +95,9 @@ int usb_register_otg_device(struct device *parent, return register_otg_device(&otg->dev, otg); } + +static int otg_bus_init(void) +{ + return bus_register(&otg_bus_type); +} +pure_initcall(otg_bus_init); diff --git a/include/linux/usb/usb.h b/include/linux/usb/usb.h index ffeceec88f9e..a611d19b4a17 100644 --- a/include/linux/usb/usb.h +++ b/include/linux/usb/usb.h @@ -480,6 +480,8 @@ enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np, int usb_register_otg_device(struct device *parent, int (*set_mode)(void *ctx, enum usb_dr_mode mode), void *ctx); +extern struct bus_type otg_bus_type; + extern struct list_head usb_device_list; bool usb_hub_is_root_hub(struct usb_device *hdev); -- 2.39.2