Commit 7f344f0a authored by Linus Torvalds's avatar Linus Torvalds

Merge master.kernel.org:/pub/scm/linux/kernel/git/wim/linux-2.6-watchdog

* master.kernel.org:/pub/scm/linux/kernel/git/wim/linux-2.6-watchdog:
  [WATCHDOG] at91_wdt.c - Atmel AT91RM9200 watchdog driver
  [WATCHDOG] pcwd_usb.c: fix a NULL pointer dereference
  [WATCHDOG] pcwd.c sprintf/strcpy fix
  [WATCHDOG] pcwd.c general clean-up after patches
  [WATCHDOG] pcwd.c add debug info
  [WATCHDOG] pcwd.c pcwd_cleanup_module patch
  [WATCHDOG] pcwd.c firmware-info patch
  [WATCHDOG] pcwd.c control status patch
parents 63589ed0 853807fb
...@@ -60,6 +60,13 @@ config SOFT_WATCHDOG ...@@ -60,6 +60,13 @@ config SOFT_WATCHDOG
# ARM Architecture # ARM Architecture
config AT91_WATCHDOG
tristate "AT91RM9200 watchdog"
depends on WATCHDOG && ARCH_AT91RM9200
help
Watchdog timer embedded into AT91RM9200 chips. This will reboot your
system when the timeout is reached.
config 21285_WATCHDOG config 21285_WATCHDOG
tristate "DC21285 watchdog" tristate "DC21285 watchdog"
depends on WATCHDOG && FOOTBRIDGE depends on WATCHDOG && FOOTBRIDGE
......
...@@ -23,6 +23,7 @@ obj-$(CONFIG_WDTPCI) += wdt_pci.o ...@@ -23,6 +23,7 @@ obj-$(CONFIG_WDTPCI) += wdt_pci.o
obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o
# ARM Architecture # ARM Architecture
obj-$(CONFIG_AT91_WATCHDOG) += at91_wdt.o
obj-$(CONFIG_21285_WATCHDOG) += wdt285.o obj-$(CONFIG_21285_WATCHDOG) += wdt285.o
obj-$(CONFIG_977_WATCHDOG) += wdt977.o obj-$(CONFIG_977_WATCHDOG) += wdt977.o
obj-$(CONFIG_IXP2000_WATCHDOG) += ixp2000_wdt.o obj-$(CONFIG_IXP2000_WATCHDOG) += ixp2000_wdt.o
......
/*
* Watchdog driver for Atmel AT91RM9200 (Thunder)
*
* Copyright (C) 2003 SAN People (Pty) Ltd
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#include <linux/config.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/types.h>
#include <linux/watchdog.h>
#include <asm/bitops.h>
#include <asm/uaccess.h>
#define WDT_DEFAULT_TIME 5 /* 5 seconds */
#define WDT_MAX_TIME 256 /* 256 seconds */
static int wdt_time = WDT_DEFAULT_TIME;
static int nowayout = WATCHDOG_NOWAYOUT;
module_param(wdt_time, int, 0);
MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default="__MODULE_STRING(WDT_DEFAULT_TIME) ")");
module_param(nowayout, int, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
static unsigned long at91wdt_busy;
/* ......................................................................... */
/*
* Disable the watchdog.
*/
static void inline at91_wdt_stop(void)
{
at91_sys_write(AT91_ST_WDMR, AT91_ST_EXTEN);
}
/*
* Enable and reset the watchdog.
*/
static void inline at91_wdt_start(void)
{
at91_sys_write(AT91_ST_WDMR, AT91_ST_EXTEN | AT91_ST_RSTEN | (((65536 * wdt_time) >> 8) & AT91_ST_WDV));
at91_sys_write(AT91_ST_CR, AT91_ST_WDRST);
}
/*
* Reload the watchdog timer. (ie, pat the watchdog)
*/
static void inline at91_wdt_reload(void)
{
at91_sys_write(AT91_ST_CR, AT91_ST_WDRST);
}
/* ......................................................................... */
/*
* Watchdog device is opened, and watchdog starts running.
*/
static int at91_wdt_open(struct inode *inode, struct file *file)
{
if (test_and_set_bit(0, &at91wdt_busy))
return -EBUSY;
at91_wdt_start();
return nonseekable_open(inode, file);
}
/*
* Close the watchdog device.
* If CONFIG_WATCHDOG_NOWAYOUT is NOT defined then the watchdog is also
* disabled.
*/
static int at91_wdt_close(struct inode *inode, struct file *file)
{
if (!nowayout)
at91_wdt_stop(); /* Disable the watchdog when file is closed */
clear_bit(0, &at91wdt_busy);
return 0;
}
/*
* Change the watchdog time interval.
*/
static int at91_wdt_settimeout(int new_time)
{
/*
* All counting occurs at SLOW_CLOCK / 128 = 0.256 Hz
*
* Since WDV is a 16-bit counter, the maximum period is
* 65536 / 0.256 = 256 seconds.
*/
if ((new_time <= 0) || (new_time > WDT_MAX_TIME))
return -EINVAL;
/* Set new watchdog time. It will be used when at91_wdt_start() is called. */
wdt_time = new_time;
return 0;
}
static struct watchdog_info at91_wdt_info = {
.identity = "at91 watchdog",
.options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
};
/*
* Handle commands from user-space.
*/
static int at91_wdt_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
void __user *argp = (void __user *)arg;
int __user *p = argp;
int new_value;
switch(cmd) {
case WDIOC_KEEPALIVE:
at91_wdt_reload(); /* pat the watchdog */
return 0;
case WDIOC_GETSUPPORT:
return copy_to_user(argp, &at91_wdt_info, sizeof(at91_wdt_info)) ? -EFAULT : 0;
case WDIOC_SETTIMEOUT:
if (get_user(new_value, p))
return -EFAULT;
if (at91_wdt_settimeout(new_value))
return -EINVAL;
/* Enable new time value */
at91_wdt_start();
/* Return current value */
return put_user(wdt_time, p);
case WDIOC_GETTIMEOUT:
return put_user(wdt_time, p);
case WDIOC_GETSTATUS:
case WDIOC_GETBOOTSTATUS:
return put_user(0, p);
case WDIOC_SETOPTIONS:
if (get_user(new_value, p))
return -EFAULT;
if (new_value & WDIOS_DISABLECARD)
at91_wdt_stop();
if (new_value & WDIOS_ENABLECARD)
at91_wdt_start();
return 0;
default:
return -ENOIOCTLCMD;
}
}
/*
* Pat the watchdog whenever device is written to.
*/
static ssize_t at91_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos)
{
at91_wdt_reload(); /* pat the watchdog */
return len;
}
/* ......................................................................... */
static struct file_operations at91wdt_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.ioctl = at91_wdt_ioctl,
.open = at91_wdt_open,
.release = at91_wdt_close,
.write = at91_wdt_write,
};
static struct miscdevice at91wdt_miscdev = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &at91wdt_fops,
};
static int __init at91_wdt_init(void)
{
int res;
/* Check that the heartbeat value is within range; if not reset to the default */
if (at91_wdt_settimeout(wdt_time)) {
at91_wdt_settimeout(WDT_DEFAULT_TIME);
printk(KERN_INFO "at91_wdt: wdt_time value must be 1 <= wdt_time <= 256, using %d\n", wdt_time);
}
res = misc_register(&at91wdt_miscdev);
if (res)
return res;
printk("AT91 Watchdog Timer enabled (%d seconds, nowayout=%d)\n", wdt_time, nowayout);
return 0;
}
static void __exit at91_wdt_exit(void)
{
misc_deregister(&at91wdt_miscdev);
}
module_init(at91_wdt_init);
module_exit(at91_wdt_exit);
MODULE_AUTHOR("Andrew Victor");
MODULE_DESCRIPTION("Watchdog driver for Atmel AT91RM9200");
MODULE_LICENSE("GPL");
MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
This diff is collapsed.
...@@ -705,7 +705,8 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi ...@@ -705,7 +705,8 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
err_out_unregister_reboot: err_out_unregister_reboot:
unregister_reboot_notifier(&usb_pcwd_notifier); unregister_reboot_notifier(&usb_pcwd_notifier);
error: error:
usb_pcwd_delete (usb_pcwd); if (usb_pcwd)
usb_pcwd_delete(usb_pcwd);
usb_pcwd_device = NULL; usb_pcwd_device = NULL;
return retval; return retval;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment