From patchwork Thu Mar 16 16:16:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 9628869 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8385960244 for ; Thu, 16 Mar 2017 16:17:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74A17281C3 for ; Thu, 16 Mar 2017 16:17:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6858B283F9; Thu, 16 Mar 2017 16:17:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4A82281C3 for ; Thu, 16 Mar 2017 16:17:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754408AbdCPQRL (ORCPT ); Thu, 16 Mar 2017 12:17:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14727 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752357AbdCPQRK (ORCPT ); Thu, 16 Mar 2017 12:17:10 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 380B8811A7; Thu, 16 Mar 2017 16:16:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 380B8811A7 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=hdegoede@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 380B8811A7 Received: from shalem.localdomain.com (ovpn-117-127.ams2.redhat.com [10.36.117.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5D91627D9; Thu, 16 Mar 2017 16:16:09 +0000 (UTC) From: Hans de Goede To: "Rafael J . Wysocki" , Len Brown , Sebastian Reichel , Chen-Yu Tsai Cc: Hans de Goede , Andy Shevchenko , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH 3/4] power: supply: axp288_fuel_gauge: Unregister duplicate ACPI battery supply Date: Thu, 16 Mar 2017 17:16:00 +0100 Message-Id: <20170316161601.32267-4-hdegoede@redhat.com> In-Reply-To: <20170316161601.32267-1-hdegoede@redhat.com> References: <20170316161601.32267-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 16 Mar 2017 16:16:11 +0000 (UTC) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Tested-by: Sergei Trusov --- 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 d0453ca..e504644 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);