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@xxxxxx> Thanks, patch looks good to me: Reviewed-by: Hans de Goede <hdegoede@xxxxxxxxxx> 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 >