diff mbox

[4/4] ACPI: update battery status first when querying from sysfs

Message ID 1291776049.19296.705.camel@rui (mailing list archive)
State Accepted
Headers show

Commit Message

Zhang Rui Dec. 8, 2010, 2:40 a.m. UTC
None
diff mbox

Patch

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);