From patchwork Wed Dec 8 02:40:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Rui X-Patchwork-Id: 389472 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 oB82fJej024511 for ; Wed, 8 Dec 2010 02:41:20 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756039Ab0LHClH (ORCPT ); Tue, 7 Dec 2010 21:41:07 -0500 Received: from mga03.intel.com ([143.182.124.21]:1415 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756043Ab0LHClE (ORCPT ); Tue, 7 Dec 2010 21:41:04 -0500 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 07 Dec 2010 18:40:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.59,314,1288594800"; d="scan'208";a="358568615" Received: from rui.sh.intel.com (HELO [10.239.36.7]) ([10.239.36.7]) by azsmga001.ch.intel.com with ESMTP; 07 Dec 2010 18:40:48 -0800 Subject: [PATCH 4/4] ACPI: update battery status first when querying from sysfs From: Zhang Rui To: "Brown, Len" Cc: "linux-acpi@vger.kernel.org" , seblu@seblu.net, "Zhang, Rui" Date: Wed, 08 Dec 2010 10:40:49 +0800 Message-ID: <1291776049.19296.705.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]); Wed, 08 Dec 2010 02:41:20 +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 @@ -130,6 +130,8 @@ struct acpi_battery { unsigned long flags; }; +static int acpi_battery_update(struct acpi_battery *battery); + #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); inline int acpi_battery_present(struct acpi_battery *battery) @@ -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);