Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 82eb7c50 authored by Jiri Slaby's avatar Jiri Slaby Committed by Wim Van Sebroeck
Browse files

[WATCHDOG] timers cleanup



- Use timer macros to set function and data members and to modify
  expiration time.
- Use DEFINE_TIMER for single (platform dependent) watchdog timers and
  do not init them at run-time in these cases.
- del_timer_sync is common in most cases -- we want to wait for timer
  function if it's still running.

Signed-off-by: default avatarJiri Slaby <jirislaby@gmail.com>
Cc: Steve Hill <steve@navaho.co.uk>
Cc: Heiko Ronsdorf <hero@ihg.uni-duisburg.de>
Cc: Fernando Fuganti <fuganti@conectiva.com.br>
Cc: Gergely Madarasz <gorgo@itc.hu>
Cc: Ken Hollis <khollis@bitgate.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 35fcf538
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ module_param(use_gpio, int, 0);
MODULE_PARM_DESC(use_gpio, "Use the gpio watchdog.  (required by old cobalt boards)");

static void wdt_timer_ping(unsigned long);
static struct timer_list timer;
static DEFINE_TIMER(timer, wdt_timer_ping, 0, 1);
static unsigned long next_heartbeat;
static unsigned long wdt_is_open;
static char wdt_expect_close;
@@ -108,8 +108,7 @@ static void wdt_timer_ping(unsigned long data)
		printk(KERN_WARNING PFX "Heartbeat lost! Will not ping the watchdog\n");
	}
	/* Re-set the timer interval */
	timer.expires = jiffies + WDT_INTERVAL;
	add_timer(&timer);
	mod_timer(&timer, jiffies + WDT_INTERVAL);
}

/*
@@ -147,9 +146,7 @@ static void wdt_startup(void)
	wdt_change(WDT_ENABLE);

	/* Start the timer */
	timer.expires = jiffies + WDT_INTERVAL;
	add_timer(&timer);

	mod_timer(&timer, jiffies + WDT_INTERVAL);

	printk(KERN_INFO PFX "Watchdog timer is now enabled.\n");
}
@@ -380,10 +377,6 @@ static int __init alim7101_wdt_init(void)
			timeout);
	}

	init_timer(&timer);
	timer.function = wdt_timer_ping;
	timer.data = 1;

	rc = misc_register(&wdt_miscdev);
	if (rc) {
		printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
+4 −9
Original line number Diff line number Diff line
@@ -80,10 +80,8 @@ static void cpu5wdt_trigger(unsigned long unused)
	outb(1, port + CPU5WDT_TRIGGER_REG);

	/* requeue?? */
	if( cpu5wdt_device.queue && ticks ) {
		cpu5wdt_device.timer.expires = jiffies + CPU5WDT_INTERVAL;
		add_timer(&cpu5wdt_device.timer);
	}
	if (cpu5wdt_device.queue && ticks)
		mod_timer(&cpu5wdt_device.timer, jiffies + CPU5WDT_INTERVAL);
	else {
		/* ticks doesn't matter anyway */
		complete(&cpu5wdt_device.stop);
@@ -109,8 +107,7 @@ static void cpu5wdt_start(void)
		outb(1, port + CPU5WDT_MODE_REG);
		outb(0, port + CPU5WDT_RESET_REG);
		outb(0, port + CPU5WDT_ENABLE_REG);
		cpu5wdt_device.timer.expires = jiffies + CPU5WDT_INTERVAL;
		add_timer(&cpu5wdt_device.timer);
		mod_timer(&cpu5wdt_device.timer, jiffies + CPU5WDT_INTERVAL);
	}
	/* if process dies, counter is not decremented */
	cpu5wdt_device.running++;
@@ -245,9 +242,7 @@ static int __devinit cpu5wdt_init(void)

	clear_bit(0, &cpu5wdt_device.inuse);

	init_timer(&cpu5wdt_device.timer);
	cpu5wdt_device.timer.function = cpu5wdt_trigger;
	cpu5wdt_device.timer.data = 0;
	setup_timer(&cpu5wdt_device.timer, cpu5wdt_trigger, 0);

	cpu5wdt_device.default_ticks = ticks;

+5 −11
Original line number Diff line number Diff line
@@ -118,12 +118,14 @@ static int action = 0;
module_param(action, int, 0);
MODULE_PARM_DESC(action, "after watchdog resets, generate: 0 = RESET(*)  1 = SMI  2 = NMI  3 = SCI");

static void zf_ping(unsigned long data);

static int zf_action = GEN_RESET;
static unsigned long zf_is_open;
static char zf_expect_close;
static spinlock_t zf_lock;
static spinlock_t zf_port_lock;
static struct timer_list zf_timer;
static DEFINE_TIMER(zf_timer, zf_ping, 0, 0);
static unsigned long next_heartbeat = 0;


@@ -220,9 +222,7 @@ static void zf_timer_on(void)
	next_heartbeat = jiffies + ZF_USER_TIMEO;

	/* start the timer for internal ping */
	zf_timer.expires = jiffies + ZF_HW_TIMEO;

	add_timer(&zf_timer);
	mod_timer(&zf_timer, jiffies + ZF_HW_TIMEO);

	/* start watchdog timer */
	ctrl_reg = zf_get_control();
@@ -260,8 +260,7 @@ static void zf_ping(unsigned long data)
		zf_set_control(ctrl_reg);
		spin_unlock_irqrestore(&zf_port_lock, flags);

		zf_timer.expires = jiffies + ZF_HW_TIMEO;
		add_timer(&zf_timer);
		mod_timer(&zf_timer, jiffies + ZF_HW_TIMEO);
	}else{
		printk(KERN_CRIT PFX ": I will reset your machine\n");
	}
@@ -465,11 +464,6 @@ static int __init zf_init(void)
	zf_set_status(0);
	zf_set_control(0);

	/* this is the timer that will do the hard work */
	init_timer(&zf_timer);
	zf_timer.function = zf_ping;
	zf_timer.data = 0;

	return 0;

no_reboot:
+6 −8
Original line number Diff line number Diff line
@@ -56,11 +56,13 @@ static int mixcomwd_ioports[] = { 0x180, 0x280, 0x380, 0x000 };
#define FLASHCOM_WATCHDOG_OFFSET 0x4
#define FLASHCOM_ID 0x18

static void mixcomwd_timerfun(unsigned long d);

static unsigned long mixcomwd_opened; /* long req'd for setbit --RR */

static int watchdog_port;
static int mixcomwd_timer_alive;
static DEFINE_TIMER(mixcomwd_timer, NULL, 0, 0);
static DEFINE_TIMER(mixcomwd_timer, mixcomwd_timerfun, 0, 0);
static char expect_close;

static int nowayout = WATCHDOG_NOWAYOUT;
@@ -114,12 +116,8 @@ static int mixcomwd_release(struct inode *inode, struct file *file)
			printk(KERN_ERR "mixcomwd: release called while internal timer alive");
			return -EBUSY;
		}
		init_timer(&mixcomwd_timer);
		mixcomwd_timer.expires=jiffies + 5 * HZ;
		mixcomwd_timer.function=mixcomwd_timerfun;
		mixcomwd_timer.data=0;
		mixcomwd_timer_alive=1;
		add_timer(&mixcomwd_timer);
		mod_timer(&mixcomwd_timer, jiffies + 5 * HZ);
	} else {
		printk(KERN_CRIT "mixcomwd: WDT device closed unexpectedly.  WDT will not stop!\n");
	}
@@ -285,7 +283,7 @@ static void __exit mixcomwd_exit(void)
		if(mixcomwd_timer_alive) {
			printk(KERN_WARNING "mixcomwd: I quit now, hardware will"
			       " probably reboot!\n");
			del_timer(&mixcomwd_timer);
			del_timer_sync(&mixcomwd_timer);
			mixcomwd_timer_alive=0;
		}
	}
+1 −3
Original line number Diff line number Diff line
@@ -843,9 +843,7 @@ static int __devinit pcwatchdog_init(int base_addr)
	/* clear the "card caused reboot" flag */
	pcwd_clear_status();

	init_timer(&pcwd_private.timer);
	pcwd_private.timer.function = pcwd_timer_ping;
	pcwd_private.timer.data = 0;
	setup_timer(&pcwd_private.timer, pcwd_timer_ping, 0);

	/*  Disable the board  */
	pcwd_stop();
Loading