diff options
author | Alexey Starikovskiy <astarikovskiy@suse.de> | 2007-11-13 04:23:06 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-11-13 12:02:18 -0500 |
commit | 9104476e4efbef8a8e32d48ced583603ff32a2db (patch) | |
tree | 1be22813f6cab5aa5d08fd9131eba25d249842fd /drivers/acpi/battery.c | |
parent | 0b832a4b93932103d73c0c3f35ef1153e288327b (diff) |
ACPI: Battery: remove cycle from battery removal.
get_property() should not call battery_update(), it also should call
get_status() only if battery is present to avoid cycle and oops.
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Tested-by: Rolf Eike Beer <eike-kernel@sf-tec.de>
Acked-by: Johannes Weiner <hannes@saeurebad.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/acpi/battery.c')
-rw-r--r-- | drivers/acpi/battery.c | 10 |
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 | ||
135 | static int acpi_battery_update(struct acpi_battery *battery); | 135 | static int acpi_battery_get_state(struct acpi_battery *battery); |
136 | 136 | ||
137 | static int acpi_battery_get_property(struct power_supply *psy, | 137 | static 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 | ||
462 | static int acpi_battery_update(struct acpi_battery *battery) | 464 | static int acpi_battery_update(struct acpi_battery *battery) |