From patchwork Sun Oct 17 18:32:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael Wysocki X-Patchwork-Id: 260421 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9HIXcUZ027765 for ; Sun, 17 Oct 2010 18:33:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932480Ab0JQSdg (ORCPT ); Sun, 17 Oct 2010 14:33:36 -0400 Received: from ogre.sisk.pl ([217.79.144.158]:54207 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932381Ab0JQSdg (ORCPT ); Sun, 17 Oct 2010 14:33:36 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by ogre.sisk.pl (Postfix) with ESMTP id 85A64199AF0; Sun, 17 Oct 2010 20:30:14 +0200 (CEST) Received: from ogre.sisk.pl ([127.0.0.1]) by localhost (ogre.sisk.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 06810-04; Sun, 17 Oct 2010 20:29:56 +0200 (CEST) Received: from ferrari.rjw.lan (220-bem-13.acn.waw.pl [82.210.184.220]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ogre.sisk.pl (Postfix) with ESMTP id 1C07319986B; Sun, 17 Oct 2010 20:29:56 +0200 (CEST) From: "Rafael J. Wysocki" To: Sitsofe Wheeler Subject: Re: [PATCH] ACPI / Battery: Return -ENODATA for unknown values in get_property() Date: Sun, 17 Oct 2010 20:32:42 +0200 User-Agent: KMail/1.13.5 (Linux/2.6.36-rc8-rjw+; KDE/4.4.4; x86_64; ; ) Cc: Henrique de Moraes Holschuh , Matthew Garrett , Len Brown , Zhang Rui , David Zeuthen , Richard Hughes , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org References: <20101016141321.GA11054@sucs.org> <20101017131016.GB13015@khazad-dum.debian.net> <20101017145025.GA32599@sucs.org> In-Reply-To: <20101017145025.GA32599@sucs.org> MIME-Version: 1.0 Message-Id: <201010172032.43206.rjw@sisk.pl> X-Virus-Scanned: amavisd-new at ogre.sisk.pl using MkS_Vir for Linux Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Sun, 17 Oct 2010 18:33:39 +0000 (UTC) Index: linux-2.6/drivers/acpi/battery.c =================================================================== --- linux-2.6.orig/drivers/acpi/battery.c +++ linux-2.6/drivers/acpi/battery.c @@ -193,6 +193,8 @@ static int acpi_battery_get_property(str acpi_battery_get_state(battery); } else if (psp != POWER_SUPPLY_PROP_PRESENT) return -ENODEV; + if (psp < POWER_SUPPLY_PROP_MODEL_NAME) + val->intval = -1; switch (psp) { case POWER_SUPPLY_PROP_STATUS: if (battery->state & 0x01) @@ -214,26 +216,32 @@ static int acpi_battery_get_property(str val->intval = battery->cycle_count; break; case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: - val->intval = battery->design_voltage * 1000; + if (battery->design_voltage != ACPI_BATTERY_VALUE_UNKNOWN) + val->intval = battery->design_voltage * 1000; break; case POWER_SUPPLY_PROP_VOLTAGE_NOW: - val->intval = battery->voltage_now * 1000; + if (battery->voltage_now != ACPI_BATTERY_VALUE_UNKNOWN) + val->intval = battery->voltage_now * 1000; break; case POWER_SUPPLY_PROP_CURRENT_NOW: case POWER_SUPPLY_PROP_POWER_NOW: - val->intval = battery->rate_now * 1000; + if (battery->rate_now != ACPI_BATTERY_VALUE_UNKNOWN) + val->intval = battery->rate_now * 1000; break; case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: - val->intval = battery->design_capacity * 1000; + if (battery->design_capacity != ACPI_BATTERY_VALUE_UNKNOWN) + val->intval = battery->design_capacity * 1000; break; case POWER_SUPPLY_PROP_CHARGE_FULL: case POWER_SUPPLY_PROP_ENERGY_FULL: - val->intval = battery->full_charge_capacity * 1000; + if (battery->full_charge_capacity != ACPI_BATTERY_VALUE_UNKNOWN) + val->intval = battery->full_charge_capacity * 1000; break; case POWER_SUPPLY_PROP_CHARGE_NOW: case POWER_SUPPLY_PROP_ENERGY_NOW: - val->intval = battery->capacity_now * 1000; + if (battery->capacity_now != ACPI_BATTERY_VALUE_UNKNOWN) + val->intval = battery->capacity_now * 1000; break; case POWER_SUPPLY_PROP_MODEL_NAME: val->strval = battery->model_number;