* [PATCH 2/6] ACPI / Battery: Change 16-bit signed negative battery current into correct value
@ 2011-06-29 8:22 Lan Tianyu
2011-06-29 15:11 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Lan Tianyu @ 2011-06-29 8:22 UTC (permalink / raw)
To: lenb; +Cc: linux-acpi, tianyu.lan, rui.zhang, stable
This patch is for some machine which report the battery current
as a 16-bit signed negative when it is charging. This is caused
by DSDT bug. The commit bc76f90b8a5cf4aceedf210d08d5e8292f820cec
has resolved the problem for Acer laptops. But some other machines
also have such problem.
https://bugzilla.kernel.org/show_bug.cgi?id=33722
Since it is improssible that the current is above 32A on laptops
whether on AC or on battery, this patch is to check the current and
take its absolute value as current and producing a message when it
is negative in s16.
Remove Acer quirk, as this workaround handles Acer too.
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
drivers/acpi/battery.c | 26 ++++++++++----------------
1 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 611434f..9db0c97 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -94,11 +94,6 @@ MODULE_DEVICE_TABLE(acpi, battery_device_ids);
enum {
ACPI_BATTERY_ALARM_PRESENT,
ACPI_BATTERY_XINFO_PRESENT,
- /* 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.
- */
- ACPI_BATTERY_QUIRK_SIGNED16_CURRENT,
ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY,
};
@@ -465,9 +460,17 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
battery->update_time = jiffies;
kfree(buffer.pointer);
- if (test_bit(ACPI_BATTERY_QUIRK_SIGNED16_CURRENT, &battery->flags) &&
- battery->rate_now != -1)
+ /* 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.
+ */
+ if (battery->power_unit == ACPI_BATTERY_POWER_UNIT_MA &&
+ (s16)(battery->rate_now) < 0 &&
+ battery->rate_now != ACPI_BATTERY_POWER_UNIT_MA) {
battery->rate_now = abs((s16)battery->rate_now);
+ printk_once(KERN_WARNING FW_BUG "battery: (dis)charge rate"
+ " invalid.\n");
+ }
if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)
&& battery->capacity_now >= 0 && battery->capacity_now <= 100)
@@ -577,14 +580,6 @@ static void sysfs_remove_battery(struct acpi_battery *battery)
battery->bat.dev = NULL;
}
-static void acpi_battery_quirks(struct acpi_battery *battery)
-{
- if (dmi_name_in_vendors("Acer") &&
- battery->power_unit == ACPI_BATTERY_POWER_UNIT_MA) {
- set_bit(ACPI_BATTERY_QUIRK_SIGNED16_CURRENT, &battery->flags);
- }
-}
-
/*
* According to the ACPI spec, some kinds of primary batteries can
* report percentage battery remaining capacity directly to OS.
@@ -628,7 +623,6 @@ 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);
}
if (!battery->bat.dev)
--
1.7.6.rc2.8.g28eb
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 2/6] ACPI / Battery: Change 16-bit signed negative battery current into correct value
2011-06-29 8:22 [PATCH 2/6] ACPI / Battery: Change 16-bit signed negative battery current into correct value Lan Tianyu
@ 2011-06-29 15:11 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2011-06-29 15:11 UTC (permalink / raw)
To: Lan Tianyu; +Cc: linux-acpi, rui.zhang, stable, lenb
On Wed, Jun 29, 2011 at 04:22:45PM +0800, Lan Tianyu wrote:
> This patch is for some machine which report the battery current
> as a 16-bit signed negative when it is charging. This is caused
> by DSDT bug. The commit bc76f90b8a5cf4aceedf210d08d5e8292f820cec
> has resolved the problem for Acer laptops. But some other machines
> also have such problem.
>
> https://bugzilla.kernel.org/show_bug.cgi?id=33722
>
> Since it is improssible that the current is above 32A on laptops
> whether on AC or on battery, this patch is to check the current and
> take its absolute value as current and producing a message when it
> is negative in s16.
>
> Remove Acer quirk, as this workaround handles Acer too.
>
> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
> ---
<formletter>
This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read Documentation/stable_kernel_rules.txt
for how to do this properly.
</formletter>
Same goes for the other patches in this series that you sent to
stable@kernel.org as well, please redo them.
_______________________________________________
stable mailing list
stable@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/stable
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-06-29 15:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-29 8:22 [PATCH 2/6] ACPI / Battery: Change 16-bit signed negative battery current into correct value Lan Tianyu
2011-06-29 15:11 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox