From patchwork Fri Apr 7 10:43:44 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: 9669227 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 10DC8602B3 for ; Fri, 7 Apr 2017 10:43:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0128628249 for ; Fri, 7 Apr 2017 10:43:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA69828600; Fri, 7 Apr 2017 10:43:55 +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 9BB3F28249 for ; Fri, 7 Apr 2017 10:43:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755252AbdDGKny (ORCPT ); Fri, 7 Apr 2017 06:43:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56330 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754933AbdDGKny (ORCPT ); Fri, 7 Apr 2017 06:43:54 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A0499C04B93A; Fri, 7 Apr 2017 10:43:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A0499C04B93A Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=hdegoede@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A0499C04B93A Received: from shalem.localdomain.com (ovpn-116-210.ams2.redhat.com [10.36.116.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90A2F189CB; Fri, 7 Apr 2017 10:43:51 +0000 (UTC) From: Hans de Goede To: "Rafael J . Wysocki" , Len Brown , Mika Westerberg , Sebastian Reichel Cc: Hans de Goede , Andy Shevchenko , Lukas Wunner , Robert Moore , linux-acpi@vger.kernel.org, Chen-Yu Tsai , linux-pm@vger.kernel.org Subject: [PATCH v2 3/4] ACPI: battery: Add a blacklist with PMIC ACPI HIDs with a native battery driver Date: Fri, 7 Apr 2017 12:43:44 +0200 Message-Id: <20170407104345.27042-3-hdegoede@redhat.com> In-Reply-To: <20170407104345.27042-1-hdegoede@redhat.com> References: <20170407104345.27042-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 07 Apr 2017 10:43:53 +0000 (UTC) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On some systems we have a native PMIC driver which provides battery monitoring, while the ACPI battery driver is broken on these systems due to bad DSDTs or because we do not support the proprietary and undocumented ACPI opregions these ACPI battery devices rely on (e.g. BMOP opregion). 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 Even if the ACPI battery where to function fine (which on systems where we have a native PMIC driver it often doesn't) we still do not want to export the same battery to userspace twice. This commit adds a blacklist with PMIC ACPI HIDs for which we've a native battery driver and makes the ACPI battery driver not register itself when a PMIC on this list is present. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=194811 Signed-off-by: Hans de Goede --- Changes in v2: -This is a new patch in v2 of this patch-set replacing: "ACPI: battery: Add acpi_battery_unregister() function" "power: supply: axp288_fuel_gauge: Unregister duplicate ACPI battery supply" --- drivers/acpi/battery.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index b35fca4..eacb816 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -94,6 +94,12 @@ static const struct acpi_device_id battery_device_ids[] = { MODULE_DEVICE_TABLE(acpi, battery_device_ids); +/* Lists of PMIC ACPI HIDs with an (often better) native battery driver */ +static const char * const acpi_battery_blacklist[] = { + "INT33F4", /* X-Powers AXP288 PMIC */ + NULL +}; + enum { ACPI_BATTERY_ALARM_PRESENT, ACPI_BATTERY_XINFO_PRESENT, @@ -1316,7 +1322,15 @@ static struct acpi_driver acpi_battery_driver = { static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie) { - int result; + int i, result; + + for (i = 0; acpi_battery_blacklist[i]; i++) + if (acpi_dev_present(acpi_battery_blacklist[i], "1", -1)) { + pr_info("ACPI: %s: found native %s PMIC, not loading\n", + ACPI_BATTERY_DEVICE_NAME, + acpi_battery_blacklist[i]); + return; + } dmi_check_system(bat_dmi_table);