diff options
author | Alexey Starikovskiy <astarikovskiy@suse.de> | 2009-10-15 06:31:24 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2010-01-15 16:55:51 -0500 |
commit | 7b3bcc4a1a7cd2d53b403ca29d06ceb5fa617eb7 (patch) | |
tree | 1611e1da5212fb28c9b75abb83bc965488099b48 /drivers/acpi/battery.c | |
parent | 61c39bb354a1f791ba6f562b766a72e508a036ee (diff) |
ACPI: Battery: Add bit flags
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/battery.c')
-rw-r--r-- | drivers/acpi/battery.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index cada73ffdfa7..b2b48f8545c7 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -88,10 +88,13 @@ static const struct acpi_device_id battery_device_ids[] = { | |||
88 | 88 | ||
89 | MODULE_DEVICE_TABLE(acpi, battery_device_ids); | 89 | MODULE_DEVICE_TABLE(acpi, battery_device_ids); |
90 | 90 | ||
91 | /* For buggy DSDTs that report negative 16-bit values for either charging | 91 | enum { |
92 | * or discharging current and/or report 0 as 65536 due to bad math. | 92 | ACPI_BATTERY_ALARM_PRESENT, |
93 | */ | 93 | /* For buggy DSDTs that report negative 16-bit values for either charging |
94 | #define QUIRK_SIGNED16_CURRENT 0x0001 | 94 | * or discharging current and/or report 0 as 65536 due to bad math. |
95 | */ | ||
96 | ACPI_BATTERY_QUIRK_SIGNED16_CURRENT, | ||
97 | }; | ||
95 | 98 | ||
96 | struct acpi_battery { | 99 | struct acpi_battery { |
97 | struct mutex lock; | 100 | struct mutex lock; |
@@ -118,8 +121,7 @@ struct acpi_battery { | |||
118 | char oem_info[32]; | 121 | char oem_info[32]; |
119 | int state; | 122 | int state; |
120 | int power_unit; | 123 | int power_unit; |
121 | u8 alarm_present; | 124 | unsigned long flags; |
122 | long quirks; | ||
123 | }; | 125 | }; |
124 | 126 | ||
125 | #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); | 127 | #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); |
@@ -399,7 +401,7 @@ static int acpi_battery_get_state(struct acpi_battery *battery) | |||
399 | battery->update_time = jiffies; | 401 | battery->update_time = jiffies; |
400 | kfree(buffer.pointer); | 402 | kfree(buffer.pointer); |
401 | 403 | ||
402 | if ((battery->quirks & QUIRK_SIGNED16_CURRENT) && | 404 | if (test_bit(ACPI_BATTERY_QUIRK_SIGNED16_CURRENT, &battery->flags) && |
403 | battery->rate_now != -1) | 405 | battery->rate_now != -1) |
404 | battery->rate_now = abs((s16)battery->rate_now); | 406 | battery->rate_now = abs((s16)battery->rate_now); |
405 | 407 | ||
@@ -412,7 +414,8 @@ static int acpi_battery_set_alarm(struct acpi_battery *battery) | |||
412 | union acpi_object arg0 = { .type = ACPI_TYPE_INTEGER }; | 414 | union acpi_object arg0 = { .type = ACPI_TYPE_INTEGER }; |
413 | struct acpi_object_list arg_list = { 1, &arg0 }; | 415 | struct acpi_object_list arg_list = { 1, &arg0 }; |
414 | 416 | ||
415 | if (!acpi_battery_present(battery)|| !battery->alarm_present) | 417 | if (!acpi_battery_present(battery)|| |
418 | !test_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags)) | ||
416 | return -ENODEV; | 419 | return -ENODEV; |
417 | 420 | ||
418 | arg0.integer.value = battery->alarm; | 421 | arg0.integer.value = battery->alarm; |
@@ -437,10 +440,10 @@ static int acpi_battery_init_alarm(struct acpi_battery *battery) | |||
437 | /* See if alarms are supported, and if so, set default */ | 440 | /* See if alarms are supported, and if so, set default */ |
438 | status = acpi_get_handle(battery->device->handle, "_BTP", &handle); | 441 | status = acpi_get_handle(battery->device->handle, "_BTP", &handle); |
439 | if (ACPI_FAILURE(status)) { | 442 | if (ACPI_FAILURE(status)) { |
440 | battery->alarm_present = 0; | 443 | clear_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags); |
441 | return 0; | 444 | return 0; |
442 | } | 445 | } |
443 | battery->alarm_present = 1; | 446 | set_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags); |
444 | if (!battery->alarm) | 447 | if (!battery->alarm) |
445 | battery->alarm = battery->design_capacity_warning; | 448 | battery->alarm = battery->design_capacity_warning; |
446 | return acpi_battery_set_alarm(battery); | 449 | return acpi_battery_set_alarm(battery); |
@@ -510,9 +513,8 @@ static void sysfs_remove_battery(struct acpi_battery *battery) | |||
510 | 513 | ||
511 | static void acpi_battery_quirks(struct acpi_battery *battery) | 514 | static void acpi_battery_quirks(struct acpi_battery *battery) |
512 | { | 515 | { |
513 | battery->quirks = 0; | ||
514 | if (dmi_name_in_vendors("Acer") && battery->power_unit) { | 516 | if (dmi_name_in_vendors("Acer") && battery->power_unit) { |
515 | battery->quirks |= QUIRK_SIGNED16_CURRENT; | 517 | set_bit(ACPI_BATTERY_QUIRK_SIGNED16_CURRENT, &battery->flags); |
516 | } | 518 | } |
517 | } | 519 | } |
518 | 520 | ||