aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/acpi/battery.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index c2ce0ad21693..192c244f6190 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -132,7 +132,7 @@ static int acpi_battery_technology(struct acpi_battery *battery)
132 return POWER_SUPPLY_TECHNOLOGY_UNKNOWN; 132 return POWER_SUPPLY_TECHNOLOGY_UNKNOWN;
133} 133}
134 134
135static int acpi_battery_update(struct acpi_battery *battery); 135static int acpi_battery_get_state(struct acpi_battery *battery);
136 136
137static int acpi_battery_get_property(struct power_supply *psy, 137static int acpi_battery_get_property(struct power_supply *psy,
138 enum power_supply_property psp, 138 enum power_supply_property psp,
@@ -140,10 +140,11 @@ static int acpi_battery_get_property(struct power_supply *psy,
140{ 140{
141 struct acpi_battery *battery = to_acpi_battery(psy); 141 struct acpi_battery *battery = to_acpi_battery(psy);
142 142
143 if ((!acpi_battery_present(battery)) && 143 if (acpi_battery_present(battery)) {
144 psp != POWER_SUPPLY_PROP_PRESENT) 144 /* run battery update only if it is present */
145 acpi_battery_get_state(battery);
146 } else if (psp != POWER_SUPPLY_PROP_PRESENT)
145 return -ENODEV; 147 return -ENODEV;
146 acpi_battery_update(battery);
147 switch (psp) { 148 switch (psp) {
148 case POWER_SUPPLY_PROP_STATUS: 149 case POWER_SUPPLY_PROP_STATUS:
149 if (battery->state & 0x01) 150 if (battery->state & 0x01)
@@ -457,6 +458,7 @@ static void sysfs_remove_battery(struct acpi_battery *battery)
457 return; 458 return;
458 device_remove_file(battery->bat.dev, &alarm_attr); 459 device_remove_file(battery->bat.dev, &alarm_attr);
459 power_supply_unregister(&battery->bat); 460 power_supply_unregister(&battery->bat);
461 battery->bat.dev = NULL;
460} 462}
461 463
462static int acpi_battery_update(struct acpi_battery *battery) 464static int acpi_battery_update(struct acpi_battery *battery)