patch-2.4.22 linux-2.4.22/drivers/char/indydog.c

Next file: linux-2.4.22/drivers/char/ip27-rtc.c
Previous file: linux-2.4.22/drivers/char/dz.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.21/drivers/char/indydog.c linux-2.4.22/drivers/char/indydog.c
@@ -22,10 +22,9 @@
 #include <linux/smp_lock.h>
 #include <linux/init.h>
 #include <asm/uaccess.h>
-#include <asm/sgi/sgimc.h>
+#include <asm/sgi/mc.h>
 
 static unsigned long indydog_alive;
-static struct sgimc_misc_ctrl *mcmisc_regs; 
 static int expect_close = 0;
 
 #ifdef CONFIG_WATCHDOG_NOWAYOUT
@@ -37,56 +36,51 @@
 MODULE_PARM(nowayout,"i");
 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
 
-static void indydog_ping()
+static inline void indydog_ping(void)
 {
-	mcmisc_regs->watchdogt = 0;
+	sgimc->watchdogt = 0;
 }
 
-
 /*
  *	Allow only one person to hold it open
  */
-
 static int indydog_open(struct inode *inode, struct file *file)
 {
 	u32 mc_ctrl0;
 	
-	if( test_and_set_bit(0,&indydog_alive) )
+	if (test_and_set_bit(0,&indydog_alive))
 		return -EBUSY;
+
 	if (nowayout) {
 		MOD_INC_USE_COUNT;
 	}
-	/*
-	 *	Activate timer
-	 */
-	mcmisc_regs = (struct sgimc_misc_ctrl *)(KSEG1+0x1fa00000);
 
-	mc_ctrl0 = mcmisc_regs->cpuctrl0 | SGIMC_CCTRL0_WDOG;
-	mcmisc_regs->cpuctrl0 = mc_ctrl0;
+	/* Activate timer */
+	mc_ctrl0 = sgimc->cpuctrl0 | SGIMC_CCTRL0_WDOG;
+	sgimc->cpuctrl0 = mc_ctrl0;
 	indydog_ping();
 			
-	printk("Started watchdog timer.\n");
+	indydog_alive = 1;
+	printk(KERN_INFO "Started watchdog timer.\n");
+	
 	return 0;
 }
 
 static int indydog_release(struct inode *inode, struct file *file)
 {
-	/*
-	 *	Shut off the timer.
-	 * 	Lock it in if it's a module and we set nowayout.
-	 */
-	if (expect_close)
-	{
-		u32 mc_ctrl0 = mcmisc_regs->cpuctrl0; 
+	/* Shut off the timer.
+	 * Lock it in if it's a module and we set nowayout. */
+	lock_kernel();
+	if (expect_close) {
+		u32 mc_ctrl0 = sgimc->cpuctrl0;
 		mc_ctrl0 &= ~SGIMC_CCTRL0_WDOG;
-		mcmisc_regs->cpuctrl0 = mc_ctrl0;
-		printk("Stopped watchdog timer.\n");
-	}
-	else
-	{
+		sgimc->cpuctrl0 = mc_ctrl0;
+		printk(KERN_INFO "Stopped watchdog timer.\n");
+	} else
 		printk(KERN_CRIT "WDT device closed unexpectedly.  WDT will not stop!\n");
-	}
-	clear_bit(0,&indydog_alive);
+	clear_bit(0, &indydog_alive);
+	unlock_kernel();
+
 	return 0;
 }
 
@@ -99,13 +93,13 @@
 	/*
 	 *	Refresh the timer.
 	 */
-	if(len) {
+	if (len) {
 		if (!nowayout) {
 			size_t i;
 
 			/* In case it was set long ago */
 			expect_close = 0;
-
+ 
 			for (i = 0; i != len; i++) {
 				char c;
 				if (get_user(c, data + i))
@@ -161,9 +155,7 @@
 
 static int __init watchdog_init(void)
 {
-	int ret;
-
-	ret = misc_register(&indydog_miscdev);
+	int ret = misc_register(&indydog_miscdev);
 
 	if (ret)
 		return ret;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)