[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1095514c-f734-b7d5-4a6a-4ed230ecb03a@redhat.com>
Date: Mon, 19 Sep 2022 11:42:46 +0100
From: Hans de Goede <hdegoede@...hat.com>
To: Armin Wolf <W_Armin@....de>, markgross@...nel.org
Cc: rafael@...nel.org, lenb@...nel.org, hmh@....eng.br,
matan@...alib.org, corentin.chary@...il.com, jeremy@...tem76.com,
productdev@...tem76.com, platform-driver-x86@...r.kernel.org,
linux-acpi@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/5] ACPI: battery: Simplify battery_hook_unregister()
Hi,
On 9/12/22 13:53, Armin Wolf wrote:
> Since __battery_hook_unregister() is always called
> with lock set to 1, remove the unneeded conditionals
> and merge it with battery_hook_unregister().
>
> Signed-off-by: Armin Wolf <W_Armin@....de>
Thanks, patch looks good to me:
Reviewed-by: Hans de Goede <hdegoede@...hat.com>
Regards,
Hans
> ---
> drivers/acpi/battery.c | 17 ++++++-----------
> 1 file changed, 6 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index e59c261c7c59..4aea65f3d8c3 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -686,27 +686,22 @@ static LIST_HEAD(acpi_battery_list);
> static LIST_HEAD(battery_hook_list);
> static DEFINE_MUTEX(hook_mutex);
>
> -static void __battery_hook_unregister(struct acpi_battery_hook *hook, int lock)
> +void battery_hook_unregister(struct acpi_battery_hook *hook)
> {
> struct acpi_battery *battery;
> /*
> * In order to remove a hook, we first need to
> * de-register all the batteries that are registered.
> */
> - if (lock)
> - mutex_lock(&hook_mutex);
> + mutex_lock(&hook_mutex);
> +
> list_for_each_entry(battery, &acpi_battery_list, list) {
> hook->remove_battery(battery->bat);
> }
> list_del(&hook->list);
> - if (lock)
> - mutex_unlock(&hook_mutex);
> - pr_info("extension unregistered: %s\n", hook->name);
> -}
>
> -void battery_hook_unregister(struct acpi_battery_hook *hook)
> -{
> - __battery_hook_unregister(hook, 1);
> + mutex_unlock(&hook_mutex);
> + pr_info("extension unregistered: %s\n", hook->name);
> }
> EXPORT_SYMBOL_GPL(battery_hook_unregister);
>
> @@ -784,7 +779,7 @@ static void __exit battery_hook_exit(void)
> * need to remove the hooks.
> */
> list_for_each_entry_safe(hook, ptr, &battery_hook_list, list) {
> - __battery_hook_unregister(hook, 1);
> + battery_hook_unregister(hook);
> }
> mutex_destroy(&hook_mutex);
> }
> --
> 2.30.2
>
Powered by blists - more mailing lists