From: Johan Hovold Date: Wed, 20 Jul 2016 14:40:24 +0000 (+0200) Subject: greybus: interface: prevent reactivation during removal X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=12169bc9143ed24ad7a5ea12a7c28d1dba891131;p=linux-beck.git greybus: interface: prevent reactivation during removal 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 Signed-off-by: Johan Hovold Reviewed-by: Alex Elder Reviewed-by: Viresh Kumar Reviewed-by: Patrick Titiano Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/interface.c b/drivers/staging/greybus/interface.c index 01cefced7b69..3ad1c757d7e7 100644 --- a/drivers/staging/greybus/interface.c +++ b/drivers/staging/greybus/interface.c @@ -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); diff --git a/drivers/staging/greybus/interface.h b/drivers/staging/greybus/interface.h index f52dfd09bb16..daa9759149a5 100644 --- a/drivers/staging/greybus/interface.h +++ b/drivers/staging/greybus/interface.h @@ -53,6 +53,7 @@ struct gb_interface { bool disconnected; bool ejected; + bool removed; bool active; bool enabled; bool mode_switch; diff --git a/drivers/staging/greybus/module.c b/drivers/staging/greybus/module.c index d506fa0b3272..69f67ddbd4a3 100644 --- a/drivers/staging/greybus/module.c +++ b/drivers/staging/greybus/module.c @@ -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);