From patchwork Wed Dec 20 15:16:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ognjen Galic X-Patchwork-Id: 10125817 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 14B3460245 for ; Wed, 20 Dec 2017 15:16:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0748E28AB0 for ; Wed, 20 Dec 2017 15:16:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0469294E1; Wed, 20 Dec 2017 15:16:21 +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=-5.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB, 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 A6E2628AB0 for ; Wed, 20 Dec 2017 15:16:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755085AbdLTPQU (ORCPT ); Wed, 20 Dec 2017 10:16:20 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35622 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754664AbdLTPQT (ORCPT ); Wed, 20 Dec 2017 10:16:19 -0500 Received: by mail-wm0-f67.google.com with SMTP id f9so10468657wmh.0; Wed, 20 Dec 2017 07:16:18 -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=6oorTnjoFVv58TCMn0oldg6Rnq/DxbXGGoQqtom3yE0=; b=eu7pF6/ijrhXd1PTsFOleM9Eu/8p7GgHtKQsVbwNm7sgOwp6va3D7Uju6SC+0JawA1 /kZFJo2IzFTt2OmNq2EV1QwqReVM5VW9QfhkYEE2Y/IxShnH0CtX44OqTrg8hueg37Y6 ujCuwY6udfmU7i9gecYlR/kq0e5rB83tZPzoIqbG4jzNMtUH6YRV1I6ZitDVPdc8bt7w Nhg38Ewn8DlmMate2n4Td6Hz2BHBjSlv6vFLeJv7jULLLy0uWfnqIBdrYgJ0UN/ksL8P x9bdea4NO6vRdIzdxvYjyQjab6Fo9enkjp7Jmj570sEuLOdNXZcYhQL4YuVFmwPAiSAI fLcA== 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=6oorTnjoFVv58TCMn0oldg6Rnq/DxbXGGoQqtom3yE0=; b=E+sCH/iQq34DsdK6Sfhu/xwRM0WfzUH7g0hbdmhe9JFqKXHfIzInA/U1cOVL/uJROv C9MYvWW71eckYivNJTPxMPQskh86H5W0QVBtXXrYr2NTiNnQh8ucJV7XoAEycr0R0r0Z 270HRloTy+GD+fAUk3bAHhlTH6whk1SnDtt3dDxsq2kIHutgnK2MwfIu7daqPcnor4Ee BiJG5pVVuU3HexGD328eh2kujdShgC4Z4reUgnj+rYEiwcVJ+QtXyuurcyu8ZE3AlCVP Ixmi9K4rIE/h4RcFbw/Vw8qYTsG6eCcGt9fvb9vxRyBwaiekhORrjPq34UOZ4RxlIw4Z i95w== X-Gm-Message-State: AKGB3mLgj12dY5ONQpXuvUz/tXvZA0Xr1Oy5x1o3BeZCwpMkBB7Vfp4j +IBo1fgVvZ8ZEfDtGAVa9wA= X-Google-Smtp-Source: ACJfBovNVmn6/sygxTkk3KLYTunOJNvNp54iF88tuoEUD5z7DxmgAB9JGawpBOBWrEXTC89wWdIn/Q== X-Received: by 10.28.129.69 with SMTP id c66mr7338011wmd.29.1513782977757; Wed, 20 Dec 2017 07:16:17 -0800 (PST) Received: from thinkpad (51-143-241-92-stat.customer.blic.net. [92.241.143.51]) by smtp.gmail.com with ESMTPSA id e197sm15845173wmf.4.2017.12.20.07.16.16 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Dec 2017 07:16:16 -0800 (PST) Date: Wed, 20 Dec 2017 16:16:15 +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 v7] battery: Add the ThinkPad "Not Charging" quirk Message-ID: <20171220151615.GA12627@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 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 1794408..be47829 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; @@ -1336,6 +1339,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, @@ -1353,6 +1362,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"), + }, + }, {}, };