summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorMaarten ter Huurne <maarten@treewalker.org>2016-02-28 19:05:48 +0300
committerSebastian Reichel <sre@kernel.org>2016-03-03 17:05:08 +0300
commit754645342a35e422782f7a59545448ff9e933739 (patch)
tree74837f3873a2d34b2d089b13d48dbe2321386312 /drivers/power
parent9052768fe4a4ca773e48654b1dc4297a298e76b9 (diff)
downloadlinux-754645342a35e422782f7a59545448ff9e933739.tar.xz
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: Maarten ter Huurne <maarten@treewalker.org> Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/jz4740-battery.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/power/jz4740-battery.c b/drivers/power/jz4740-battery.c
index abdfc21ec13f..88f04f4d1a70 100644
--- a/drivers/power/jz4740-battery.c
+++ b/drivers/power/jz4740-battery.c
@@ -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;
}