[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAE9FiQVg+OyztG_W43BHWm4Xhxsh42rS-h+-_pNoma1i5yCZog@mail.gmail.com>
Date: Fri, 28 Jun 2013 13:16:29 -0700
From: Yinghai Lu <yinghai@...nel.org>
To: "Rafael J. Wysocki" <rjw@...k.pl>
Cc: ACPI Devel Maling List <linux-acpi@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Jiang Liu <liuj97@...il.com>,
"Alexander E. Patrakov" <patrakov@...il.com>
Subject: Re: [PATCH 4/4] ACPI / dock: Simplify dock_init_hotplug() and dock_release_hotplug()
On Fri, Jun 28, 2013 at 12:48 PM, Rafael J. Wysocki <rjw@...k.pl> wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@...el.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@...el.com>
Acked-by: Yinghai Lu <yinghai@...nel.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);
> }
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists