|
@@ -449,6 +449,29 @@ bool mei_cldev_enabled(struct mei_cl_device *cldev)
|
|
|
}
|
|
|
EXPORT_SYMBOL_GPL(mei_cldev_enabled);
|
|
|
|
|
|
+/**
|
|
|
+ * mei_cl_bus_module_get - acquire module of the underlying
|
|
|
+ * hw driver.
|
|
|
+ *
|
|
|
+ * @cldev: mei client device
|
|
|
+ *
|
|
|
+ * Return: true on success; false if the module was removed.
|
|
|
+ */
|
|
|
+static bool mei_cl_bus_module_get(struct mei_cl_device *cldev)
|
|
|
+{
|
|
|
+ return try_module_get(cldev->bus->dev->driver->owner);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * mei_cl_bus_module_put - release the underlying hw module.
|
|
|
+ *
|
|
|
+ * @cldev: mei client device
|
|
|
+ */
|
|
|
+static void mei_cl_bus_module_put(struct mei_cl_device *cldev)
|
|
|
+{
|
|
|
+ module_put(cldev->bus->dev->driver->owner);
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* mei_cldev_enable - enable me client device
|
|
|
* create connection with me client
|
|
@@ -487,9 +510,17 @@ int mei_cldev_enable(struct mei_cl_device *cldev)
|
|
|
goto out;
|
|
|
}
|
|
|
|
|
|
+ if (!mei_cl_bus_module_get(cldev)) {
|
|
|
+ dev_err(&cldev->dev, "get hw module failed");
|
|
|
+ ret = -ENODEV;
|
|
|
+ goto out;
|
|
|
+ }
|
|
|
+
|
|
|
ret = mei_cl_connect(cl, cldev->me_cl, NULL);
|
|
|
- if (ret < 0)
|
|
|
+ if (ret < 0) {
|
|
|
dev_err(&cldev->dev, "cannot connect\n");
|
|
|
+ mei_cl_bus_module_put(cldev);
|
|
|
+ }
|
|
|
|
|
|
out:
|
|
|
mutex_unlock(&bus->device_lock);
|
|
@@ -553,6 +584,8 @@ int mei_cldev_disable(struct mei_cl_device *cldev)
|
|
|
dev_err(bus->dev, "Could not disconnect from the ME client\n");
|
|
|
|
|
|
out:
|
|
|
+ mei_cl_bus_module_put(cldev);
|
|
|
+
|
|
|
/* Flush queues and remove any pending read */
|
|
|
mei_cl_flush_queues(cl, NULL);
|
|
|
mei_cl_unlink(cl);
|
|
@@ -562,37 +595,6 @@ out:
|
|
|
}
|
|
|
EXPORT_SYMBOL_GPL(mei_cldev_disable);
|
|
|
|
|
|
-/**
|
|
|
- * mei_cl_bus_module_get - acquire module of the underlying
|
|
|
- * hw module.
|
|
|
- *
|
|
|
- * @cl: host client
|
|
|
- *
|
|
|
- * Return: true on success; false if the module was removed.
|
|
|
- */
|
|
|
-bool mei_cl_bus_module_get(struct mei_cl *cl)
|
|
|
-{
|
|
|
- struct mei_cl_device *cldev = cl->cldev;
|
|
|
-
|
|
|
- if (!cldev)
|
|
|
- return true;
|
|
|
-
|
|
|
- return try_module_get(cldev->bus->dev->driver->owner);
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * mei_cl_bus_module_put - release the underlying hw module.
|
|
|
- *
|
|
|
- * @cl: host client
|
|
|
- */
|
|
|
-void mei_cl_bus_module_put(struct mei_cl *cl)
|
|
|
-{
|
|
|
- struct mei_cl_device *cldev = cl->cldev;
|
|
|
-
|
|
|
- if (cldev)
|
|
|
- module_put(cldev->bus->dev->driver->owner);
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* mei_cl_device_find - find matching entry in the driver id table
|
|
|
*
|