From patchwork Thu Dec 21 19:55:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ognjen Galic X-Patchwork-Id: 10128347 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 DC3A1603B5 for ; Thu, 21 Dec 2017 19:55:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C745F29E14 for ; Thu, 21 Dec 2017 19:55:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC01F29E24; Thu, 21 Dec 2017 19:55:19 +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 E5DFF29E1C for ; Thu, 21 Dec 2017 19:55:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753469AbdLUTzR (ORCPT ); Thu, 21 Dec 2017 14:55:17 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:45767 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753360AbdLUTzP (ORCPT ); Thu, 21 Dec 2017 14:55:15 -0500 Received: by mail-wr0-f195.google.com with SMTP id h1so26081240wre.12; Thu, 21 Dec 2017 11:55:15 -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=S5MzB4d0fNYxxgSePvooNEUE1CDiepz+v4zmO23iPvM=; b=HW5ko/N3ysxsmJzr8SFV1XOpJBxRz3LozCHWs4yho9kIC80I+QZ/gye0exjpdi/kzn 1G5fTLPBSB7F6DKzodzJVYPu4P/dR93Fc8BXpcm1SubnqkZDO2FEUKqrObiePo2bEXfH w2oWOQsWtZqjnyYyXuS4McK15VbkbK4Krc8zbNsUOc5BkI3D5batuOjSkj5m06CrUbK3 A+cG0QPg8tkcfsvrNWIXhwpFv/naaYEzJEoKOQ+5MLp+yfdZocNsGOWmHXtwcSbiBkpr zxd5mdo9SR9qEAel1ot/mzHIqNGnIc2R2VV5+yzCqS3DvP935wdDi8OU1ylBX6IXTFop a6Mw== 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=S5MzB4d0fNYxxgSePvooNEUE1CDiepz+v4zmO23iPvM=; b=pdk8KhT5CiSkH0KUfHsWhQGPHUCh3sOjyknh+oI6iwRiWoU57iN618zz9kRMQPLN57 ksOsycq7wAkm2uCSlitYgqsyIGYMFCh2T3ybIdxlfbUPMuA/VJCO24vwfn+SQNW/EjxR +8Ocryxz7FwnBZjslwm5QjcUM6yVLF/xAnVOB5PJBP29Fm8TiDgCfecOzVSDfwVzyheB LB9BTesm8Fa5JAJlzfF+zG2sGU7JTWlBey9nQSTud7z5nIue2mFDZOLbj5FySyH4cfSb +YybExn7mWt8Z8LDMU6NO00uSfMJMpd0zHUvSEj7fZZxanMtmYm4TCLsPInN0UpHwzss TIFA== X-Gm-Message-State: AKGB3mIMUCpuNbywiGwWsB0ePCfiLtGjo6LyyfZ2Wpn68ijn6/Al+whb 1yFWSCWTJdRkDw+8aMdWBY0= X-Google-Smtp-Source: ACJfBot1x3P0vGsoPVK3V//TU3TK+2XQwqMWwWGCEK4dthFsJA9YZyAeXTOUK4OA8oGTTwtYQ2AmnQ== X-Received: by 10.223.176.26 with SMTP id f26mr6016214wra.177.1513886114480; Thu, 21 Dec 2017 11:55:14 -0800 (PST) Received: from thinkpad (pppoe-46-239-10-167.teol.net. [46.239.10.167]) by smtp.gmail.com with ESMTPSA id u44sm20766107wrb.68.2017.12.21.11.55.13 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Dec 2017 11:55:13 -0800 (PST) Date: Thu, 21 Dec 2017 20:55:12 +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 v9 4/4] battery: Add the ThinkPad "Not Charging" quirk Message-ID: <20171221195512.GA17520@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 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"), + }, + }, {}, };