Skip to content

Commit 3be5c17

Browse files
committed
Merge branches 'acpi-video' and 'acpi-battery'
Merge an ACPI backlight (video) quirk and ACPI battery driver fix and cleanup for 6.12-rc2: - Add a quirk for Dell OptiPlex 5480 AIO to the ACPI backlight (video) driver (Hans de Goede). - Prevent the ACPI battery driver from crashing when unregistering a battery hook and simplify battery hook locking in it (Armin Wolf). * acpi-video: ACPI: video: Add backlight=native quirk for Dell OptiPlex 5480 AIO * acpi-battery: ACPI: battery: Fix possible crash when unregistering a battery hook ACPI: battery: Simplify battery hook locking
3 parents 056301e + ac78288 + 76959af commit 3be5c17

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

drivers/acpi/battery.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -703,28 +703,35 @@ static LIST_HEAD(acpi_battery_list);
703703
static LIST_HEAD(battery_hook_list);
704704
static DEFINE_MUTEX(hook_mutex);
705705

706-
static void __battery_hook_unregister(struct acpi_battery_hook *hook, int lock)
706+
static void battery_hook_unregister_unlocked(struct acpi_battery_hook *hook)
707707
{
708708
struct acpi_battery *battery;
709+
709710
/*
710711
* In order to remove a hook, we first need to
711712
* de-register all the batteries that are registered.
712713
*/
713-
if (lock)
714-
mutex_lock(&hook_mutex);
715714
list_for_each_entry(battery, &acpi_battery_list, list) {
716715
if (!hook->remove_battery(battery->bat, hook))
717716
power_supply_changed(battery->bat);
718717
}
719-
list_del(&hook->list);
720-
if (lock)
721-
mutex_unlock(&hook_mutex);
718+
list_del_init(&hook->list);
719+
722720
pr_info("extension unregistered: %s\n", hook->name);
723721
}
724722

725723
void battery_hook_unregister(struct acpi_battery_hook *hook)
726724
{
727-
__battery_hook_unregister(hook, 1);
725+
mutex_lock(&hook_mutex);
726+
/*
727+
* Ignore already unregistered battery hooks. This might happen
728+
* if a battery hook was previously unloaded due to an error when
729+
* adding a new battery.
730+
*/
731+
if (!list_empty(&hook->list))
732+
battery_hook_unregister_unlocked(hook);
733+
734+
mutex_unlock(&hook_mutex);
728735
}
729736
EXPORT_SYMBOL_GPL(battery_hook_unregister);
730737

@@ -733,7 +740,6 @@ void battery_hook_register(struct acpi_battery_hook *hook)
733740
struct acpi_battery *battery;
734741

735742
mutex_lock(&hook_mutex);
736-
INIT_LIST_HEAD(&hook->list);
737743
list_add(&hook->list, &battery_hook_list);
738744
/*
739745
* Now that the driver is registered, we need
@@ -750,7 +756,7 @@ void battery_hook_register(struct acpi_battery_hook *hook)
750756
* hooks.
751757
*/
752758
pr_err("extension failed to load: %s", hook->name);
753-
__battery_hook_unregister(hook, 0);
759+
battery_hook_unregister_unlocked(hook);
754760
goto end;
755761
}
756762

@@ -804,7 +810,7 @@ static void battery_hook_add_battery(struct acpi_battery *battery)
804810
*/
805811
pr_err("error in extension, unloading: %s",
806812
hook_node->name);
807-
__battery_hook_unregister(hook_node, 0);
813+
battery_hook_unregister_unlocked(hook_node);
808814
}
809815
}
810816
mutex_unlock(&hook_mutex);
@@ -837,7 +843,7 @@ static void __exit battery_hook_exit(void)
837843
* need to remove the hooks.
838844
*/
839845
list_for_each_entry_safe(hook, ptr, &battery_hook_list, list) {
840-
__battery_hook_unregister(hook, 1);
846+
battery_hook_unregister(hook);
841847
}
842848
mutex_destroy(&hook_mutex);
843849
}

drivers/acpi/video_detect.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,15 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
844844
* controller board in their ACPI tables (and may even have one), but
845845
* which need native backlight control nevertheless.
846846
*/
847+
{
848+
/* https://github.com/zabbly/linux/issues/26 */
849+
.callback = video_detect_force_native,
850+
/* Dell OptiPlex 5480 AIO */
851+
.matches = {
852+
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
853+
DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 5480 AIO"),
854+
},
855+
},
847856
{
848857
/* https://bugzilla.redhat.com/show_bug.cgi?id=2303936 */
849858
.callback = video_detect_force_native,

0 commit comments

Comments
 (0)