diff options
author | Len Brown <len.brown@intel.com> | 2009-09-19 09:56:17 +0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-09-19 09:56:17 +0400 |
commit | 7a92d803227a523a9a5546e4e0dce1325a4b5926 (patch) | |
tree | fd914dcba7a367939550774d786355352628c3b3 /drivers/acpi/battery.c | |
parent | b4549a24b6194201077d0295207ec204f785fab1 (diff) | |
parent | bc76f90b8a5cf4aceedf210d08d5e8292f820cec (diff) | |
download | linux-7a92d803227a523a9a5546e4e0dce1325a4b5926.tar.xz |
Merge branch 'battery' into release
Diffstat (limited to 'drivers/acpi/battery.c')
-rw-r--r-- | drivers/acpi/battery.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index f8c3d1bb6969..3f4602b8f287 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -31,6 +31,7 @@ #include <linux/types.h> #include <linux/jiffies.h> #include <linux/async.h> +#include <linux/dmi.h> #ifdef CONFIG_ACPI_PROCFS_POWER #include <linux/proc_fs.h> @@ -87,6 +88,10 @@ static const struct acpi_device_id battery_device_ids[] = { MODULE_DEVICE_TABLE(acpi, battery_device_ids); +/* For buggy DSDTs that report negative 16-bit values for either charging + * or discharging current and/or report 0 as 65536 due to bad math. + */ +#define QUIRK_SIGNED16_CURRENT 0x0001 struct acpi_battery { struct mutex lock; @@ -114,6 +119,7 @@ struct acpi_battery { int state; int power_unit; u8 alarm_present; + long quirks; }; #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); @@ -392,6 +398,11 @@ static int acpi_battery_get_state(struct acpi_battery *battery) state_offsets, ARRAY_SIZE(state_offsets)); battery->update_time = jiffies; kfree(buffer.pointer); + + if ((battery->quirks & QUIRK_SIGNED16_CURRENT) && + battery->rate_now != -1) + battery->rate_now = abs((s16)battery->rate_now); + return result; } @@ -497,6 +508,14 @@ static void sysfs_remove_battery(struct acpi_battery *battery) } #endif +static void acpi_battery_quirks(struct acpi_battery *battery) +{ + battery->quirks = 0; + if (dmi_name_in_vendors("Acer") && battery->power_unit) { + battery->quirks |= QUIRK_SIGNED16_CURRENT; + } +} + static int acpi_battery_update(struct acpi_battery *battery) { int result, old_present = acpi_battery_present(battery); @@ -515,6 +534,7 @@ static int acpi_battery_update(struct acpi_battery *battery) result = acpi_battery_get_info(battery); if (result) return result; + acpi_battery_quirks(battery); acpi_battery_init_alarm(battery); } #ifdef CONFIG_ACPI_SYSFS_POWER |