summaryrefslogtreecommitdiff
path: root/drivers/misc/mei/bus.c
diff options
context:
space:
mode:
authorAlexander Usyskin <alexander.usyskin@intel.com>2017-01-27 17:32:39 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-01-31 13:07:43 +0300
commit5d88246090c5e9b178eb05bcfb52bbaad2ae48f3 (patch)
tree35fba5dcc29e9a348d925ab900e2b69ee1346f69 /drivers/misc/mei/bus.c
parent9ecb839f16a353e71175981a098842fda4ddc7f1 (diff)
downloadlinux-5d88246090c5e9b178eb05bcfb52bbaad2ae48f3.tar.xz
mei: bus: prevent hardware module unload if device on bus is active
The hardware module should not be unloaded if the bus has active devices. Get get_/put_ bus parent module upon client device connection/disconnection, to prevent the hardware managing module to disappear underneath. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/mei/bus.c')
-rw-r--r--drivers/misc/mei/bus.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 3bb1f1500f6b..b67f15b53067 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -542,6 +542,37 @@ 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
*
* @cldev: me client device