From 62eaeb625024b85d004404d9d5d16a63e597c5c8 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 11 Mar 2017 11:07:08 +0100 Subject: [PATCH 2/2] power: supply: axp288_fuel_gauge: Unregister duplicate acpi battery supply On some systems with axp288 pmic the dsdt also exports an acpi battery device (PNP0C0A device). This leads to there being 2 battery power_supply-s registed like this: ~$ acpi Battery 0: Charging, 84%, 00:49:39 until charged Battery 1: Unknown, 0%, rate information unavailable Note that the ACPI battery device does not work properly this is due to Linux missing support for the vendor specific BMOP acpi opregion. But even if the acpi battery where to function fine we still do not want to export the same battery to userspace twice. Therefor this commit calls acpi_battery_unregister() after successfully registering the axp288-fuel-gauge power_supply to remove the duplicate (and often broken) acpi battery power_supply. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=194811 Signed-off-by: Hans de Goede --- drivers/power/supply/Kconfig | 2 ++ drivers/power/supply/axp288_fuel_gauge.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index b02b46b..6f5826e 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -242,6 +242,8 @@ config AXP288_CHARGER config AXP288_FUEL_GAUGE tristate "X-Powers AXP288 Fuel Gauge" depends on MFD_AXP20X && IIO + # if ACPI_BATTERY=m, this can't be 'y' + depends on ACPI_BATTERY || !ACPI_BATTERY help Say yes here to have support for X-Power power management IC (PMIC) Fuel Gauge. The device provides battery statistics and status diff --git a/drivers/power/supply/axp288_fuel_gauge.c b/drivers/power/supply/axp288_fuel_gauge.c index a8dcabc..15f10ce 100644 --- a/drivers/power/supply/axp288_fuel_gauge.c +++ b/drivers/power/supply/axp288_fuel_gauge.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -754,6 +755,8 @@ static int axp288_fuel_gauge_probe(struct platform_device *pdev) return ret; } + acpi_battery_unregister(); + fuel_gauge_create_debugfs(info); fuel_gauge_init_irq(info); schedule_delayed_work(&info->status_monitor, STATUS_MON_DELAY_JIFFIES); -- 2.9.3