Commit 01e4c5d3 authored by Linus Torvalds's avatar Linus Torvalds

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

* git://git.kernel.org/pub/scm/linux/kernel/git/wim/linux-2.6-watchdog:
  [WATCHDOG] omap_wdt.c: move probe function to .devinit.text
  [WATCHDOG] ks8695_wdt.c: move probe function to .devinit.text
  [WATCHDOG] at91rm9200_wdt.c: move probe function to .devinit.text
  [WATCHDOG] remove ARM26 sections
  [WATCHDOG] orion5x_wdt: Add shutdown callback, use watchdog ping function
  [WATCHDOG] i6300esb.c: Restructure initialization of the device
  [WATCHDOG] i6300esb.c: Fix the GETSTATUS and GETBOOTSTATUS ioctls.
  [WATCHDOG] i6300esb.c: Cleanup
parents cec5455e 3230e8cd
...@@ -240,8 +240,6 @@ config ORION5X_WATCHDOG ...@@ -240,8 +240,6 @@ config ORION5X_WATCHDOG
To compile this driver as a module, choose M here: the To compile this driver as a module, choose M here: the
module will be called orion5x_wdt. module will be called orion5x_wdt.
# ARM26 Architecture
# AVR32 Architecture # AVR32 Architecture
config AT32AP700X_WDT config AT32AP700X_WDT
......
...@@ -42,8 +42,6 @@ obj-$(CONFIG_IOP_WATCHDOG) += iop_wdt.o ...@@ -42,8 +42,6 @@ obj-$(CONFIG_IOP_WATCHDOG) += iop_wdt.o
obj-$(CONFIG_DAVINCI_WATCHDOG) += davinci_wdt.o obj-$(CONFIG_DAVINCI_WATCHDOG) += davinci_wdt.o
obj-$(CONFIG_ORION5X_WATCHDOG) += orion5x_wdt.o obj-$(CONFIG_ORION5X_WATCHDOG) += orion5x_wdt.o
# ARM26 Architecture
# AVR32 Architecture # AVR32 Architecture
obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o
......
...@@ -197,7 +197,7 @@ static struct miscdevice at91wdt_miscdev = { ...@@ -197,7 +197,7 @@ static struct miscdevice at91wdt_miscdev = {
.fops = &at91wdt_fops, .fops = &at91wdt_fops,
}; };
static int __init at91wdt_probe(struct platform_device *pdev) static int __devinit at91wdt_probe(struct platform_device *pdev)
{ {
int res; int res;
...@@ -214,7 +214,7 @@ static int __init at91wdt_probe(struct platform_device *pdev) ...@@ -214,7 +214,7 @@ static int __init at91wdt_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int __exit at91wdt_remove(struct platform_device *pdev) static int __devexit at91wdt_remove(struct platform_device *pdev)
{ {
int res; int res;
...@@ -252,7 +252,7 @@ static int at91wdt_resume(struct platform_device *pdev) ...@@ -252,7 +252,7 @@ static int at91wdt_resume(struct platform_device *pdev)
static struct platform_driver at91wdt_driver = { static struct platform_driver at91wdt_driver = {
.probe = at91wdt_probe, .probe = at91wdt_probe,
.remove = __exit_p(at91wdt_remove), .remove = __devexit_p(at91wdt_remove),
.shutdown = at91wdt_shutdown, .shutdown = at91wdt_shutdown,
.suspend = at91wdt_suspend, .suspend = at91wdt_suspend,
.resume = at91wdt_resume, .resume = at91wdt_resume,
......
...@@ -52,10 +52,10 @@ ...@@ -52,10 +52,10 @@
#define ESB_LOCK_REG 0x68 /* WDT lock register */ #define ESB_LOCK_REG 0x68 /* WDT lock register */
/* Memory mapped registers */ /* Memory mapped registers */
#define ESB_TIMER1_REG BASEADDR + 0x00 /* Timer1 value after each reset */ #define ESB_TIMER1_REG (BASEADDR + 0x00)/* Timer1 value after each reset */
#define ESB_TIMER2_REG BASEADDR + 0x04 /* Timer2 value after each reset */ #define ESB_TIMER2_REG (BASEADDR + 0x04)/* Timer2 value after each reset */
#define ESB_GINTSR_REG BASEADDR + 0x08 /* General Interrupt Status Register */ #define ESB_GINTSR_REG (BASEADDR + 0x08)/* General Interrupt Status Register */
#define ESB_RELOAD_REG BASEADDR + 0x0c /* Reload register */ #define ESB_RELOAD_REG (BASEADDR + 0x0c)/* Reload register */
/* Lock register bits */ /* Lock register bits */
#define ESB_WDT_FUNC (0x01 << 2) /* Watchdog functionality */ #define ESB_WDT_FUNC (0x01 << 2) /* Watchdog functionality */
...@@ -68,6 +68,7 @@ ...@@ -68,6 +68,7 @@
#define ESB_WDT_INTTYPE (0x11 << 0) /* Interrupt type on timer1 timeout */ #define ESB_WDT_INTTYPE (0x11 << 0) /* Interrupt type on timer1 timeout */
/* Reload register bits */ /* Reload register bits */
#define ESB_WDT_TIMEOUT (0x01 << 9) /* Watchdog timed out */
#define ESB_WDT_RELOAD (0x01 << 8) /* prevent timeout */ #define ESB_WDT_RELOAD (0x01 << 8) /* prevent timeout */
/* Magic constants */ /* Magic constants */
...@@ -87,7 +88,6 @@ static struct platform_device *esb_platform_device; ...@@ -87,7 +88,6 @@ static struct platform_device *esb_platform_device;
/* 30 sec default heartbeat (1 < heartbeat < 2*1023) */ /* 30 sec default heartbeat (1 < heartbeat < 2*1023) */
#define WATCHDOG_HEARTBEAT 30 #define WATCHDOG_HEARTBEAT 30
static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */ static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */
module_param(heartbeat, int, 0); module_param(heartbeat, int, 0);
MODULE_PARM_DESC(heartbeat, MODULE_PARM_DESC(heartbeat,
"Watchdog heartbeat in seconds. (1<heartbeat<2046, default=" "Watchdog heartbeat in seconds. (1<heartbeat<2046, default="
...@@ -123,7 +123,7 @@ static int esb_timer_start(void) ...@@ -123,7 +123,7 @@ static int esb_timer_start(void)
esb_unlock_registers(); esb_unlock_registers();
writew(ESB_WDT_RELOAD, ESB_RELOAD_REG); writew(ESB_WDT_RELOAD, ESB_RELOAD_REG);
/* Enable or Enable + Lock? */ /* Enable or Enable + Lock? */
val = 0x02 | (nowayout ? 0x01 : 0x00); val = ESB_WDT_ENABLE | (nowayout ? ESB_WDT_LOCK : 0x00);
pci_write_config_byte(esb_pci, ESB_LOCK_REG, val); pci_write_config_byte(esb_pci, ESB_LOCK_REG, val);
spin_unlock(&esb_lock); spin_unlock(&esb_lock);
return 0; return 0;
...@@ -143,7 +143,7 @@ static int esb_timer_stop(void) ...@@ -143,7 +143,7 @@ static int esb_timer_stop(void)
spin_unlock(&esb_lock); spin_unlock(&esb_lock);
/* Returns 0 if the timer was disabled, non-zero otherwise */ /* Returns 0 if the timer was disabled, non-zero otherwise */
return (val & 0x01); return val & ESB_WDT_ENABLE;
} }
static void esb_timer_keepalive(void) static void esb_timer_keepalive(void)
...@@ -190,18 +190,6 @@ static int esb_timer_set_heartbeat(int time) ...@@ -190,18 +190,6 @@ static int esb_timer_set_heartbeat(int time)
return 0; return 0;
} }
static int esb_timer_read(void)
{
u32 count;
/* This isn't documented, and doesn't take into
* acount which stage is running, but it looks
* like a 20 bit count down, so we might as well report it.
*/
pci_read_config_dword(esb_pci, 0x64, &count);
return (int)count;
}
/* /*
* /dev/watchdog handling * /dev/watchdog handling
*/ */
...@@ -282,7 +270,7 @@ static long esb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -282,7 +270,7 @@ static long esb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
sizeof(ident)) ? -EFAULT : 0; sizeof(ident)) ? -EFAULT : 0;
case WDIOC_GETSTATUS: case WDIOC_GETSTATUS:
return put_user(esb_timer_read(), p); return put_user(0, p);
case WDIOC_GETBOOTSTATUS: case WDIOC_GETBOOTSTATUS:
return put_user(triggered, p); return put_user(triggered, p);
...@@ -362,8 +350,6 @@ MODULE_DEVICE_TABLE(pci, esb_pci_tbl); ...@@ -362,8 +350,6 @@ MODULE_DEVICE_TABLE(pci, esb_pci_tbl);
static unsigned char __devinit esb_getdevice(void) static unsigned char __devinit esb_getdevice(void)
{ {
u8 val1;
unsigned short val2;
/* /*
* Find the PCI device * Find the PCI device
*/ */
...@@ -371,66 +357,79 @@ static unsigned char __devinit esb_getdevice(void) ...@@ -371,66 +357,79 @@ static unsigned char __devinit esb_getdevice(void)
esb_pci = pci_get_device(PCI_VENDOR_ID_INTEL, esb_pci = pci_get_device(PCI_VENDOR_ID_INTEL,
PCI_DEVICE_ID_INTEL_ESB_9, NULL); PCI_DEVICE_ID_INTEL_ESB_9, NULL);
if (esb_pci) { if (!esb_pci)
if (pci_enable_device(esb_pci)) { return 0;
printk(KERN_ERR PFX "failed to enable device\n");
goto err_devput;
}
if (pci_request_region(esb_pci, 0, ESB_MODULE_NAME)) { if (pci_enable_device(esb_pci)) {
printk(KERN_ERR PFX "failed to request region\n"); printk(KERN_ERR PFX "failed to enable device\n");
goto err_disable; goto err_devput;
} }
BASEADDR = pci_ioremap_bar(esb_pci, 0); if (pci_request_region(esb_pci, 0, ESB_MODULE_NAME)) {
if (BASEADDR == NULL) { printk(KERN_ERR PFX "failed to request region\n");
/* Something's wrong here, BASEADDR has to be set */ goto err_disable;
printk(KERN_ERR PFX "failed to get BASEADDR\n"); }
goto err_release;
}
/* BASEADDR = pci_ioremap_bar(esb_pci, 0);
* The watchdog has two timers, it can be setup so that the if (BASEADDR == NULL) {
* expiry of timer1 results in an interrupt and the expiry of /* Something's wrong here, BASEADDR has to be set */
* timer2 results in a reboot. We set it to not generate printk(KERN_ERR PFX "failed to get BASEADDR\n");
* any interrupts as there is not much we can do with it goto err_release;
* right now. }
*
* We also enable reboots and set the timer frequency to /* Done */
* the PCI clock divided by 2^15 (approx 1KHz). return 1;
*/
pci_write_config_word(esb_pci, ESB_CONFIG_REG, 0x0003);
/* Check that the WDT isn't already locked */
pci_read_config_byte(esb_pci, ESB_LOCK_REG, &val1);
if (val1 & ESB_WDT_LOCK)
printk(KERN_WARNING PFX "nowayout already set\n");
/* Set the timer to watchdog mode and disable it for now */
pci_write_config_byte(esb_pci, ESB_LOCK_REG, 0x00);
/* Check if the watchdog was previously triggered */
esb_unlock_registers();
val2 = readw(ESB_RELOAD_REG);
triggered = (val2 & (0x01 << 9) >> 9);
/* Reset trigger flag and timers */
esb_unlock_registers();
writew((0x11 << 8), ESB_RELOAD_REG);
/* Done */
return 1;
err_release: err_release:
pci_release_region(esb_pci, 0); pci_release_region(esb_pci, 0);
err_disable: err_disable:
pci_disable_device(esb_pci); pci_disable_device(esb_pci);
err_devput: err_devput:
pci_dev_put(esb_pci); pci_dev_put(esb_pci);
}
return 0; return 0;
} }
static void __devinit esb_initdevice(void)
{
u8 val1;
u16 val2;
/*
* Config register:
* Bit 5 : 0 = Enable WDT_OUTPUT
* Bit 2 : 0 = set the timer frequency to the PCI clock
* divided by 2^15 (approx 1KHz).
* Bits 1:0 : 11 = WDT_INT_TYPE Disabled.
* The watchdog has two timers, it can be setup so that the
* expiry of timer1 results in an interrupt and the expiry of
* timer2 results in a reboot. We set it to not generate
* any interrupts as there is not much we can do with it
* right now.
*/
pci_write_config_word(esb_pci, ESB_CONFIG_REG, 0x0003);
/* Check that the WDT isn't already locked */
pci_read_config_byte(esb_pci, ESB_LOCK_REG, &val1);
if (val1 & ESB_WDT_LOCK)
printk(KERN_WARNING PFX "nowayout already set\n");
/* Set the timer to watchdog mode and disable it for now */
pci_write_config_byte(esb_pci, ESB_LOCK_REG, 0x00);
/* Check if the watchdog was previously triggered */
esb_unlock_registers();
val2 = readw(ESB_RELOAD_REG);
if (val2 & ESB_WDT_TIMEOUT)
triggered = WDIOF_CARDRESET;
/* Reset WDT_TIMEOUT flag and timers */
esb_unlock_registers();
writew((ESB_WDT_TIMEOUT | ESB_WDT_RELOAD), ESB_RELOAD_REG);
/* And set the correct timeout value */
esb_timer_set_heartbeat(heartbeat);
}
static int __devinit esb_probe(struct platform_device *dev) static int __devinit esb_probe(struct platform_device *dev)
{ {
int ret; int ret;
...@@ -441,13 +440,17 @@ static int __devinit esb_probe(struct platform_device *dev) ...@@ -441,13 +440,17 @@ static int __devinit esb_probe(struct platform_device *dev)
/* Check that the heartbeat value is within it's range; /* Check that the heartbeat value is within it's range;
if not reset to the default */ if not reset to the default */
if (esb_timer_set_heartbeat(heartbeat)) { if (heartbeat < 0x1 || heartbeat > 2 * 0x03ff) {
esb_timer_set_heartbeat(WATCHDOG_HEARTBEAT); heartbeat = WATCHDOG_HEARTBEAT;
printk(KERN_INFO PFX printk(KERN_INFO PFX
"heartbeat value must be 1<heartbeat<2046, using %d\n", "heartbeat value must be 1<heartbeat<2046, using %d\n",
heartbeat); heartbeat);
} }
/* Initialize the watchdog and make sure it does not run */
esb_initdevice();
/* Register the watchdog so that userspace has access to it */
ret = misc_register(&esb_miscdev); ret = misc_register(&esb_miscdev);
if (ret != 0) { if (ret != 0) {
printk(KERN_ERR PFX printk(KERN_ERR PFX
...@@ -455,7 +458,6 @@ static int __devinit esb_probe(struct platform_device *dev) ...@@ -455,7 +458,6 @@ static int __devinit esb_probe(struct platform_device *dev)
WATCHDOG_MINOR, ret); WATCHDOG_MINOR, ret);
goto err_unmap; goto err_unmap;
} }
esb_timer_stop();
printk(KERN_INFO PFX printk(KERN_INFO PFX
"initialized (0x%p). heartbeat=%d sec (nowayout=%d)\n", "initialized (0x%p). heartbeat=%d sec (nowayout=%d)\n",
BASEADDR, heartbeat, nowayout); BASEADDR, heartbeat, nowayout);
...@@ -463,11 +465,8 @@ static int __devinit esb_probe(struct platform_device *dev) ...@@ -463,11 +465,8 @@ static int __devinit esb_probe(struct platform_device *dev)
err_unmap: err_unmap:
iounmap(BASEADDR); iounmap(BASEADDR);
/* err_release: */
pci_release_region(esb_pci, 0); pci_release_region(esb_pci, 0);
/* err_disable: */
pci_disable_device(esb_pci); pci_disable_device(esb_pci);
/* err_devput: */
pci_dev_put(esb_pci); pci_dev_put(esb_pci);
return ret; return ret;
} }
......
...@@ -221,7 +221,7 @@ static struct miscdevice ks8695wdt_miscdev = { ...@@ -221,7 +221,7 @@ static struct miscdevice ks8695wdt_miscdev = {
.fops = &ks8695wdt_fops, .fops = &ks8695wdt_fops,
}; };
static int __init ks8695wdt_probe(struct platform_device *pdev) static int __devinit ks8695wdt_probe(struct platform_device *pdev)
{ {
int res; int res;
...@@ -238,7 +238,7 @@ static int __init ks8695wdt_probe(struct platform_device *pdev) ...@@ -238,7 +238,7 @@ static int __init ks8695wdt_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int __exit ks8695wdt_remove(struct platform_device *pdev) static int __devexit ks8695wdt_remove(struct platform_device *pdev)
{ {
int res; int res;
...@@ -276,7 +276,7 @@ static int ks8695wdt_resume(struct platform_device *pdev) ...@@ -276,7 +276,7 @@ static int ks8695wdt_resume(struct platform_device *pdev)
static struct platform_driver ks8695wdt_driver = { static struct platform_driver ks8695wdt_driver = {
.probe = ks8695wdt_probe, .probe = ks8695wdt_probe,
.remove = __exit_p(ks8695wdt_remove), .remove = __devexit_p(ks8695wdt_remove),
.shutdown = ks8695wdt_shutdown, .shutdown = ks8695wdt_shutdown,
.suspend = ks8695wdt_suspend, .suspend = ks8695wdt_suspend,
.resume = ks8695wdt_resume, .resume = ks8695wdt_resume,
......
...@@ -258,7 +258,7 @@ static const struct file_operations omap_wdt_fops = { ...@@ -258,7 +258,7 @@ static const struct file_operations omap_wdt_fops = {
.release = omap_wdt_release, .release = omap_wdt_release,
}; };
static int __init omap_wdt_probe(struct platform_device *pdev) static int __devinit omap_wdt_probe(struct platform_device *pdev)
{ {
struct resource *res, *mem; struct resource *res, *mem;
struct omap_wdt_dev *wdev; struct omap_wdt_dev *wdev;
...@@ -367,7 +367,7 @@ static void omap_wdt_shutdown(struct platform_device *pdev) ...@@ -367,7 +367,7 @@ static void omap_wdt_shutdown(struct platform_device *pdev)
omap_wdt_disable(wdev); omap_wdt_disable(wdev);
} }
static int omap_wdt_remove(struct platform_device *pdev) static int __devexit omap_wdt_remove(struct platform_device *pdev)
{ {
struct omap_wdt_dev *wdev = platform_get_drvdata(pdev); struct omap_wdt_dev *wdev = platform_get_drvdata(pdev);
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
...@@ -426,7 +426,7 @@ static int omap_wdt_resume(struct platform_device *pdev) ...@@ -426,7 +426,7 @@ static int omap_wdt_resume(struct platform_device *pdev)
static struct platform_driver omap_wdt_driver = { static struct platform_driver omap_wdt_driver = {
.probe = omap_wdt_probe, .probe = omap_wdt_probe,
.remove = omap_wdt_remove, .remove = __devexit_p(omap_wdt_remove),
.shutdown = omap_wdt_shutdown, .shutdown = omap_wdt_shutdown,
.suspend = omap_wdt_suspend, .suspend = omap_wdt_suspend,
.resume = omap_wdt_resume, .resume = omap_wdt_resume,
......
...@@ -42,7 +42,17 @@ static unsigned int wdt_tclk; ...@@ -42,7 +42,17 @@ static unsigned int wdt_tclk;
static unsigned long wdt_status; static unsigned long wdt_status;
static spinlock_t wdt_lock; static spinlock_t wdt_lock;
static void wdt_enable(void) static void orion5x_wdt_ping(void)
{
spin_lock(&wdt_lock);
/* Reload watchdog duration */
writel(wdt_tclk * heartbeat, WDT_VAL);
spin_unlock(&wdt_lock);
}
static void orion5x_wdt_enable(void)
{ {
u32 reg; u32 reg;
...@@ -69,7 +79,7 @@ static void wdt_enable(void) ...@@ -69,7 +79,7 @@ static void wdt_enable(void)
spin_unlock(&wdt_lock); spin_unlock(&wdt_lock);
} }
static void wdt_disable(void) static void orion5x_wdt_disable(void)
{ {
u32 reg; u32 reg;
...@@ -101,7 +111,7 @@ static int orion5x_wdt_open(struct inode *inode, struct file *file) ...@@ -101,7 +111,7 @@ static int orion5x_wdt_open(struct inode *inode, struct file *file)
if (test_and_set_bit(WDT_IN_USE, &wdt_status)) if (test_and_set_bit(WDT_IN_USE, &wdt_status))
return -EBUSY; return -EBUSY;
clear_bit(WDT_OK_TO_CLOSE, &wdt_status); clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
wdt_enable(); orion5x_wdt_enable();
return nonseekable_open(inode, file); return nonseekable_open(inode, file);
} }
...@@ -122,18 +132,28 @@ static ssize_t orion5x_wdt_write(struct file *file, const char *data, ...@@ -122,18 +132,28 @@ static ssize_t orion5x_wdt_write(struct file *file, const char *data,
set_bit(WDT_OK_TO_CLOSE, &wdt_status); set_bit(WDT_OK_TO_CLOSE, &wdt_status);
} }
} }
wdt_enable(); orion5x_wdt_ping();
} }
return len; return len;
} }
static struct watchdog_info ident = { static int orion5x_wdt_settimeout(int new_time)
{
if ((new_time <= 0) || (new_time > wdt_max_duration))
return -EINVAL;
/* Set new watchdog time to be used when
* orion5x_wdt_enable() or orion5x_wdt_ping() is called. */
heartbeat = new_time;
return 0;
}
static const struct watchdog_info ident = {
.options = WDIOF_MAGICCLOSE | WDIOF_SETTIMEOUT | .options = WDIOF_MAGICCLOSE | WDIOF_SETTIMEOUT |
WDIOF_KEEPALIVEPING, WDIOF_KEEPALIVEPING,
.identity = "Orion5x Watchdog", .identity = "Orion5x Watchdog",
}; };
static long orion5x_wdt_ioctl(struct file *file, unsigned int cmd, static long orion5x_wdt_ioctl(struct file *file, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
...@@ -152,7 +172,7 @@ static long orion5x_wdt_ioctl(struct file *file, unsigned int cmd, ...@@ -152,7 +172,7 @@ static long orion5x_wdt_ioctl(struct file *file, unsigned int cmd,
break; break;
case WDIOC_KEEPALIVE: case WDIOC_KEEPALIVE:
wdt_enable(); orion5x_wdt_ping();
ret = 0; ret = 0;
break; break;
...@@ -161,12 +181,11 @@ static long orion5x_wdt_ioctl(struct file *file, unsigned int cmd, ...@@ -161,12 +181,11 @@ static long orion5x_wdt_ioctl(struct file *file, unsigned int cmd,
if (ret) if (ret)
break; break;
if (time <= 0 || time > wdt_max_duration) { if (orion5x_wdt_settimeout(time)) {
ret = -EINVAL; ret = -EINVAL;
break; break;
} }
heartbeat = time; orion5x_wdt_ping();
wdt_enable();
/* Fall through */ /* Fall through */
case WDIOC_GETTIMEOUT: case WDIOC_GETTIMEOUT:
...@@ -187,7 +206,7 @@ static long orion5x_wdt_ioctl(struct file *file, unsigned int cmd, ...@@ -187,7 +206,7 @@ static long orion5x_wdt_ioctl(struct file *file, unsigned int cmd,
static int orion5x_wdt_release(struct inode *inode, struct file *file) static int orion5x_wdt_release(struct inode *inode, struct file *file)
{ {
if (test_bit(WDT_OK_TO_CLOSE, &wdt_status)) if (test_bit(WDT_OK_TO_CLOSE, &wdt_status))
wdt_disable(); orion5x_wdt_disable();
else else
printk(KERN_CRIT "WATCHDOG: Device closed unexpectedly - " printk(KERN_CRIT "WATCHDOG: Device closed unexpectedly - "
"timer will not stop\n"); "timer will not stop\n");
...@@ -230,7 +249,7 @@ static int __devinit orion5x_wdt_probe(struct platform_device *pdev) ...@@ -230,7 +249,7 @@ static int __devinit orion5x_wdt_probe(struct platform_device *pdev)
orion5x_wdt_miscdev.parent = &pdev->dev; orion5x_wdt_miscdev.parent = &pdev->dev;
wdt_max_duration = WDT_MAX_CYCLE_COUNT / wdt_tclk; wdt_max_duration = WDT_MAX_CYCLE_COUNT / wdt_tclk;
if (heartbeat <= 0 || heartbeat > wdt_max_duration) if (orion5x_wdt_settimeout(heartbeat))
heartbeat = wdt_max_duration; heartbeat = wdt_max_duration;
ret = misc_register(&orion5x_wdt_miscdev); ret = misc_register(&orion5x_wdt_miscdev);
...@@ -247,7 +266,7 @@ static int __devexit orion5x_wdt_remove(struct platform_device *pdev) ...@@ -247,7 +266,7 @@ static int __devexit orion5x_wdt_remove(struct platform_device *pdev)
int ret; int ret;
if (test_bit(WDT_IN_USE, &wdt_status)) { if (test_bit(WDT_IN_USE, &wdt_status)) {
wdt_disable(); orion5x_wdt_disable();
clear_bit(WDT_IN_USE, &wdt_status); clear_bit(WDT_IN_USE, &wdt_status);
} }
...@@ -258,9 +277,16 @@ static int __devexit orion5x_wdt_remove(struct platform_device *pdev) ...@@ -258,9 +277,16 @@ static int __devexit orion5x_wdt_remove(struct platform_device *pdev)
return ret; return ret;
} }
static void orion5x_wdt_shutdown(struct platform_device *pdev)
{
if (test_bit(WDT_IN_USE, &wdt_status))
orion5x_wdt_disable();
}
static struct platform_driver orion5x_wdt_driver = { static struct platform_driver orion5x_wdt_driver = {
.probe = orion5x_wdt_probe, .probe = orion5x_wdt_probe,
.remove = __devexit_p(orion5x_wdt_remove), .remove = __devexit_p(orion5x_wdt_remove),
.shutdown = orion5x_wdt_shutdown,
.driver = { .driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "orion5x_wdt", .name = "orion5x_wdt",
...@@ -285,10 +311,11 @@ MODULE_AUTHOR("Sylver Bruneau <sylver.bruneau@googlemail.com>"); ...@@ -285,10 +311,11 @@ MODULE_AUTHOR("Sylver Bruneau <sylver.bruneau@googlemail.com>");
MODULE_DESCRIPTION("Orion5x Processor Watchdog"); MODULE_DESCRIPTION("Orion5x Processor Watchdog");
module_param(heartbeat, int, 0); module_param(heartbeat, int, 0);
MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds"); MODULE_PARM_DESC(heartbeat, "Initial watchdog heartbeat in seconds");
module_param(nowayout, int, 0); module_param(nowayout, int, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started"); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
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