From 7f2876443622b5d07bad358639be452e34be427b Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Sun, 31 Jul 2022 09:30:39 -0600 Subject: [PATCH] battery: Fix condition to start/stop charging Change the condition, which is currently a level *at* which charging will start/stop. Per sysfs [1], these values are a level: - *below* which charging will begin - *above* which charging will stop [1]: https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-power Signed-off-by: Tim Crawford --- src/board/system76/common/battery.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/board/system76/common/battery.c b/src/board/system76/common/battery.c index a5579ca..7d3d27e 100644 --- a/src/board/system76/common/battery.c +++ b/src/board/system76/common/battery.c @@ -58,7 +58,7 @@ int16_t battery_charger_configure(void) { // Stop threshold not configured: Always charge on AC. should_charge = true; } - else if (battery_info.charge >= battery_get_end_threshold()) { + else if (battery_info.charge > battery_get_end_threshold()) { // Stop threshold configured: Stop charging at threshold. should_charge = false; } @@ -66,7 +66,7 @@ int16_t battery_charger_configure(void) { // Start threshold not configured: Always charge up to stop threshold. should_charge = true; } - else if (battery_info.charge <= battery_get_start_threshold()) { + else if (battery_info.charge < battery_get_start_threshold()) { // Start threshold configured: Start charging at threshold. should_charge = true; }