From patchwork Thu Dec 21 10:01:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ognjen Galic X-Patchwork-Id: 10127263 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 4D6AA6019C for ; Thu, 21 Dec 2017 10:01:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EE8429599 for ; Thu, 21 Dec 2017 10:01:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43ADF29B8C; Thu, 21 Dec 2017 10:01:58 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 EC40229599 for ; Thu, 21 Dec 2017 10:01:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752006AbdLUKB4 (ORCPT ); Thu, 21 Dec 2017 05:01:56 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:37898 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752101AbdLUKBX (ORCPT ); Thu, 21 Dec 2017 05:01:23 -0500 Received: by mail-wr0-f193.google.com with SMTP id o2so24665891wro.5; Thu, 21 Dec 2017 02:01:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=og557vGhFc1ivPZoGApvGGL6c85KXwG2yp2OXmyUUiE=; b=kEFvUybQQy3yZuox0hS3YiTSP0i7U53jq761v0RJFpVE1MOy06lyBd12Mew7hbye2Q 4eTMOroO/BJmDj2RgrwvevEIfgRVUkgqdm35D/4sjmO4cCpS7CveU3HFv6cy6sR/ZCXz R7/K85elDMZ19R0T/F5o4nn26zu8zPWGXUiwy63UjgrGnox4aW4dM7RFA1or/Wzgiy8k dHflJBMBZo8PkykcbvsU9rHDTUubDzFhotcU34phW6eqBhHfTU1+NR7Ahsu1gLv4Y+I8 OkG3jqr+b8xeCw9k2hJYFDPZpA0n6V2zfrGCUz1kpPCOGZKrz6ylZN6kpbMWvye5XCqS VHVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=og557vGhFc1ivPZoGApvGGL6c85KXwG2yp2OXmyUUiE=; b=eXKRGnsZNekGV7uK2vhuJ9pjzMVlUNhZkeJvHOEqJwTiuHuvCw6N4bjBc/iNj4LX5L pV506/PcTkMbY23994RIoVopyhV+ADCZ1M97XKmFKRiwtK86ka9iBnmXnVVGhWkvaR7g OjcAN61JgvqhWc4lkP6FlGtncMBqpiY3u+O5dyT3ylVlL8yh8B5g4//lfQVaXnl4KBsV SkMHGUW4P4ufcEIyVx7Y71+IS7i916JWacKnTzipgXeVc+s48dNNb1cChdC5fcY3yTOk nooa+NOhwUoL7HH0l+uBB+MYz5cBerqbrUitP7Gs4OYx1kStu1kWkV+fqAPSYoWPMWZ+ 19HQ== X-Gm-Message-State: AKGB3mIXjKn2g8T20UVFq9VMQo0ZqVDd4IQjyzlINnaUtv0ty75TtG+m CFCAIzCzPAWgGThHIax1aEA= X-Google-Smtp-Source: ACJfBotk32FKorulXYYZRGvpBKdVrSzxrQ74pmr6muykUd934OVu2iN93CG5THEQA8ryR1ZV3o15ug== X-Received: by 10.223.172.205 with SMTP id o71mr11377177wrc.197.1513850481856; Thu, 21 Dec 2017 02:01:21 -0800 (PST) Received: from thinkpad (pppoe-46-239-10-167.teol.net. [46.239.10.167]) by smtp.gmail.com with ESMTPSA id r3sm5070393wmg.31.2017.12.21.02.01.20 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Dec 2017 02:01:20 -0800 (PST) Date: Thu, 21 Dec 2017 11:01:20 +0100 From: Ognjen Galic To: Andy Shevchenko , "Rafael J. Wysocki" , Ognjen =?utf-8?B?R2FsacSH?= , "Rafael J. Wysocki" , Len Brown , Robert Moore , Lv Zheng , ACPI Devel Maling List , devel@acpica.org, Darren Hart , Andy Shevchenko , Henrique de Moraes Holschuh , Sebastian Reichel , Platform Driver , ibm-acpi-devel@lists.sourceforge.net, Linux PM , Christoph =?iso-8859-1?Q?B=F6hmwalder?= , Kevin Locke Subject: [PATCH 3/3 v8] battery: Add the ThinkPad "Not Charging" quirk Message-ID: <20171221100120.GA30669@thinkpad> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) 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 The EC/ACPI firmware on Lenovo ThinkPads used to report a status of "Unknown" when the battery is between the charge start and charge stop thresholds. On Windows, it reports "Not Charging" so the quirk has been added to also report correctly. Now the "status" attribute returns "Not Charging" when the battery on ThinkPads is not physicaly charging. v7: * Added all the style changes as suggested by Rafael * Re-ordered the series to make this a post-implement bugfix v8: * No changes in this patch in v8 Signed-off-by: Ognjen Galic --- drivers/acpi/battery.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index da56c3a..d07da7f 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -72,6 +72,7 @@ static async_cookie_t async_cookie; static bool battery_driver_registered; static int battery_bix_broken_package; static int battery_notification_delay_ms; +static int battery_quirk_notcharging; static unsigned int cache_time = 1000; module_param(cache_time, uint, 0644); MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); @@ -223,6 +224,8 @@ static int acpi_battery_get_property(struct power_supply *psy, val->intval = POWER_SUPPLY_STATUS_CHARGING; else if (acpi_battery_is_charged(battery)) val->intval = POWER_SUPPLY_STATUS_FULL; + else if (battery_quirk_notcharging) + val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; else val->intval = POWER_SUPPLY_STATUS_UNKNOWN; break; @@ -1337,6 +1340,12 @@ battery_notification_delay_quirk(const struct dmi_system_id *d) return 0; } +static int __init battery_quirk_not_charging(const struct dmi_system_id *d) +{ + battery_quirk_notcharging = 1; + return 0; +} + static const struct dmi_system_id bat_dmi_table[] __initconst = { { .callback = battery_bix_broken_package_quirk, @@ -1354,6 +1363,19 @@ static const struct dmi_system_id bat_dmi_table[] __initconst = { DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-573G"), }, }, + { + /* + * On Lenovo ThinkPads the BIOS specification defines + * a state when the bits for charging and discharging + * are both set to 0. That state is "Not Charging". + */ + .callback = battery_quirk_not_charging, + .ident = "Lenovo ThinkPad", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad"), + }, + }, {}, };