lkml.org 
[lkml]   [2010]   [Mar]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[004/145] [WATCHDOG] bfin: fix max timeout calculation
    2.6.32-stable review patch.  If anyone has any objections, please let me know.

    ----------------
    From: Mike Frysinger <vapier@gentoo.org>

    commit 3dae93ec3ee1fceec69f40ef9b97892ce62ba7a5 upstream.

    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>
    Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

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

    --- 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;
    }



    \
     
     \ /
      Last update: 2010-03-13 01:33    [W:4.141 / U:0.204 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site