lkml.org 
[lkml]   [2013]   [Jun]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 4/4] ACPI / dock: Simplify dock_init_hotplug() and dock_release_hotplug()
From
On Fri, Jun 28, 2013 at 12:48 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> 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>
> ---
> drivers/acpi/dock.c | 24 ++++++++----------------
> 1 file changed, 8 insertions(+), 16 deletions(-)
>
> Index: linux-pm/drivers/acpi/dock.c
> ===================================================================
> --- linux-pm.orig/drivers/acpi/dock.c
> +++ linux-pm/drivers/acpi/dock.c
> @@ -134,19 +134,16 @@ static int dock_init_hotplug(struct dock
> 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;
> }
> @@ -161,22 +158,17 @@ static int dock_init_hotplug(struct dock
> */
> 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);
> }
>
>


\
 
 \ /
  Last update: 2013-06-29 00:21    [W:0.307 / U:0.428 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site