summaryrefslogtreecommitdiff
path: root/drivers/staging/greybus/bundle.c
diff options
context:
space:
mode:
authorJohan Hovold <johan@hovoldconsulting.com>2015-12-07 15:05:43 +0100
committerGreg Kroah-Hartman <gregkh@google.com>2015-12-08 15:56:38 -0500
commita7e36d0eac7fe9d8c66547ac4ec660b026ca4691 (patch)
tree29711b15c480e8aa73586198ca5789872d2c07ec /drivers/staging/greybus/bundle.c
parentbdc37354aa933d299c959144487eba777e707b63 (diff)
greybus: bundle: separate bundle creation and registration
Separate bundle creation and registration. Note that the bundle connections still needs to be initialised post registration as protocol drivers create child devices to the bundle. This will ultimately allow connection structures to be created while parsing manifests, but the connections to not be enabled until a driver is bound. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/bundle.c')
-rw-r--r--drivers/staging/greybus/bundle.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/drivers/staging/greybus/bundle.c b/drivers/staging/greybus/bundle.c
index 0f3a00d8d4f2..fb775ff1895d 100644
--- a/drivers/staging/greybus/bundle.c
+++ b/drivers/staging/greybus/bundle.c
@@ -107,7 +107,6 @@ struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
u8 class)
{
struct gb_bundle *bundle;
- int retval;
/*
* Reject any attempt to reuse a bundle id. We initialize
@@ -128,8 +127,6 @@ struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
bundle->class = class;
INIT_LIST_HEAD(&bundle->connections);
- /* Build up the bundle device structures and register it with the
- * driver core */
bundle->dev.parent = &intf->dev;
bundle->dev.bus = &greybus_bus_type;
bundle->dev.type = &greybus_bundle_type;
@@ -137,18 +134,24 @@ struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
device_initialize(&bundle->dev);
dev_set_name(&bundle->dev, "%s.%d", dev_name(&intf->dev), bundle_id);
- retval = device_add(&bundle->dev);
- if (retval) {
- pr_err("failed to add bundle device for id %u\n", bundle_id);
- put_device(&bundle->dev);
- return NULL;
- }
-
list_add(&bundle->links, &intf->bundles);
return bundle;
}
+int gb_bundle_add(struct gb_bundle *bundle)
+{
+ int ret;
+
+ ret = device_add(&bundle->dev);
+ if (ret) {
+ dev_err(&bundle->dev, "failed to register bundle: %d\n", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
static void gb_bundle_connections_exit(struct gb_bundle *bundle)
{
struct gb_connection *connection;
@@ -162,10 +165,12 @@ static void gb_bundle_connections_exit(struct gb_bundle *bundle)
*/
void gb_bundle_destroy(struct gb_bundle *bundle)
{
- list_del(&bundle->links);
-
gb_bundle_connections_exit(bundle);
- device_unregister(&bundle->dev);
-}
+ if (device_is_registered(&bundle->dev))
+ device_del(&bundle->dev);
+ list_del(&bundle->links);
+
+ put_device(&bundle->dev);
+}