From patchwork Tue Nov 2 03:20:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 296582 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 oA23L0tR011184 for ; Tue, 2 Nov 2010 03:21:00 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755453Ab0KBDU7 (ORCPT ); Mon, 1 Nov 2010 23:20:59 -0400 Received: from mga03.intel.com ([143.182.124.21]:43917 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754135Ab0KBDU7 (ORCPT ); Mon, 1 Nov 2010 23:20:59 -0400 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 01 Nov 2010 20:20:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.58,278,1286175600"; d="scan'208";a="343361188" 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 20:20:50 -0700 Subject: [PATCH 1/2] ACPI ac: update AC status first when querying from sysfs From: Zhang Rui To: "Brown, Len" Cc: "linux-acpi@vger.kernel.org" , cbou@mail.ru, seblu@seblu.net, "Zhang, Rui" Date: Tue, 02 Nov 2010 11:20:59 +0800 Message-ID: <1288668059.2234.170.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 03:21:00 +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,34 @@ 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)