greybus: interface: register control device at hotplug
authorJohan Hovold <johan@hovoldconsulting.com>
Wed, 13 Apr 2016 17:19:03 +0000 (19:19 +0200)
committerGreg Kroah-Hartman <gregkh@google.com>
Thu, 21 Apr 2016 01:06:00 +0000 (10:06 +0900)
Make sure to register also the control device along with any bundles
when registering an interface.

Note that we currently ignore failures to register the control device
just as we do for bundle devices.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/control.c
drivers/staging/greybus/control.h
drivers/staging/greybus/interface.c

index c303bb2937bce94e5c8b4e8c2b4cad9fe3465c61..6063619064824e62d0ac716f7ab2979d0fc5af46 100644 (file)
@@ -294,6 +294,27 @@ void gb_control_disable(struct gb_control *control)
        gb_connection_disable(control->connection);
 }
 
+int gb_control_add(struct gb_control *control)
+{
+       int ret;
+
+       ret = device_add(&control->dev);
+       if (ret) {
+               dev_err(&control->dev,
+                               "failed to register control device: %d\n",
+                               ret);
+               return ret;
+       }
+
+       return 0;
+}
+
+void gb_control_del(struct gb_control *control)
+{
+       if (device_is_registered(&control->dev))
+               device_del(&control->dev);
+}
+
 void gb_control_put(struct gb_control *control)
 {
        put_device(&control->dev);
index 697f901b34a797026842dccaf7b231f60fabdc16..102e937a982c47d3a224e9375bed058da7328af9 100644 (file)
@@ -26,6 +26,8 @@ struct gb_control {
 struct gb_control *gb_control_create(struct gb_interface *intf);
 int gb_control_enable(struct gb_control *control);
 void gb_control_disable(struct gb_control *control);
+int gb_control_add(struct gb_control *control);
+void gb_control_del(struct gb_control *control);
 void gb_control_put(struct gb_control *control);
 
 int gb_control_get_bundle_versions(struct gb_control *control);
index 56a320732ef9ca7ce5e78cfa0b4585ccb7029c2c..e0e08731c05531fcba704faad921413d247f664c 100644 (file)
@@ -537,6 +537,7 @@ void gb_interface_disable(struct gb_interface *intf)
        list_for_each_entry_safe(bundle, next, &intf->bundles, links)
                gb_bundle_destroy(bundle);
 
+       gb_control_del(intf->control);
        gb_control_disable(intf->control);
 }
 
@@ -557,6 +558,9 @@ int gb_interface_add(struct gb_interface *intf)
        dev_info(&intf->dev, "DDBL1 Manufacturer=0x%08x, Product=0x%08x\n",
                 intf->ddbl1_manufacturer_id, intf->ddbl1_product_id);
 
+       /* NOTE: ignoring errors for now */
+       gb_control_add(intf->control);
+
        list_for_each_entry_safe_reverse(bundle, tmp, &intf->bundles, links) {
                ret = gb_bundle_add(bundle);
                if (ret) {