mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [WATCHDOG] v2.6.33-rc8 - bfin_wdt.c : fix max timeout calculation
@ 2010-02-21 19:21 Wim Van Sebroeck
  0 siblings, 0 replies; only message in thread
From: Wim Van Sebroeck @ 2010-02-21 19:21 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, LKML, Mike Frysinger

Hi Linus,

Please pull from 'master' branch of
	git://git.kernel.org/pub/scm/linux/kernel/git/wim/linux-2.6-watchdog.git
or if master.kernel.org hasn't synced up yet:
	master.kernel.org:/pub/scm/linux/kernel/git/wim/linux-2.6-watchdog.git

This will update the following files:

 drivers/watchdog/bfin_wdt.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

with these Changes:

Author: Mike Frysinger <vapier@gentoo.org>
Date:   Mon Feb 15 19:32:25 2010 -0500

    [WATCHDOG] bfin: fix max timeout calculation
    
    Relying on overflow/wrap around isn't exact because if you wrap far
    enough, you get back to "valid" values.
    
    Reported-by: Thorsten Pohlmann <pohlmann@tetronik.com>
    Signed-off-by: Mike Frysinger <vapier@gentoo.org>
    Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
    Cc: stable <stable@kernel.org>

The Changes can also be looked at on:
	http://www.kernel.org/git/?p=linux/kernel/git/wim/linux-2.6-watchdog.git;a=summary

For completeness, I added the overal diff below.

Greetings,
Wim.

================================================================================
diff --git a/drivers/watchdog/bfin_wdt.c b/drivers/watchdog/bfin_wdt.c
index c7b3f9d..2159e66 100644
--- a/drivers/watchdog/bfin_wdt.c
+++ b/drivers/watchdog/bfin_wdt.c
@@ -1,9 +1,8 @@
 /*
  * Blackfin On-Chip Watchdog Driver
- *  Supports BF53[123]/BF53[467]/BF54[2489]/BF561
  *
  * Originally based on softdog.c
- * Copyright 2006-2007 Analog Devices Inc.
+ * Copyright 2006-2010 Analog Devices Inc.
  * Copyright 2006-2007 Michele d'Amico
  * Copyright 1996 Alan Cox <alan@lxorguk.ukuu.org.uk>
  *
@@ -137,13 +136,15 @@ static int bfin_wdt_running(void)
  */
 static int bfin_wdt_set_timeout(unsigned long t)
 {
-	u32 cnt;
+	u32 cnt, max_t, sclk;
 	unsigned long flags;
 
-	stampit();
+	sclk = get_sclk();
+	max_t = -1 / sclk;
+	cnt = t * sclk;
+	stamp("maxtimeout=%us newtimeout=%lus (cnt=%#x)", max_t, t, cnt);
 
-	cnt = t * get_sclk();
-	if (cnt < get_sclk()) {
+	if (t > max_t) {
 		printk(KERN_WARNING PFX "timeout value is too large\n");
 		return -EINVAL;
 	}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-02-21 19:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-21 19:21 [WATCHDOG] v2.6.33-rc8 - bfin_wdt.c : fix max timeout calculation Wim Van Sebroeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®