* [PATCH 3/4] ACPI ac: update AC status first when querying from sysfs
@ 2010-12-08 2:40 Zhang Rui
2010-12-09 20:34 ` Len Brown
0 siblings, 1 reply; 2+ messages in thread
From: Zhang Rui @ 2010-12-08 2:40 UTC (permalink / raw)
To: Brown, Len; +Cc: linux-acpi, seblu, Zhang, Rui
Update AC status first when querying from sysfs.
http://marc.info/?l=linux-acpi&m=128855015826728&w=2
https://bugzilla.kernel.org/show_bug.cgi?id=21722
Tested_by: Seblu <seblu@seblu.net>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
drivers/acpi/ac.c | 46 +++++++++++++++++++++++++++++-----------------
1 file changed, 29 insertions(+), 17 deletions(-)
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)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 3/4] ACPI ac: update AC status first when querying from sysfs
2010-12-08 2:40 [PATCH 3/4] ACPI ac: update AC status first when querying from sysfs Zhang Rui
@ 2010-12-09 20:34 ` Len Brown
0 siblings, 0 replies; 2+ messages in thread
From: Len Brown @ 2010-12-09 20:34 UTC (permalink / raw)
To: Zhang Rui; +Cc: linux-acpi, seblu
applied
thanks,
Len Brown, Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-12-09 20:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-08 2:40 [PATCH 3/4] ACPI ac: update AC status first when querying from sysfs Zhang Rui
2010-12-09 20:34 ` Len Brown
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.