lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1386419801-10091-1-git-send-email-jan.vcelak@nic.cz>
Date:	Sat,  7 Dec 2013 13:36:41 +0100
From:	Jan Vcelak <jan.vcelak@....cz>
To:	lenb@...nel.org, rjw@...ysocki.net, linux-acpi@...r.kernel.org
Cc:	linux-kernel@...r.kernel.org
Subject: [PATCH] ACPI: full battery charge cannot exceed current one

Some degraded batteries report maximal capacity to be smaller than
current charge of the battery. This can confuse some user space
applications (like upower).

This patch handles the situation by increasing maximal capacity
of the battery if it exceedes current charge.

Signed-off-by: Jan Vcelak <jan.vcelak@....cz>
---

upower: fully charged battery reported as 0% charged
https://bugzilla.redhat.com/show_bug.cgi?id=1025980

 drivers/acpi/battery.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index fbf1ace..71ec1f6 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -494,6 +494,11 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
 		battery->capacity_now = battery->capacity_now *
 		    10000 / battery->design_voltage;
 	}
+
+	/* Some degraded batteries report lower full charge than current one. */
+	if (battery->capacity_now > battery->full_charge_capacity)
+		battery->full_charge_capacity = battery->capacity_now;
+
 	return result;
 }
 
-- 
1.8.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ