From 8b0df4b2eaf2f741ae44e8f5bad4ecb223f87932 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Wed, 25 Nov 2015 15:59:04 +0100 Subject: [PATCH] greybus: interface: make interfaces children of host devices Make interfaces child devices of host devices. The new interface device name is "-", 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: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/interface.c | 17 +++-------------- drivers/staging/greybus/interface.h | 1 - drivers/staging/greybus/loopback.c | 6 ------ 3 files changed, 3 insertions(+), 21 deletions(-) diff --git a/drivers/staging/greybus/interface.c b/drivers/staging/greybus/interface.c index 1b13d3791b28..5060924f167d 100644 --- a/drivers/staging/greybus/interface.c +++ b/drivers/staging/greybus/interface.c @@ -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, u8 interface_id) { - struct gb_module *module; struct gb_interface *intf; 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); if (!intf) - goto put_module; + return NULL; intf->hd = hd; /* XXX refcount? */ - intf->module = module; intf->interface_id = interface_id; INIT_LIST_HEAD(&intf->bundles); INIT_LIST_HEAD(&intf->manifest_descs); @@ -145,13 +139,13 @@ struct gb_interface *gb_interface_create(struct gb_host_device *hd, /* Invalid device id to start with */ 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.type = &greybus_interface_type; intf->dev.groups = interface_groups; intf->dev.dma_mask = hd->dev.dma_mask; 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); if (retval) { @@ -167,8 +161,6 @@ struct gb_interface *gb_interface_create(struct gb_host_device *hd, free_intf: put_device(&intf->dev); -put_module: - put_device(&module->dev); return NULL; } @@ -177,7 +169,6 @@ put_module: */ void gb_interface_remove(struct gb_interface *intf) { - struct gb_module *module; struct gb_bundle *bundle; struct gb_bundle *next; @@ -191,9 +182,7 @@ void gb_interface_remove(struct gb_interface *intf) list_for_each_entry_safe(bundle, next, &intf->bundles, links) gb_bundle_destroy(bundle); - module = intf->module; device_unregister(&intf->dev); - put_device(&module->dev); } void gb_interfaces_remove(struct gb_host_device *hd) diff --git a/drivers/staging/greybus/interface.h b/drivers/staging/greybus/interface.h index 71493cd96ec7..1202062a70eb 100644 --- a/drivers/staging/greybus/interface.h +++ b/drivers/staging/greybus/interface.h @@ -31,7 +31,6 @@ struct gb_interface { u32 vendor_id; u32 product_id; - struct gb_module *module; struct gb_host_device *hd; /* The interface needs to boot over unipro */ diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c index 0c38414a3e06..ededfef40e9c 100644 --- a/drivers/staging/greybus/loopback.c +++ b/drivers/staging/greybus/loopback.c @@ -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 *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) return -1; if (cb->bundle->intf->interface_id < ca->bundle->intf->interface_id) -- 2.20.1