From patchwork Tue Nov 2 05:22:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Rui X-Patchwork-Id: 296632 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 oA25MMuS022403 for ; Tue, 2 Nov 2010 05:22:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936216Ab0KBFWO (ORCPT ); Tue, 2 Nov 2010 01:22:14 -0400 Received: from mga14.intel.com ([143.182.124.37]:1885 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936277Ab0KBFWM (ORCPT ); Tue, 2 Nov 2010 01:22:12 -0400 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 01 Nov 2010 22:22:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.58,278,1286175600"; d="scan'208";a="343398740" Received: from rui.sh.intel.com (HELO [10.239.13.24]) ([10.239.13.24]) by azsmga001.ch.intel.com with ESMTP; 01 Nov 2010 22:22:11 -0700 Subject: Re: [PATCH 2/2] ACPI battery: update battery status first when querying from sysfs From: Zhang Rui To: Seblu Cc: "Brown, Len" , "linux-acpi@vger.kernel.org" , "cbou@mail.ru" In-Reply-To: References: <1288668295.2234.174.camel@rui> Date: Tue, 02 Nov 2010 13:22:20 +0800 Message-ID: <1288675340.2234.176.camel@rui> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 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]); Tue, 02 Nov 2010 05:22:23 +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 @@ -177,6 +177,8 @@ static int acpi_battery_is_charged(struc return 0; } +static int acpi_battery_update(struct acpi_battery *battery); + static int acpi_battery_get_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) @@ -184,6 +186,9 @@ static int acpi_battery_get_property(str int ret = 0; struct acpi_battery *battery = to_acpi_battery(psy); + if (acpi_battery_update(battery)) + return -ENODEV; + if (acpi_battery_present(battery)) { /* run battery update only if it is present */ acpi_battery_get_state(battery);