From patchwork Sat Dec 23 10:53:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ognjen Galic X-Patchwork-Id: 10131487 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 7D3E060388 for ; Sat, 23 Dec 2017 10:53:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BBDC29A3C for ; Sat, 23 Dec 2017 10:53:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F37A29A48; Sat, 23 Dec 2017 10:53:56 +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=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 0064928E3C for ; Sat, 23 Dec 2017 10:53:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750820AbdLWKxy (ORCPT ); Sat, 23 Dec 2017 05:53:54 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:38765 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750805AbdLWKxx (ORCPT ); Sat, 23 Dec 2017 05:53:53 -0500 Received: by mail-wm0-f68.google.com with SMTP id 64so25505582wme.3; Sat, 23 Dec 2017 02:53:52 -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=iwJ29jCz1Y4Fo3qHH/uMZTPjt6W3ip6Ybz6cdUhok5U=; b=j3966f3TvSTyUMTRlwrU6iRQO/+qLaJhiJxwMyhvZyq6EDRZreCKt468/lOXzKbzY3 mMljVCHIvsrhGioVyariFBGFY+Guuaxitz8yzACJyRjiwsz9z8aqOTfgfySrYRZS4dwX OiuoFrcCwbSAD+3lbODIG07Hod39/fTwE6X7c5T8LyH0gDc+Yenhh86eBkeIyyzJhGuh 3CeFglE4FKX3sDRYVkjSQikZkh8S9PcBm9++RwN3RlmrxfahOESW7V2G2kr/41NxlVUc rsO7Mcnjz2VPWW9+shT8TFir62nmwc1lvNVy6++hIJnjsL7VWbWldmmjJJz6cWWDGmvN Df3Q== 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=iwJ29jCz1Y4Fo3qHH/uMZTPjt6W3ip6Ybz6cdUhok5U=; b=onw+oUGI3L7Ai7rmq3tm64JIvGR6Ol+fkzYiMQaKfVGyWHwVKKU08zFAfDINQM6xHD faZnvZQIwLeLGwJNp6c41ZdCQFQfDJckJWGYBaXc3KCo8KB8Bd8ApcxHFQYQLhSwizOx Do8QUtkNe4bugGD9IVD+BovkcgZMH2bPTWzA+6OCr5o1Va9R6zz3UfKOn/5YMHW75NJr 5vu6tTyU/qUJ6RIFEL611Uca1e6CXtgoOBuo8ovhHGjgXkIKmT0kzDfQBU68rYkJa1sw Q558GQQszcuWYhIdkcjkLuDxWiytmpXsL2FEIeU9CUkBRFybEVF1UnOgrR7JX3/JGbtm ykJA== X-Gm-Message-State: AKGB3mKNPVwakRQIo8EO6wYf0izDf6NQ8M2mamanYlyBhIjGP+rIQCLS YXUj3MKZQbBfQeIqJSpVTXw= X-Google-Smtp-Source: ACJfBoslrHlS2NaUpEhG5qa55udseXjDa3usRQF+aC0ZVyqoDRLzDGIjKwXKGIAsu0yDYm/nAjwtyQ== X-Received: by 10.28.147.84 with SMTP id v81mr15315640wmd.133.1514026432250; Sat, 23 Dec 2017 02:53:52 -0800 (PST) Received: from thinkpad (pppoe-46-239-10-236.teol.net. [46.239.10.236]) by smtp.gmail.com with ESMTPSA id 17sm12693183wmq.10.2017.12.23.02.53.51 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 23 Dec 2017 02:53:51 -0800 (PST) Date: Sat, 23 Dec 2017 11:53:50 +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 v10 4/4] battery: Add the ThinkPad "Not Charging" quirk Message-ID: <20171223105350.GA4390@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 v9: * No changes in this patch in v9 v10: * No changes in this patch in v10 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 c86b373..08ef103 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"), + }, + }, {}, };