* 2 of the License, or (at your option) any later version.
*
*/
-
#include <linux/module.h>
#include <linux/types.h>
#include <linux/fs.h>
#include <linux/miscdevice.h>
#include <linux/watchdog.h>
+#include <linux/irq.h>
#include <asm/bootinfo.h>
-#include <adm5120_info.h>
-#include <adm5120_defs.h>
-#include <adm5120_irq.h>
-#include <adm5120_switch.h>
-
+#include <asm/mach-adm5120/adm5120_info.h>
+#include <asm/mach-adm5120/adm5120_defs.h>
+#include <asm/mach-adm5120/adm5120_switch.h>
#define DEFAULT_TIMEOUT 15 /* (secs) Default is 15 seconds */
#define MAX_TIMEOUT 327
#define NAME "adm5120_wdt"
#define VERSION "0.1"
-static int expect_close = 0;
-static int access = 0;
+static int expect_close;
+static int access;
static unsigned int timeout = DEFAULT_TIMEOUT;
static int nowayout = WATCHDOG_NOWAYOUT;
if (access)
return -EBUSY;
- if (nowayout) {
+ if (nowayout)
__module_get(THIS_MODULE);
- }
/* Activate timer */
wdt_reset_counter();
static int wdt_release(struct inode *inode, struct file *file)
{
/*
- * Shut off the timer.
- * Lock it in if it's a module and we set nowayout
+ * Shut off the timer.
+ * Lock it in if it's a module and we set nowayout
*/
if (expect_close && (nowayout == 0)) {
wdt_disable();
printk(KERN_INFO NAME ": disabling watchdog timer\n");
module_put(THIS_MODULE);
- } else {
+ } else
printk(KERN_CRIT NAME ": device closed unexpectedly. WDT will not stop!\n");
- }
+
access = 0;
return 0;
}
.identity = "ADM5120_WDT Watchdog",
};
switch (cmd) {
- default:
- return -ENOTTY;
- case WDIOC_GETSUPPORT:
- if(copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident)))
- return -EFAULT;
- return 0;
- case WDIOC_GETSTATUS:
- case WDIOC_GETBOOTSTATUS:
- return put_user(0,(int *)arg);
- case WDIOC_KEEPALIVE:
- wdt_reset_counter();
- return 0;
- case WDIOC_SETTIMEOUT:
- if (get_user(new_timeout, (int *)arg))
- return -EFAULT;
- if (new_timeout < 1)
- return -EINVAL;
- if (new_timeout > MAX_TIMEOUT)
- return -EINVAL;
- timeout = new_timeout;
- wdt_set_timeout();
- /* Fall */
- case WDIOC_GETTIMEOUT:
- return put_user(timeout, (int *)arg);
+ default:
+ return -ENOTTY;
+ case WDIOC_GETSUPPORT:
+ if (copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident)))
+ return -EFAULT;
+ return 0;
+ case WDIOC_GETSTATUS:
+ case WDIOC_GETBOOTSTATUS:
+ return put_user(0, (int *)arg);
+ case WDIOC_KEEPALIVE:
+ wdt_reset_counter();
+ return 0;
+ case WDIOC_SETTIMEOUT:
+ if (get_user(new_timeout, (int *)arg))
+ return -EFAULT;
+ if (new_timeout < 1)
+ return -EINVAL;
+ if (new_timeout > MAX_TIMEOUT)
+ return -EINVAL;
+ timeout = new_timeout;
+ wdt_set_timeout();
+ /* Fall */
+ case WDIOC_GETTIMEOUT:
+ return put_user(timeout, (int *)arg);
}
}
-static struct file_operations wdt_fops = {
- owner: THIS_MODULE,
- llseek: no_llseek,
- write: wdt_write,
- ioctl: wdt_ioctl,
- open: wdt_open,
- release: wdt_release,
+static const struct file_operations wdt_fops = {
+ .owner = THIS_MODULE,
+ .llseek = no_llseek,
+ .write = wdt_write,
+ .ioctl = wdt_ioctl,
+ .open = wdt_open,
+ .release = wdt_release,
};
static struct miscdevice wdt_miscdev = {
- minor: WATCHDOG_MINOR,
- name: "watchdog",
- fops: &wdt_fops,
+ .minor = WATCHDOG_MINOR,
+ .name = "watchdog",
+ .fops = &wdt_fops,
};
static char banner[] __initdata = KERN_INFO NAME ": Watchdog Timer version " VERSION "\n";