diff options
author | Roland Dreier <roland@digitalvampire.org> | 2007-11-07 18:09:09 -0500 |
---|---|---|
committer | Len Brown <lenb@t61.(none)> | 2007-11-08 15:08:15 -0500 |
commit | 4c41d3ad6544f1c9aec37c441af04f5d0ad3a731 (patch) | |
tree | a219cf7ae81282beba10c821e2179326f8429939 /drivers/acpi | |
parent | dbeeb816e805091e7cfc03baf36dc40b4adb2bbd (diff) |
ACPI: Always return valid 'status' from acpi_battery_get_property()
If a battery is at a critical charge level and not being charged or
discharged, then the ACPI _BST method will return a state of 4, and
the current acpi_battery_get_property() code will not set any property
value for POWER_SUPPLY_PROP_STATUS. This will cause an oops in
power_supply_show_property() when it reads off the end of the
status_text array. This actually was causing a 100% reproducible
crash on boot on my laptop with two batteries, when one battery was
completely drained and the laptop was not plugged in.
Fix this by making sure acpi_battery_get_property() returns
POWER_SUPPLY_STATUS_UNKNOWN for any battery state it doesn't already
handle explicitly. There doesn't seem to be any status enum value
defined that makes more sense than 'unknown' for a battery at a
critical charge level.
Signed-off-by: Roland Dreier <roland@digitalvampire.org>
Acked-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <lenb@t61.(none)>
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/battery.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index c2ce0ad21693..cbb27b4ddea4 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -152,6 +152,8 @@ static int acpi_battery_get_property(struct power_supply *psy, | |||
152 | val->intval = POWER_SUPPLY_STATUS_CHARGING; | 152 | val->intval = POWER_SUPPLY_STATUS_CHARGING; |
153 | else if (battery->state == 0) | 153 | else if (battery->state == 0) |
154 | val->intval = POWER_SUPPLY_STATUS_FULL; | 154 | val->intval = POWER_SUPPLY_STATUS_FULL; |
155 | else | ||
156 | val->intval = POWER_SUPPLY_STATUS_UNKNOWN; | ||
155 | break; | 157 | break; |
156 | case POWER_SUPPLY_PROP_PRESENT: | 158 | case POWER_SUPPLY_PROP_PRESENT: |
157 | val->intval = acpi_battery_present(battery); | 159 | val->intval = acpi_battery_present(battery); |