]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
greybus: interface: fix timesync registration sequencing
authorDavid Lin <dtwlin@google.com>
Fri, 5 Aug 2016 22:08:40 +0000 (15:08 -0700)
committerGreg Kroah-Hartman <gregkh@google.com>
Sat, 6 Aug 2016 09:08:48 +0000 (11:08 +0200)
When enabling an interface, control device should be registered after
having successfully added the timesync. Similarly for the interface
disable path, control device should be removed first before removing
timesync.

Testing Done:
 - Enable and disable the interface

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Suggested-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: David Lin <dtwlin@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/interface.c

index 76569f8b086e01d2e8b72cfa8e0b4f781aa8c4c1..c3ed3d7dee9999ea85fdc213520d2a63d50f27c5 100644 (file)
@@ -1152,17 +1152,17 @@ int gb_interface_enable(struct gb_interface *intf)
        if (ret)
                goto err_destroy_bundles;
 
-       /* Register the control device and any bundles */
-       ret = gb_control_add(intf->control);
-       if (ret)
-               goto err_destroy_bundles;
-
        ret = gb_timesync_interface_add(intf);
        if (ret) {
                dev_err(&intf->dev, "failed to add to timesync: %d\n", ret);
-               goto err_del_control;
+               goto err_destroy_bundles;
        }
 
+       /* Register the control device and any bundles */
+       ret = gb_control_add(intf->control);
+       if (ret)
+               goto err_remove_timesync;
+
        pm_runtime_use_autosuspend(&intf->dev);
        pm_runtime_get_noresume(&intf->dev);
        pm_runtime_set_active(&intf->dev);
@@ -1186,8 +1186,8 @@ int gb_interface_enable(struct gb_interface *intf)
 
        return 0;
 
-err_del_control:
-       gb_control_del(intf->control);
+err_remove_timesync:
+       gb_timesync_interface_remove(intf);
 err_destroy_bundles:
        list_for_each_entry_safe(bundle, tmp, &intf->bundles, links)
                gb_bundle_destroy(bundle);
@@ -1229,8 +1229,8 @@ void gb_interface_disable(struct gb_interface *intf)
        if (!intf->mode_switch && !intf->disconnected)
                gb_control_interface_deactivate_prepare(intf->control);
 
-       gb_timesync_interface_remove(intf);
        gb_control_del(intf->control);
+       gb_timesync_interface_remove(intf);
        gb_control_disable(intf->control);
        gb_control_put(intf->control);
        intf->control = NULL;