From: Josef Gajdusek <atx@atx.name>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: lenb@kernel.org, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] acpi/battery: fix wrong value of capacity_now reported by few battery types when fully charged (resend)
Date: Tue, 17 Jun 2014 23:15:49 +0200 [thread overview]
Message-ID: <20140617211549.GB6988@dashie> (raw)
In-Reply-To: <2828453.ZgdXeiReHi@vostro.rjw.lan>
It seems that some batteries (noticed on DELL JYPJ136) assume
capacity_now = design_capacity when fully charged. This causes
reported capacity to suddenly jump to >full_charge_capacity (and that
means capacity reported to userspace is >100% and incorrect)
values after 99%. This patch detects capacity_now > full_charge_capacity,
notifies userspace (unless it is the known bug where capacity_now ==
design_capacity) and trims the value to full_charge_capacity.
Signed-off-by: Josef Gajdusek <atx@atx.name>
---
> Thinking more about the printk_once(). Perhaps it only needs to be printed
> when battery->capacity_now != battery->design_capacity (it's a known issue
> otherwise).
Changed. That was actually what I wanted to do originally, but I was unsure
about the kernel policy on this sort of messages.
>> + printk_once(KERN_WARNING FW_BUG
>> + "battery: reported current charge level (%d) "
>> + "is higher than reported maximum charge level (%d)."
>> + "This is normal on some systems.\n",
>
> Also I think that the line above doesn't add any real value. :-)
Removed, now it really is not needed as there is not any known system for which
capacity_now > full_charge_capacity && capacity_now != design_capacity would be
considered "normal"
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index e48fc98..9cacabd 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -532,6 +532,19 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
" invalid.\n");
}
+ /* When fully charged, some batteries wrongly report
+ * capacity_now = design_capacity instead of = full_charge_capacity
+ */
+ if (battery->capacity_now > battery->full_charge_capacity &&
+ battery->full_charge_capacity != ACPI_BATTERY_VALUE_UNKNOWN) {
+ battery->capacity_now = battery->full_charge_capacity;
+ if (battery->capacity_now != battery->design_capacity)
+ printk_once(KERN_WARNING FW_BUG
+ "battery: reported current charge level (%d) "
+ "is higher than reported maximum charge level (%d).\n",
+ battery->capacity_now, battery->full_charge_capacity);
+ }
+
if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)
&& battery->capacity_now >= 0 && battery->capacity_now <= 100)
battery->capacity_now = (battery->capacity_now *
prev parent reply other threads:[~2014-06-17 21:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-12 14:58 [PATCH] acpi/battery: fix wrong value of capacity_now reported by few battery types when fully charged (resend) Josef Gajdusek
2014-06-17 12:09 ` Rafael J. Wysocki
2014-06-17 16:41 ` Josef Gajdusek
2014-06-17 20:07 ` Rafael J. Wysocki
2014-06-17 20:14 ` Josef Gajdusek
2014-06-17 21:04 ` Rafael J. Wysocki
2014-06-17 21:15 ` Josef Gajdusek [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140617211549.GB6988@dashie \
--to=atx@atx.name \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rjw@rjwysocki.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox