summaryrefslogtreecommitdiffstats
path: root/drivers/acpi/dock.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-06-30 23:47:14 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-07-15 01:33:11 +0200
commit4ec24065a65b4debfdeb591cc01a4aa092651f53 (patch)
treeaa21b3a9df792b568c0fef3b809e33b2232960c1 /drivers/acpi/dock.c
parent37f908778f20bbcc35ab9a98a5b584329c6abf08 (diff)
downloadop-kernel-dev-4ec24065a65b4debfdeb591cc01a4aa092651f53.zip
op-kernel-dev-4ec24065a65b4debfdeb591cc01a4aa092651f53.tar.gz
ACPI / dock: Simplify dock_init_hotplug() and dock_release_hotplug()
Make dock_init_hotplug() and dock_release_hotplug() slightly simpler and move some checks in those functions to the code paths where they are needed. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Yinghai Lu <yinghai@kernel.org>
Diffstat (limited to 'drivers/acpi/dock.c')
-rw-r--r--drivers/acpi/dock.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 41c5d04..b1170d6 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -130,19 +130,16 @@ static int dock_init_hotplug(struct dock_dependent_device *dd,
int ret = 0;
mutex_lock(&hotplug_lock);
-
- if (dd->hp_context) {
+ if (WARN_ON(dd->hp_context)) {
ret = -EEXIST;
} else {
dd->hp_refcount = 1;
dd->hp_ops = ops;
dd->hp_context = context;
dd->hp_release = release;
+ if (init)
+ init(context);
}
-
- if (!WARN_ON(ret) && init)
- init(context);
-
mutex_unlock(&hotplug_lock);
return ret;
}
@@ -157,22 +154,17 @@ static int dock_init_hotplug(struct dock_dependent_device *dd,
*/
static void dock_release_hotplug(struct dock_dependent_device *dd)
{
- void (*release)(void *) = NULL;
- void *context = NULL;
-
mutex_lock(&hotplug_lock);
-
if (dd->hp_context && !--dd->hp_refcount) {
+ void (*release)(void *) = dd->hp_release;
+ void *context = dd->hp_context;
+
dd->hp_ops = NULL;
- context = dd->hp_context;
dd->hp_context = NULL;
- release = dd->hp_release;
dd->hp_release = NULL;
+ if (release)
+ release(context);
}
-
- if (release && context)
- release(context);
-
mutex_unlock(&hotplug_lock);
}
OpenPOWER on IntegriCloud