lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 12 Sep 2022 14:53:39 +0200
From:   Armin Wolf <W_Armin@....de>
To:     hdegoede@...hat.com, 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: [PATCH 2/5] ACPI: battery: Simplify battery_hook_unregister()

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>
---
 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