mei: bus: call device disable handler prior to disconnection
authorTomas Winkler <tomas.winkler@intel.com>
Tue, 10 Feb 2015 08:39:47 +0000 (10:39 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 2 Mar 2015 03:37:00 +0000 (19:37 -0800)
call device's disable handler prior to disconnection
so it can possibly close the communication with fw client
in graceful way

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/mei/bus.c

index 17ca7e20fb6adfa56d9be501c300fa3644782d22..45896f95fed11313fb0880f98d3a623f36352440 100644 (file)
@@ -467,37 +467,34 @@ int mei_cl_disable_device(struct mei_cl_device *device)
 
        dev = cl->dev;
 
+       if (device->ops && device->ops->disable)
+               device->ops->disable(device);
+
+       device->event_cb = NULL;
+
        mutex_lock(&dev->device_lock);
 
        if (cl->state != MEI_FILE_CONNECTED) {
-               mutex_unlock(&dev->device_lock);
                dev_err(dev->dev, "Already disconnected");
-
-               return 0;
+               err = 0;
+               goto out;
        }
 
        cl->state = MEI_FILE_DISCONNECTING;
 
        err = mei_cl_disconnect(cl);
        if (err < 0) {
-               mutex_unlock(&dev->device_lock);
-               dev_err(dev->dev,
-                       "Could not disconnect from the ME client");
-
-               return err;
+               dev_err(dev->dev, "Could not disconnect from the ME client");
+               goto out;
        }
 
        /* Flush queues and remove any pending read */
        mei_cl_flush_queues(cl, NULL);
 
-       device->event_cb = NULL;
-
+out:
        mutex_unlock(&dev->device_lock);
+       return err;
 
-       if (!device->ops || !device->ops->disable)
-               return 0;
-
-       return device->ops->disable(device);
 }
 EXPORT_SYMBOL_GPL(mei_cl_disable_device);