Commit 8b0df4b2 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

greybus: interface: make interfaces children of host devices

Make interfaces child devices of host devices.

The new interface device name is "<bus_id>-<intf_id>", where bus_id is
the dynamically allocated bus id for the host device and intf_id is the
svc-allocated interface id.
Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 582b3a13
...@@ -124,20 +124,14 @@ int gb_create_bundle_connection(struct gb_interface *intf, u8 class) ...@@ -124,20 +124,14 @@ int gb_create_bundle_connection(struct gb_interface *intf, u8 class)
struct gb_interface *gb_interface_create(struct gb_host_device *hd, struct gb_interface *gb_interface_create(struct gb_host_device *hd,
u8 interface_id) u8 interface_id)
{ {
struct gb_module *module;
struct gb_interface *intf; struct gb_interface *intf;
int retval; int retval;
module = gb_module_find(hd, endo_get_module_id(hd->endo, interface_id));
if (!module)
return NULL;
intf = kzalloc(sizeof(*intf), GFP_KERNEL); intf = kzalloc(sizeof(*intf), GFP_KERNEL);
if (!intf) if (!intf)
goto put_module; return NULL;
intf->hd = hd; /* XXX refcount? */ intf->hd = hd; /* XXX refcount? */
intf->module = module;
intf->interface_id = interface_id; intf->interface_id = interface_id;
INIT_LIST_HEAD(&intf->bundles); INIT_LIST_HEAD(&intf->bundles);
INIT_LIST_HEAD(&intf->manifest_descs); INIT_LIST_HEAD(&intf->manifest_descs);
...@@ -145,13 +139,13 @@ struct gb_interface *gb_interface_create(struct gb_host_device *hd, ...@@ -145,13 +139,13 @@ struct gb_interface *gb_interface_create(struct gb_host_device *hd,
/* Invalid device id to start with */ /* Invalid device id to start with */
intf->device_id = GB_DEVICE_ID_BAD; intf->device_id = GB_DEVICE_ID_BAD;
intf->dev.parent = &module->dev; intf->dev.parent = &hd->dev;
intf->dev.bus = &greybus_bus_type; intf->dev.bus = &greybus_bus_type;
intf->dev.type = &greybus_interface_type; intf->dev.type = &greybus_interface_type;
intf->dev.groups = interface_groups; intf->dev.groups = interface_groups;
intf->dev.dma_mask = hd->dev.dma_mask; intf->dev.dma_mask = hd->dev.dma_mask;
device_initialize(&intf->dev); device_initialize(&intf->dev);
dev_set_name(&intf->dev, "%s:%d", dev_name(&module->dev), interface_id); dev_set_name(&intf->dev, "%d-%d", hd->bus_id, interface_id);
retval = device_add(&intf->dev); retval = device_add(&intf->dev);
if (retval) { if (retval) {
...@@ -167,8 +161,6 @@ struct gb_interface *gb_interface_create(struct gb_host_device *hd, ...@@ -167,8 +161,6 @@ struct gb_interface *gb_interface_create(struct gb_host_device *hd,
free_intf: free_intf:
put_device(&intf->dev); put_device(&intf->dev);
put_module:
put_device(&module->dev);
return NULL; return NULL;
} }
...@@ -177,7 +169,6 @@ struct gb_interface *gb_interface_create(struct gb_host_device *hd, ...@@ -177,7 +169,6 @@ struct gb_interface *gb_interface_create(struct gb_host_device *hd,
*/ */
void gb_interface_remove(struct gb_interface *intf) void gb_interface_remove(struct gb_interface *intf)
{ {
struct gb_module *module;
struct gb_bundle *bundle; struct gb_bundle *bundle;
struct gb_bundle *next; struct gb_bundle *next;
...@@ -191,9 +182,7 @@ void gb_interface_remove(struct gb_interface *intf) ...@@ -191,9 +182,7 @@ void gb_interface_remove(struct gb_interface *intf)
list_for_each_entry_safe(bundle, next, &intf->bundles, links) list_for_each_entry_safe(bundle, next, &intf->bundles, links)
gb_bundle_destroy(bundle); gb_bundle_destroy(bundle);
module = intf->module;
device_unregister(&intf->dev); device_unregister(&intf->dev);
put_device(&module->dev);
} }
void gb_interfaces_remove(struct gb_host_device *hd) void gb_interfaces_remove(struct gb_host_device *hd)
......
...@@ -31,7 +31,6 @@ struct gb_interface { ...@@ -31,7 +31,6 @@ struct gb_interface {
u32 vendor_id; u32 vendor_id;
u32 product_id; u32 product_id;
struct gb_module *module;
struct gb_host_device *hd; struct gb_host_device *hd;
/* The interface needs to boot over unipro */ /* The interface needs to boot over unipro */
......
...@@ -878,12 +878,6 @@ static int gb_loopback_bus_id_compare(void *priv, struct list_head *lha, ...@@ -878,12 +878,6 @@ static int gb_loopback_bus_id_compare(void *priv, struct list_head *lha,
struct gb_connection *ca = a->connection; struct gb_connection *ca = a->connection;
struct gb_connection *cb = b->connection; struct gb_connection *cb = b->connection;
if (ca->bundle->intf->module->module_id <
cb->bundle->intf->module->module_id)
return -1;
if (cb->bundle->intf->module->module_id <
ca->bundle->intf->module->module_id)
return 1;
if (ca->bundle->intf->interface_id < cb->bundle->intf->interface_id) if (ca->bundle->intf->interface_id < cb->bundle->intf->interface_id)
return -1; return -1;
if (cb->bundle->intf->interface_id < ca->bundle->intf->interface_id) if (cb->bundle->intf->interface_id < ca->bundle->intf->interface_id)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment