From patchwork Wed Dec 8 02:40:45 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Rui X-Patchwork-Id: 389442 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 oB82ebnj024360 for ; Wed, 8 Dec 2010 02:40:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755951Ab0LHCkp (ORCPT ); Tue, 7 Dec 2010 21:40:45 -0500 Received: from mga01.intel.com ([192.55.52.88]:24868 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755848Ab0LHCkp (ORCPT ); Tue, 7 Dec 2010 21:40:45 -0500 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 07 Dec 2010 18:40:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.59,314,1288594800"; d="scan'208";a="634182979" Received: from rui.sh.intel.com (HELO [10.239.36.7]) ([10.239.36.7]) by fmsmga002.fm.intel.com with ESMTP; 07 Dec 2010 18:40:44 -0800 Subject: [PATCH 3/4] ACPI ac: update AC 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:45 +0800 Message-ID: <1291776045.19296.704.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:40:46 +0000 (UTC) Index: linux-2.6/drivers/acpi/ac.c =================================================================== --- linux-2.6.orig/drivers/acpi/ac.c +++ linux-2.6/drivers/acpi/ac.c @@ -100,24 +100,7 @@ static const struct file_operations acpi .release = single_release, }; #endif -static int get_ac_property(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) -{ - struct acpi_ac *ac = to_acpi_ac(psy); - switch (psp) { - case POWER_SUPPLY_PROP_ONLINE: - val->intval = ac->state; - break; - default: - return -EINVAL; - } - return 0; -} -static enum power_supply_property ac_props[] = { - POWER_SUPPLY_PROP_ONLINE, -}; /* -------------------------------------------------------------------------- AC Adapter Management -------------------------------------------------------------------------- */ @@ -140,6 +123,35 @@ static int acpi_ac_get_state(struct acpi return 0; } +/* -------------------------------------------------------------------------- + sysfs I/F + -------------------------------------------------------------------------- */ +static int get_ac_property(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val) +{ + struct acpi_ac *ac = to_acpi_ac(psy); + + if (!ac) + return -ENODEV; + + if (acpi_ac_get_state(ac)) + return -ENODEV; + + switch (psp) { + case POWER_SUPPLY_PROP_ONLINE: + val->intval = ac->state; + break; + default: + return -EINVAL; + } + return 0; +} + +static enum power_supply_property ac_props[] = { + POWER_SUPPLY_PROP_ONLINE, +}; + #ifdef CONFIG_ACPI_PROCFS_POWER /* -------------------------------------------------------------------------- FS Interface (/proc)