From patchwork Sat Feb 7 11:21:23 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Hughes X-Patchwork-Id: 6020 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n17BMCUS001526 for ; Sat, 7 Feb 2009 11:22:13 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752443AbZBGLWL (ORCPT ); Sat, 7 Feb 2009 06:22:11 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752703AbZBGLWL (ORCPT ); Sat, 7 Feb 2009 06:22:11 -0500 Received: from qw-out-2122.google.com ([74.125.92.24]:13661 "EHLO qw-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752443AbZBGLWK (ORCPT ); Sat, 7 Feb 2009 06:22:10 -0500 Received: by qw-out-2122.google.com with SMTP id 3so666351qwe.37 for ; Sat, 07 Feb 2009 03:22:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :in-reply-to:references:content-type:date:message-id:mime-version :x-mailer; bh=9W+3fHjuLUypzk26/Y/XeeHO38RO/d9A4fXOvU6KFWM=; b=KLn4cSahrMZEWEGqA4jRmXmWMvZzswSeKbgxXiXYWbyAf7jbhmCbbRSFlSyBSz2eFD M3XOnQT3/SaSymJ9lvbxGXprRVxF+hOX0edJFz+Asa0ECPmTWuoq7D7U0dl44Vedad6M Y6GRlbkG3M4HGBtgkzAwazoHX1hMSJc1J3cZg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer; b=rxpjUmpqkND5FWp3GwAclCAuYJJ03PH3WZrzprooem2vAfSzAcE3vV4t3LZuOJrEva eyvZQ9qfcOt+nspSAapuqjB2AJHhzfvpWJKalKOjHwQzzFGr34oQl4lQX8pgptk+WiV4 VDbsh/xzU0IdT/ndvvMrC3i8/Kdsko/dq9OgI= Received: by 10.215.39.14 with SMTP id r14mr4069462qaj.80.1234005728390; Sat, 07 Feb 2009 03:22:08 -0800 (PST) Received: from ?192.168.1.64? ([78.86.247.183]) by mx.google.com with ESMTPS id 5sm1143481qwg.35.2009.02.07.03.22.06 (version=SSLv3 cipher=RC4-MD5); Sat, 07 Feb 2009 03:22:07 -0800 (PST) Subject: Re: [git pull] ACPI patches for 2.6.29-rc3 From: Richard Hughes To: Len Brown Cc: Linus Torvalds , Andrew Morton , Linux Kernel Mailing List , linux-acpi@vger.kernel.org In-Reply-To: References: Date: Sat, 07 Feb 2009 11:21:23 +0000 Message-Id: <1234005683.10134.8.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.25.90 (2.25.90-1.fc11) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On Sat, 2009-02-07 at 01:59 -0500, Len Brown wrote: > Nothing too Earth-shaking. > This will update the files shown below. No sign of my battery patch (attached, again) to fix the confirmed userspace breakage of the acpi battery on some hardware (T61 and other Lenovo models). I've filed http://bugzilla.kernel.org/show_bug.cgi?id=12632 and it's in status "RESOLVED CODE_FIX" but it seems nobody has done anything with the patch. Please, tell me what I need to do to get this merged. If it's not merged soon, I'll just switch HAL back to using /proc/acpi by default as it's affecting real users right now. Thanks, Richard. >From 3b0fb1239e5bc064766ffa3d7a45265e722fb9eb Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Sun, 25 Jan 2009 15:05:50 +0000 Subject: [PATCH] battery: don't assume we are fully charged when not charging or discharging On hardware like the T61 it can take a couple of seconds for the battery to start charging after the power is connected, and we incorrectly tell userspace that we are fully charged, and then go back to charging. Only mark a battery as fully charged when the preset charge matches either the last full charge, or the design charge. Signed-off-by: Richard Hughes --- drivers/acpi/battery.c | 25 ++++++++++++++++++++++++- 1 files changed, 24 insertions(+), 1 deletions(-) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 65132f9..69cbc57 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -138,6 +138,29 @@ static int acpi_battery_technology(struct acpi_battery *battery) static int acpi_battery_get_state(struct acpi_battery *battery); +static int acpi_battery_is_charged(struct acpi_battery *battery) +{ + /* either charging or discharging */ + if (battery->state != 0) + return 0; + + /* battery not reporting charge */ + if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN || + battery->capacity_now == 0) + return 0; + + /* good batteries update full_charge as the batteries degrade */ + if (battery->full_charge_capacity == battery->capacity_now) + return 1; + + /* fallback to using design values for broken batteries */ + if (battery->design_capacity == battery->capacity_now) + return 1; + + /* we don't do any sort of metric based on percentages */ + return 0; +} + static int acpi_battery_get_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) @@ -155,7 +178,7 @@ static int acpi_battery_get_property(struct power_supply *psy, val->intval = POWER_SUPPLY_STATUS_DISCHARGING; else if (battery->state & 0x02) val->intval = POWER_SUPPLY_STATUS_CHARGING; - else if (battery->state == 0) + else if (acpi_battery_is_charged(battery)) val->intval = POWER_SUPPLY_STATUS_FULL; else val->intval = POWER_SUPPLY_STATUS_UNKNOWN; -- 1.6.0.6