Patchwork ACPI battery: Fix sysfs oops when removing battery

login
register
mail settings
Submitter Borislav Petkov
Date Dec. 19, 2010, 1 p.m.
Message ID <20101219130001.GB5790@liondog.tnic>
Download mbox | patch
Permalink /patch/418751/
State New, archived
Headers show

Comments

Patch

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 9fb9d5a..78be7d5 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -186,14 +186,15 @@  static int acpi_battery_get_property(struct power_supply *psy,
 	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);
+		if (acpi_battery_update(battery))
+			return -ENODEV;
+
 	} else if (psp != POWER_SUPPLY_PROP_PRESENT)
 		return -ENODEV;
+
 	switch (psp) {
 	case POWER_SUPPLY_PROP_STATUS:
 		if (battery->state & 0x01)