From patchwork Wed Jan 3 11:59:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ognjen Galic X-Patchwork-Id: 10142175 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 042176034B for ; Wed, 3 Jan 2018 11:59:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E14B229090 for ; Wed, 3 Jan 2018 11:59:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D561229092; Wed, 3 Jan 2018 11:59:46 +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 78BF929091 for ; Wed, 3 Jan 2018 11:59:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752389AbeACL7p (ORCPT ); Wed, 3 Jan 2018 06:59:45 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:38809 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752387AbeACL7o (ORCPT ); Wed, 3 Jan 2018 06:59:44 -0500 Received: by mail-wr0-f195.google.com with SMTP id y9so1319469wrb.5; Wed, 03 Jan 2018 03:59:43 -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=xmEnrWQKbTsSL0zorPwqkl/ksm8umG0O9JIAt6eHP68=; b=LGBmVTeRlGZg8Q/cVD7pdixDa5Ts+BYrY8oU6LqmXitf+8uRT4lfKbUVRFHiQo2X1x aFLN/02cmZuGMBFEektet0++1d1nlTGyiBhu8mU5Caobkd2JbKXQSTdsFFDTUrRNo6no IrHFkQpG9hwGzD/r13bcuvoema3IoIaT+9mbTJ8eqjndbQwbrmNmMVM607pKSxWg+T7E PjDE5rPbEfAZejtK7Yr32tLYpKbN89fdd9UEt13oGRENxu0KszRkLrH4AqtHIkkFVyyx iU7p36eocyhmOcQn8uVPhlc1lsXJhMfNpBeF6D0fS+dW7K1PUzneb4pCRFmw3bX6Dw1W N0Zw== 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=xmEnrWQKbTsSL0zorPwqkl/ksm8umG0O9JIAt6eHP68=; b=pabl6oBxiELVy+JbC6+DaDlEgqLIQlgN7f4f+2utzl2PCHtSOoZOuJmWtEPk/dyt18 ShKbETtkrNhE4tz9mZ4rFMJqU03DoWOvAdzWhJcPyYJ71G4TGfMQ/HC5zfHdwGQmEXuy lfw6FSJI2r8tJ111lD9P1ZHZ0TLf6mrwM5AI8fRbSWEK/8Ohc2pi3Pc3Xnhj7LiiRvvS wcj2wXQiQr3MOAKq9GnwDj4uZQaf9tHhufS16MbXat1QawykPc2gttMCahYMmeKvtY0g oX5nBoPWjO3I2plXzz5sqIEMovsIByxlJOCzbUZKF6863GsFdJH5RuuboEdluRtLkTGU KZwQ== X-Gm-Message-State: AKGB3mJku3lbQhYUxneA+I3nBOursdwjgFJSw975R2ENXWcXvg9pGt6D Z+ecgBsdtbGAta28S08UIKE= X-Google-Smtp-Source: ACJfBotkngTznrxkvR9AfvajJj0ZkQEfJnxA3c9khzC35obsBujINp0kwcJFqtFfcLNR3OPL7rnJMg== X-Received: by 10.223.193.4 with SMTP id r4mr1236440wre.151.1514980782959; Wed, 03 Jan 2018 03:59:42 -0800 (PST) Received: from thinkpad (pppoe-46-239-11-72.teol.net. [46.239.11.72]) by smtp.googlemail.com with ESMTPSA id l73sm2119342wrc.50.2018.01.03.03.59.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jan 2018 03:59:42 -0800 (PST) Date: Wed, 3 Jan 2018 12:59:39 +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 v12 4/4] battery: Add the ThinkPad "Not Charging" quirk Message-ID: <20180103115939.GA10155@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 Reviewed-by: Andy Shevchenko --- Notes: 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 v12: * No changes in this patch in v12 drivers/acpi/battery.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 7089e31..279516e 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -74,6 +74,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"); @@ -225,6 +226,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; @@ -1309,6 +1312,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, @@ -1326,6 +1335,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"), + }, + }, {}, };