greybus: interface: prevent reactivation during removal
authorJohan Hovold <johan@hovoldconsulting.com>
Wed, 20 Jul 2016 14:40:24 +0000 (16:40 +0200)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 20 Jul 2016 17:16:54 +0000 (10:16 -0700)
Make sure to prevent an interface that is going away from being
reactivated.

This is needed to preemptively close a race between the upcoming feature
to reactivate a powered-down interface and physical removal (i.e.
module_removed event processing) as well as logical removal (e.g. the
current system-suspend hack).

Reviewed-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Patrick Titiano <ptitiano@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/interface.c
drivers/staging/greybus/interface.h
drivers/staging/greybus/module.c

index 01cefce..3ad1c75 100644 (file)
@@ -873,7 +873,7 @@ static int _gb_interface_activate(struct gb_interface *intf,
 
        *type = GB_INTERFACE_TYPE_UNKNOWN;
 
-       if (intf->ejected)
+       if (intf->ejected || intf->removed)
                return -ENODEV;
 
        ret = gb_interface_vsys_set(intf, true);
index f52dfd0..daa9759 100644 (file)
@@ -53,6 +53,7 @@ struct gb_interface {
        bool disconnected;
 
        bool ejected;
+       bool removed;
        bool active;
        bool enabled;
        bool mode_switch;
index d506fa0..69f67dd 100644 (file)
@@ -186,6 +186,7 @@ static void gb_module_deregister_interface(struct gb_interface *intf)
                intf->disconnected = true;
 
        mutex_lock(&intf->mutex);
+       intf->removed = true;
        gb_interface_disable(intf);
        gb_interface_deactivate(intf);
        mutex_unlock(&intf->mutex);