OSDN Git Service

ACPI / x86: Introduce an acpi_quirk_skip_acpi_ac_and_battery() helper
authorHans de Goede <hdegoede@redhat.com>
Thu, 30 Dec 2021 19:31:19 +0000 (20:31 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 4 Jan 2022 14:40:48 +0000 (15:40 +0100)
commit57a18322227134e37b693ef8ef216ed7ce7ba7d6
treef4ac9b0fdd8e673a4670178c4ba4a0aed095f4c9
parent8e0feb25172b51978b9240aea1f0628c5b45b5b1
ACPI / x86: Introduce an acpi_quirk_skip_acpi_ac_and_battery() helper

Some x86 ACPI boards have broken AC and battery ACPI devices in their ACPI
tables. This is often tied to these devices using certain PMICs where the
factory OS image seems to be using native charger and fuel-gauge drivers
instead.

So far both the AC and battery drivers have almost identical checks for
these PMICs including both of them having a DMI based mechanism to force
usage of the ACPI AC and battery drivers on some boards even though one
of these PMICs is present, with the same 2 boards listed in both driver's
DMI tables for this.

The only difference is that the AC driver checks for 2 PMICs and the
battery driver only for one. This has grown this way because the other
(Whiskey Cove) PMIC is only used on a few boards (3 known boards) and
although some of these do have non working ACPI battery devices, their
_STA method always returns 0, but that really should not be relied on.

This patch factors out the shared checks into a new
acpi_quirk_skip_acpi_ac_and_battery() helper and moves the AC and
battery drivers over to this new helper.

Note the DMI table is shared with acpi_quirk_skip_i2c_client_enumeration()
and acpi_quirk_skip_serdev_enumeration(), because boards needing DMI quirks
for either of these typically also have broken AC and battery ACPI devices.

The ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY quirk is not set yet on boards
already in this DMI table, to avoid introducing any functional changes
in this refactoring patch.

Besided sharing the code between the AC and battery drivers this
refactoring also moves this quirk handling to under #ifdef CONFIG_X86,
removing this x86 specific code from non x86 ACPI builds.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/ac.c
drivers/acpi/battery.c
drivers/acpi/x86/utils.c
include/acpi/acpi_bus.h