diff mbox

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

Message ID 1288675340.2234.176.camel@rui (mailing list archive)
State New, archived
Headers show

Commit Message

Zhang Rui Nov. 2, 2010, 5:22 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
@@ -177,6 +177,8 @@  static int acpi_battery_is_charged(struc
 	return 0;
 }
 
+static int acpi_battery_update(struct acpi_battery *battery);
+
 static int acpi_battery_get_property(struct power_supply *psy,
 				     enum power_supply_property psp,
 				     union power_supply_propval *val)
@@ -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);