Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1345335 > unrolled thread

[PATCH] jz4740-battery: Correct voltage change check

Started byMaarten ter Huurne <maarten@treewalker.org>
First post2016-02-28 17:10 +0100
Last post2016-03-03 15:30 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] jz4740-battery: Correct voltage change check Maarten ter Huurne <maarten@treewalker.org> - 2016-02-28 17:10 +0100
    Re: [PATCH] jz4740-battery: Correct voltage change check Sebastian Reichel <sre@kernel.org> - 2016-03-03 15:30 +0100

#1345335 — [PATCH] jz4740-battery: Correct voltage change check

FromMaarten ter Huurne <maarten@treewalker.org>
Date2016-02-28 17:10 +0100
Subject[PATCH] jz4740-battery: Correct voltage change check
Message-ID<r7c4X-52Z-7@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1349218

FromSebastian Reichel <sre@kernel.org>
Date2016-03-03 15:30 +0100
Message-ID<r8Cqn-8hu-35@gated-at.bofh.it>
In reply to#1345335

[Multipart message — attachments visible in raw view] — view raw

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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web