* [PATCH] jz4740-battery: Correct voltage change check
@ 2016-02-28 16:05 Maarten ter Huurne
2016-03-03 14:21 ` Sebastian Reichel
0 siblings, 1 reply; 2+ messages in thread
From: Maarten ter Huurne @ 2016-02-28 16:05 UTC (permalink / raw)
To: Lars-Peter Clausen
Cc: Sebastian Reichel, Dmitry Eremin-Solenikov, David Woodhouse,
linux-pm, linux-kernel, Maarten ter Huurne
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>
---
drivers/power/jz4740-battery.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/power/jz4740-battery.c b/drivers/power/jz4740-battery.c
index abdfc21..88f04f4 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;
}
--
2.6.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] jz4740-battery: Correct voltage change check
2016-02-28 16:05 [PATCH] jz4740-battery: Correct voltage change check Maarten ter Huurne
@ 2016-03-03 14:21 ` Sebastian Reichel
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2016-03-03 14:21 UTC (permalink / raw)
To: Maarten ter Huurne
Cc: Lars-Peter Clausen, Dmitry Eremin-Solenikov, David Woodhouse,
linux-pm, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 339 bytes --]
Hi,
On Sun, Feb 28, 2016 at 05:05:48PM +0100, Maarten ter Huurne wrote:
> 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.
Thanks, queued.
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-03-03 14:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-28 16:05 [PATCH] jz4740-battery: Correct voltage change check Maarten ter Huurne
2016-03-03 14:21 ` Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).