From patchwork Sun Dec 31 14:17:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ognjen Galic X-Patchwork-Id: 10138191 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 81448605B4 for ; Sun, 31 Dec 2017 14:17:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EA6728553 for ; Sun, 31 Dec 2017 14:17:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62124287E3; Sun, 31 Dec 2017 14:17:51 +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 17A6728844 for ; Sun, 31 Dec 2017 14:17:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751013AbdLaORu (ORCPT ); Sun, 31 Dec 2017 09:17:50 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:44484 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750945AbdLaORs (ORCPT ); Sun, 31 Dec 2017 09:17:48 -0500 Received: by mail-wm0-f67.google.com with SMTP id t8so54811789wmc.3; Sun, 31 Dec 2017 06:17:48 -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=4eXcc7rUXktmzp0TK3iHTGP5TU2B85gd6m5Zfdr5CHM=; b=e7OXVJZsts9FZ2daki5XsI/jZtDpY8smmWWlVDCFCPqLdulp9CNpci2fTKcVzxizun 2l4OST4hYIw1lLuUdtZrOGWSdv3nc6AnBlhCm9UQSYoMwi8WEAR4cgkM2erXXvd4I3rU 6k/45xvs56TCxdJtyxDro28RZfVI8iLgbOl87O6oJO2JeIBKRpZfgMxAo2FNdQgX7uV3 c7zd7q6HepIaD6GJknb3Ear7JfW8FQC49xPnYH7o5C5ZMpEVE3J0mZXJbHCj8A9ZBcvx qdXVheO1vLJZy1mWWDSLAlS2+GD7XDctrtx8lHP6MFSqHZtB2yBkBiNXhl8uYOAaXoUB s8jQ== 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=4eXcc7rUXktmzp0TK3iHTGP5TU2B85gd6m5Zfdr5CHM=; b=mIJNbpNTbJudniBMsG7lVC6YWVIfcUx8rnflbo4uS6xblorKjtq+/EZx2Jyso4P9Lw 0Ykh21zDjfr8jyzOdkX++GGHldg11t+pXWlp1r5nho14JKbvEUMftUhWin83W7EiVXZi 29fZwlWWlCJ7MJXLwd9iTSF4RQtOkVunN3o+jdmoKJd0YTMahtcn0m4z2XQtZiswRspA Rwuqd8vdMJ2s2tjDKQUz1n/7bFB3XC71+LvG35ao2RdrS2bgubC+b/gbBrW+UVYvS1gl utHoUdhgm5gOMIGHTNLMP0SShaby2agPjx6btophJNdyqnj13ZaSY8WO1BAbiQ0GyUaf 7iJg== X-Gm-Message-State: AKGB3mIjvXHk68+f1ZkHehQPu2tn1Qs/svI6Y/kamrWvyVSFwYuRdv5q 8e+fna8h6NRgja7c4303JUE= X-Google-Smtp-Source: ACJfBovaW3IF2jEjLohgXC61Jfq3LoXtdBPtxoVdBbrtH5FqwCFlQWirsoC78JFFPtE57wAsc3KSaQ== X-Received: by 10.80.165.41 with SMTP id y38mr53348989edb.72.1514729867406; Sun, 31 Dec 2017 06:17:47 -0800 (PST) Received: from thinkpad (pppoe-46-239-11-36.teol.net. [46.239.11.36]) by smtp.googlemail.com with ESMTPSA id h56sm33225684ede.45.2017.12.31.06.17.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Dec 2017 06:17:46 -0800 (PST) Date: Sun, 31 Dec 2017 15:17:43 +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 v11 4/5] battery: Add the ThinkPad "Not Charging" quirk Message-ID: <20171231141743.GA4657@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. Signed-off-by: Ognjen Galic 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 v11: * Fix formatting of changelog --- 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"), + }, + }, {}, };