linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Armin Wolf <W_Armin@gmx.de>, markgross@kernel.org
Cc: rafael@kernel.org, lenb@kernel.org, hmh@hmh.eng.br,
	matan@svgalib.org, corentin.chary@gmail.com, jeremy@system76.com,
	productdev@system76.com, platform-driver-x86@vger.kernel.org,
	linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/5] ACPI: battery: Simplify battery_hook_unregister()
Date: Mon, 19 Sep 2022 11:42:46 +0100	[thread overview]
Message-ID: <1095514c-f734-b7d5-4a6a-4ed230ecb03a@redhat.com> (raw)
In-Reply-To: <20220912125342.7395-3-W_Armin@gmx.de>

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@gmx.de>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.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
> 


  reply	other threads:[~2022-09-19 10:50 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-12 12:53 [PATCH 0/5] platform/x86: dell: Add new dell-wmi-ddv driver Armin Wolf
2022-09-12 12:53 ` [PATCH 1/5] ACPI: battery: Do not unload battery hooks on single error Armin Wolf
2022-09-19 10:42   ` Hans de Goede
2022-09-19 16:27     ` Rafael J. Wysocki
2022-09-19 19:12       ` Armin Wolf
2022-09-19 20:35         ` Armin Wolf
2022-09-27 14:29           ` Hans de Goede
2022-09-27 15:44             ` Armin Wolf
2022-09-12 12:53 ` [PATCH 2/5] ACPI: battery: Simplify battery_hook_unregister() Armin Wolf
2022-09-19 10:42   ` Hans de Goede [this message]
2022-09-12 12:53 ` [PATCH 3/5] ACPI: battery: Allow battery hooks to be registered multiple times Armin Wolf
2022-09-12 16:42   ` Barnabás Pőcze
2022-09-12 17:29     ` Armin Wolf
2022-09-19 11:18       ` Hans de Goede
2022-09-19 17:42       ` Barnabás Pőcze
2022-09-12 12:53 ` [PATCH 4/5] ACPI: battery: Allow for passing data to battery hooks Armin Wolf
2022-09-19 11:08   ` Hans de Goede
2022-09-12 12:53 ` [PATCH 5/5] platform/x86: dell: Add new dell-wmi-ddv driver Armin Wolf
2022-09-12 21:56   ` Randy Dunlap
2022-09-13 14:40     ` Armin Wolf
2022-09-13 16:08       ` Limonciello, Mario
2022-09-13 16:45         ` Armin Wolf
2022-09-13 18:27         ` Randy Dunlap
2022-09-13 18:30           ` Limonciello, Mario
2022-09-13 18:37             ` Randy Dunlap
2022-09-19 11:33   ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1095514c-f734-b7d5-4a6a-4ed230ecb03a@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=W_Armin@gmx.de \
    --cc=corentin.chary@gmail.com \
    --cc=hmh@hmh.eng.br \
    --cc=jeremy@system76.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markgross@kernel.org \
    --cc=matan@svgalib.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=productdev@system76.com \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).