Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 75464534 authored by Maarten ter Huurne's avatar Maarten ter Huurne Committed by Sebastian Reichel
Browse files

jz4740-battery: Correct voltage change check



The check is supposed to avoid redundant update notifications, so it
should check for the difference between old and new voltage exceeding
a threshold.

Also make sure the result of a failed read is never stored.

Signed-off-by: default avatarMaarten ter Huurne <maarten@treewalker.org>
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
parent 9052768f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -208,7 +208,7 @@ static void jz_battery_update(struct jz_battery *jz_battery)
	}

	voltage = jz_battery_read_voltage(jz_battery);
	if (abs(voltage - jz_battery->voltage) < 50000) {
	if (voltage >= 0 && abs(voltage - jz_battery->voltage) > 50000) {
		jz_battery->voltage = voltage;
		has_changed = true;
	}