Commit 750f7706 authored by Linus Torvalds's avatar Linus Torvalds

Merge git://www.linux-watchdog.org/linux-watchdog

Pull watchdog updates from Wim Van Sebroeck:
 - Removal of the Documentation/watchdog/00-INDEX file
 - Fix boot status reporting for imx2_wdt
 - clean-up sp805_wdt, pnx4008_wdt and mpcore_wdt
 - convert printk in watchdog drivers to pr_ functions
 - change nowayout module parameter to bool for every watchdog device
 - conversion of jz4740_wdt, pnx4008_wdt, max63xx_wdt, softdog,
   ep93xx_wdt, coh901327 and txx9wdt to new watchdog API
 - Add support for the WDIOC_GETTIMELEFT ioctl call to the new watchdog
   API
 - Change the new watchdog API so that the driver updates the timeout
   value
 - two fixes for the xen_wdt driver

Fix up conflicts in ep93xx driver due to the same patches being merged
through separate branches.

* git://www.linux-watchdog.org/linux-watchdog: (33 commits)
  watchdog: txx9wdt: fix timeout
  watchdog: Convert txx9wdt driver to watchdog framework
  watchdog: coh901327_wdt.c: fix timeout
  watchdog: coh901327: convert to use watchdog core
  watchdog: Add support for WDIOC_GETTIMELEFT IOCTL in watchdog core
  watchdog: ep93xx_wdt: timeout is an unsigned int value.
  watchdog: ep93xx_wdt: Fix timeout after conversion to watchdog core
  watchdog: Convert ep93xx driver to watchdog core
  watchdog: sp805: Use devm routines
  watchdog: sp805: replace readl/writel with lighter _relaxed variants
  watchdog: sp805: Fix documentation style comment
  watchdog: mpcore_wdt: Allow platform_get_irq() to fail
  watchdog: mpcore_wdt: Use devm routines
  watchdog: mpcore_wdt: Rename dev to pdev for pointing to struct platform_device
  watchdog: xen: don't clear is_active when xen_wdt_stop() failed
  watchdog: xen: don't unconditionally enable the watchdog during resume
  watchdog: fix compiler error for missing parenthesis
  watchdog: ep93xx_wdt.c: fix platform probe
  watchdog: ep93xx: Convert the watchdog driver into a platform device.
  watchdog: fix set_timeout operations
  ...
parents 89e5d6f0 b92c803e
00-INDEX
- this file.
convert_drivers_to_kernel_api.txt
- how-to for converting old watchdog drivers to the new kernel API.
hpwdt.txt
- information on the HP iLO2 NMI watchdog
pcwd-watchdog.txt
- documentation for Berkshire Products PC Watchdog ISA cards.
src/
- directory holding watchdog related example programs.
watchdog-api.txt
- description of the Linux Watchdog driver API.
watchdog-kernel-api.txt
- description of the Linux WatchDog Timer Driver Core kernel API.
watchdog-parameters.txt
- information on driver parameters (for drivers other than
the ones that have driver-specific files here)
wdt.txt
- description of the Watchdog Timer Interfaces for Linux.
...@@ -59,6 +59,10 @@ Here is a overview of the functions and probably needed actions: ...@@ -59,6 +59,10 @@ Here is a overview of the functions and probably needed actions:
WDIOC_GETTIMEOUT: WDIOC_GETTIMEOUT:
No preparations needed No preparations needed
WDIOC_GETTIMELEFT:
It needs get_timeleft() callback to be defined. Otherwise it
will return EOPNOTSUPP
Other IOCTLs can be served using the ioctl-callback. Note that this is mainly Other IOCTLs can be served using the ioctl-callback. Note that this is mainly
intended for porting old drivers; new drivers should not invent private IOCTLs. intended for porting old drivers; new drivers should not invent private IOCTLs.
Private IOCTLs are processed first. When the callback returns with Private IOCTLs are processed first. When the callback returns with
......
The Linux WatchDog Timer Driver Core kernel API. The Linux WatchDog Timer Driver Core kernel API.
=============================================== ===============================================
Last reviewed: 29-Nov-2011 Last reviewed: 16-Mar-2012
Wim Van Sebroeck <wim@iguana.be> Wim Van Sebroeck <wim@iguana.be>
...@@ -77,6 +77,7 @@ struct watchdog_ops { ...@@ -77,6 +77,7 @@ struct watchdog_ops {
int (*ping)(struct watchdog_device *); int (*ping)(struct watchdog_device *);
unsigned int (*status)(struct watchdog_device *); unsigned int (*status)(struct watchdog_device *);
int (*set_timeout)(struct watchdog_device *, unsigned int); int (*set_timeout)(struct watchdog_device *, unsigned int);
unsigned int (*get_timeleft)(struct watchdog_device *);
long (*ioctl)(struct watchdog_device *, unsigned int, unsigned long); long (*ioctl)(struct watchdog_device *, unsigned int, unsigned long);
}; };
...@@ -117,11 +118,13 @@ they are supported. These optional routines/operations are: ...@@ -117,11 +118,13 @@ they are supported. These optional routines/operations are:
status of the device is reported with watchdog WDIOF_* status flags/bits. status of the device is reported with watchdog WDIOF_* status flags/bits.
* set_timeout: this routine checks and changes the timeout of the watchdog * set_timeout: this routine checks and changes the timeout of the watchdog
timer device. It returns 0 on success, -EINVAL for "parameter out of range" timer device. It returns 0 on success, -EINVAL for "parameter out of range"
and -EIO for "could not write value to the watchdog". On success the timeout and -EIO for "could not write value to the watchdog". On success this
value of the watchdog_device will be changed to the value that was just used routine should set the timeout value of the watchdog_device to the
to re-program the watchdog timer device. achieved timeout value (which may be different from the requested one
because the watchdog does not necessarily has a 1 second resolution).
(Note: the WDIOF_SETTIMEOUT needs to be set in the options field of the (Note: the WDIOF_SETTIMEOUT needs to be set in the options field of the
watchdog's info structure). watchdog's info structure).
* get_timeleft: this routines returns the time that's left before a reset.
* ioctl: if this routine is present then it will be called first before we do * ioctl: if this routine is present then it will be called first before we do
our own internal ioctl call handling. This routine should return -ENOIOCTLCMD our own internal ioctl call handling. This routine should return -ENOIOCTLCMD
if a command is not supported. The parameters that are passed to the ioctl if a command is not supported. The parameters that are passed to the ioctl
......
...@@ -153,7 +153,7 @@ ...@@ -153,7 +153,7 @@
#endif #endif
static DEFINE_MUTEX(ipmi_watchdog_mutex); static DEFINE_MUTEX(ipmi_watchdog_mutex);
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
static ipmi_user_t watchdog_user; static ipmi_user_t watchdog_user;
static int watchdog_ifnum; static int watchdog_ifnum;
...@@ -320,7 +320,7 @@ module_param(start_now, int, 0444); ...@@ -320,7 +320,7 @@ module_param(start_now, int, 0444);
MODULE_PARM_DESC(start_now, "Set to 1 to start the watchdog as" MODULE_PARM_DESC(start_now, "Set to 1 to start the watchdog as"
"soon as the driver is loaded."); "soon as the driver is loaded.");
module_param(nowayout, int, 0644); module_param(nowayout, bool, 0644);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started " MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
"(default=CONFIG_WATCHDOG_NOWAYOUT)"); "(default=CONFIG_WATCHDOG_NOWAYOUT)");
......
...@@ -53,8 +53,8 @@ ...@@ -53,8 +53,8 @@
static const unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; static const unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END };
/* Insmod parameters */ /* Insmod parameters */
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
......
...@@ -71,8 +71,8 @@ MODULE_PARM_DESC(timeout, ...@@ -71,8 +71,8 @@ MODULE_PARM_DESC(timeout,
"Watchdog timeout in minutes. 2<= timeout <=255 (default=" "Watchdog timeout in minutes. 2<= timeout <=255 (default="
__MODULE_STRING(WATCHDOG_TIMEOUT) ")"); __MODULE_STRING(WATCHDOG_TIMEOUT) ")");
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default=" "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
......
...@@ -323,6 +323,7 @@ static int mei_wd_ops_set_timeout(struct watchdog_device *wd_dev, unsigned int t ...@@ -323,6 +323,7 @@ static int mei_wd_ops_set_timeout(struct watchdog_device *wd_dev, unsigned int t
mutex_lock(&dev->device_lock); mutex_lock(&dev->device_lock);
dev->wd_timeout = timeout; dev->wd_timeout = timeout;
wd_dev->timeout = timeout;
mei_wd_set_start_timeout(dev, dev->wd_timeout); mei_wd_set_start_timeout(dev, dev->wd_timeout);
mutex_unlock(&dev->device_lock); mutex_unlock(&dev->device_lock);
......
...@@ -55,6 +55,7 @@ comment "Watchdog Device Drivers" ...@@ -55,6 +55,7 @@ comment "Watchdog Device Drivers"
config SOFT_WATCHDOG config SOFT_WATCHDOG
tristate "Software watchdog" tristate "Software watchdog"
select WATCHDOG_CORE
help help
A software monitoring watchdog. This will fail to reboot your system A software monitoring watchdog. This will fail to reboot your system
from some situations that the hardware watchdog will recover from some situations that the hardware watchdog will recover
...@@ -74,6 +75,7 @@ config WM831X_WATCHDOG ...@@ -74,6 +75,7 @@ config WM831X_WATCHDOG
config WM8350_WATCHDOG config WM8350_WATCHDOG
tristate "WM8350 watchdog" tristate "WM8350 watchdog"
depends on MFD_WM8350 depends on MFD_WM8350
select WATCHDOG_CORE
help help
Support for the watchdog in the WM8350 AudioPlus PMIC. When Support for the watchdog in the WM8350 AudioPlus PMIC. When
the watchdog triggers the system will be reset. the watchdog triggers the system will be reset.
...@@ -217,6 +219,7 @@ config MPCORE_WATCHDOG ...@@ -217,6 +219,7 @@ config MPCORE_WATCHDOG
config EP93XX_WATCHDOG config EP93XX_WATCHDOG
tristate "EP93xx Watchdog" tristate "EP93xx Watchdog"
depends on ARCH_EP93XX depends on ARCH_EP93XX
select WATCHDOG_CORE
help help
Say Y here if to include support for the watchdog timer Say Y here if to include support for the watchdog timer
embedded in the Cirrus Logic EP93xx family of devices. embedded in the Cirrus Logic EP93xx family of devices.
...@@ -234,6 +237,7 @@ config OMAP_WATCHDOG ...@@ -234,6 +237,7 @@ config OMAP_WATCHDOG
config PNX4008_WATCHDOG config PNX4008_WATCHDOG
tristate "PNX4008 and LPC32XX Watchdog" tristate "PNX4008 and LPC32XX Watchdog"
depends on ARCH_PNX4008 || ARCH_LPC32XX depends on ARCH_PNX4008 || ARCH_LPC32XX
select WATCHDOG_CORE
help help
Say Y here if to include support for the watchdog timer Say Y here if to include support for the watchdog timer
in the PNX4008 or LPC32XX processor. in the PNX4008 or LPC32XX processor.
...@@ -283,6 +287,7 @@ config COH901327_WATCHDOG ...@@ -283,6 +287,7 @@ config COH901327_WATCHDOG
bool "ST-Ericsson COH 901 327 watchdog" bool "ST-Ericsson COH 901 327 watchdog"
depends on ARCH_U300 depends on ARCH_U300
default y if MACH_U300 default y if MACH_U300
select WATCHDOG_CORE
help help
Say Y here to include Watchdog timer support for the Say Y here to include Watchdog timer support for the
watchdog embedded into the ST-Ericsson U300 series platforms. watchdog embedded into the ST-Ericsson U300 series platforms.
...@@ -328,6 +333,7 @@ config TS72XX_WATCHDOG ...@@ -328,6 +333,7 @@ config TS72XX_WATCHDOG
config MAX63XX_WATCHDOG config MAX63XX_WATCHDOG
tristate "Max63xx watchdog" tristate "Max63xx watchdog"
depends on ARM && HAS_IOMEM depends on ARM && HAS_IOMEM
select WATCHDOG_CORE
help help
Support for memory mapped max63{69,70,71,72,73,74} watchdog timer. Support for memory mapped max63{69,70,71,72,73,74} watchdog timer.
...@@ -955,6 +961,7 @@ config INDYDOG ...@@ -955,6 +961,7 @@ config INDYDOG
config JZ4740_WDT config JZ4740_WDT
tristate "Ingenic jz4740 SoC hardware watchdog" tristate "Ingenic jz4740 SoC hardware watchdog"
depends on MACH_JZ4740 depends on MACH_JZ4740
select WATCHDOG_CORE
help help
Hardware driver for the built-in watchdog timer on Ingenic jz4740 SoCs. Hardware driver for the built-in watchdog timer on Ingenic jz4740 SoCs.
...@@ -996,6 +1003,7 @@ config AR7_WDT ...@@ -996,6 +1003,7 @@ config AR7_WDT
config TXX9_WDT config TXX9_WDT
tristate "Toshiba TXx9 Watchdog Timer" tristate "Toshiba TXx9 Watchdog Timer"
depends on CPU_TX39XX || CPU_TX49XX depends on CPU_TX39XX || CPU_TX49XX
select WATCHDOG_CORE
help help
Hardware driver for the built-in watchdog timer on TXx9 MIPS SoCs. Hardware driver for the built-in watchdog timer on TXx9 MIPS SoCs.
......
...@@ -52,6 +52,8 @@ ...@@ -52,6 +52,8 @@
* Includes, defines, variables, module parameters, ... * Includes, defines, variables, module parameters, ...
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
/* Includes */ /* Includes */
#include <linux/module.h> /* For module specific items */ #include <linux/module.h> /* For module specific items */
#include <linux/moduleparam.h> /* For new moduleparam's */ #include <linux/moduleparam.h> /* For new moduleparam's */
...@@ -70,7 +72,6 @@ ...@@ -70,7 +72,6 @@
/* Module information */ /* Module information */
#define DRV_NAME "acquirewdt" #define DRV_NAME "acquirewdt"
#define PFX DRV_NAME ": "
#define WATCHDOG_NAME "Acquire WDT" #define WATCHDOG_NAME "Acquire WDT"
/* There is no way to see what the correct time-out period is */ /* There is no way to see what the correct time-out period is */
#define WATCHDOG_HEARTBEAT 0 #define WATCHDOG_HEARTBEAT 0
...@@ -92,8 +93,8 @@ static int wdt_start = 0x443; ...@@ -92,8 +93,8 @@ static int wdt_start = 0x443;
module_param(wdt_start, int, 0); module_param(wdt_start, int, 0);
MODULE_PARM_DESC(wdt_start, "Acquire WDT 'start' io port (default 0x443)"); MODULE_PARM_DESC(wdt_start, "Acquire WDT 'start' io port (default 0x443)");
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default=" "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -208,8 +209,7 @@ static int acq_close(struct inode *inode, struct file *file) ...@@ -208,8 +209,7 @@ static int acq_close(struct inode *inode, struct file *file)
if (expect_close == 42) { if (expect_close == 42) {
acq_stop(); acq_stop();
} else { } else {
printk(KERN_CRIT PFX pr_crit("Unexpected close, not stopping watchdog!\n");
"Unexpected close, not stopping watchdog!\n");
acq_keepalive(); acq_keepalive();
} }
clear_bit(0, &acq_is_open); clear_bit(0, &acq_is_open);
...@@ -246,27 +246,24 @@ static int __devinit acq_probe(struct platform_device *dev) ...@@ -246,27 +246,24 @@ static int __devinit acq_probe(struct platform_device *dev)
if (wdt_stop != wdt_start) { if (wdt_stop != wdt_start) {
if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) { if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) {
printk(KERN_ERR PFX pr_err("I/O address 0x%04x already in use\n", wdt_stop);
"I/O address 0x%04x already in use\n", wdt_stop);
ret = -EIO; ret = -EIO;
goto out; goto out;
} }
} }
if (!request_region(wdt_start, 1, WATCHDOG_NAME)) { if (!request_region(wdt_start, 1, WATCHDOG_NAME)) {
printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", pr_err("I/O address 0x%04x already in use\n", wdt_start);
wdt_start);
ret = -EIO; ret = -EIO;
goto unreg_stop; goto unreg_stop;
} }
ret = misc_register(&acq_miscdev); ret = misc_register(&acq_miscdev);
if (ret != 0) { if (ret != 0) {
printk(KERN_ERR PFX pr_err("cannot register miscdev on minor=%d (err=%d)\n",
"cannot register miscdev on minor=%d (err=%d)\n", WATCHDOG_MINOR, ret);
WATCHDOG_MINOR, ret);
goto unreg_regions; goto unreg_regions;
} }
printk(KERN_INFO PFX "initialized. (nowayout=%d)\n", nowayout); pr_info("initialized. (nowayout=%d)\n", nowayout);
return 0; return 0;
unreg_regions: unreg_regions:
...@@ -308,8 +305,7 @@ static int __init acq_init(void) ...@@ -308,8 +305,7 @@ static int __init acq_init(void)
{ {
int err; int err;
printk(KERN_INFO pr_info("WDT driver for Acquire single board computer initialising\n");
"WDT driver for Acquire single board computer initialising.\n");
err = platform_driver_register(&acquirewdt_driver); err = platform_driver_register(&acquirewdt_driver);
if (err) if (err)
...@@ -332,7 +328,7 @@ static void __exit acq_exit(void) ...@@ -332,7 +328,7 @@ static void __exit acq_exit(void)
{ {
platform_device_unregister(acq_platform_device); platform_device_unregister(acq_platform_device);
platform_driver_unregister(&acquirewdt_driver); platform_driver_unregister(&acquirewdt_driver);
printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); pr_info("Watchdog Module Unloaded\n");
} }
module_init(acq_init); module_init(acq_init);
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
* add wdt_start and wdt_stop as parameters. * add wdt_start and wdt_stop as parameters.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -43,7 +45,6 @@ ...@@ -43,7 +45,6 @@
#include <asm/system.h> #include <asm/system.h>
#define DRV_NAME "advantechwdt" #define DRV_NAME "advantechwdt"
#define PFX DRV_NAME ": "
#define WATCHDOG_NAME "Advantech WDT" #define WATCHDOG_NAME "Advantech WDT"
#define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */ #define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */
...@@ -77,8 +78,8 @@ MODULE_PARM_DESC(timeout, ...@@ -77,8 +78,8 @@ MODULE_PARM_DESC(timeout,
"Watchdog timeout in seconds. 1<= timeout <=63, default=" "Watchdog timeout in seconds. 1<= timeout <=63, default="
__MODULE_STRING(WATCHDOG_TIMEOUT) "."); __MODULE_STRING(WATCHDOG_TIMEOUT) ".");
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default=" "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -207,8 +208,7 @@ static int advwdt_close(struct inode *inode, struct file *file) ...@@ -207,8 +208,7 @@ static int advwdt_close(struct inode *inode, struct file *file)
if (adv_expect_close == 42) { if (adv_expect_close == 42) {
advwdt_disable(); advwdt_disable();
} else { } else {
printk(KERN_CRIT PFX pr_crit("Unexpected close, not stopping watchdog!\n");
"Unexpected close, not stopping watchdog!\n");
advwdt_ping(); advwdt_ping();
} }
clear_bit(0, &advwdt_is_open); clear_bit(0, &advwdt_is_open);
...@@ -245,18 +245,15 @@ static int __devinit advwdt_probe(struct platform_device *dev) ...@@ -245,18 +245,15 @@ static int __devinit advwdt_probe(struct platform_device *dev)
if (wdt_stop != wdt_start) { if (wdt_stop != wdt_start) {
if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) { if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) {
printk(KERN_ERR PFX pr_err("I/O address 0x%04x already in use\n",
"I/O address 0x%04x already in use\n", wdt_stop);
wdt_stop);
ret = -EIO; ret = -EIO;
goto out; goto out;
} }
} }
if (!request_region(wdt_start, 1, WATCHDOG_NAME)) { if (!request_region(wdt_start, 1, WATCHDOG_NAME)) {
printk(KERN_ERR PFX pr_err("I/O address 0x%04x already in use\n", wdt_start);
"I/O address 0x%04x already in use\n",
wdt_start);
ret = -EIO; ret = -EIO;
goto unreg_stop; goto unreg_stop;
} }
...@@ -265,18 +262,16 @@ static int __devinit advwdt_probe(struct platform_device *dev) ...@@ -265,18 +262,16 @@ static int __devinit advwdt_probe(struct platform_device *dev)
* if not reset to the default */ * if not reset to the default */
if (advwdt_set_heartbeat(timeout)) { if (advwdt_set_heartbeat(timeout)) {
advwdt_set_heartbeat(WATCHDOG_TIMEOUT); advwdt_set_heartbeat(WATCHDOG_TIMEOUT);
printk(KERN_INFO PFX pr_info("timeout value must be 1<=x<=63, using %d\n", timeout);
"timeout value must be 1<=x<=63, using %d\n", timeout);
} }
ret = misc_register(&advwdt_miscdev); ret = misc_register(&advwdt_miscdev);
if (ret != 0) { if (ret != 0) {
printk(KERN_ERR PFX pr_err("cannot register miscdev on minor=%d (err=%d)\n",
"cannot register miscdev on minor=%d (err=%d)\n", WATCHDOG_MINOR, ret);
WATCHDOG_MINOR, ret);
goto unreg_regions; goto unreg_regions;
} }
printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d)\n", pr_info("initialized. timeout=%d sec (nowayout=%d)\n",
timeout, nowayout); timeout, nowayout);
out: out:
return ret; return ret;
...@@ -318,8 +313,7 @@ static int __init advwdt_init(void) ...@@ -318,8 +313,7 @@ static int __init advwdt_init(void)
{ {
int err; int err;
printk(KERN_INFO pr_info("WDT driver for Advantech single board computer initialising\n");
"WDT driver for Advantech single board computer initialising.\n");
err = platform_driver_register(&advwdt_driver); err = platform_driver_register(&advwdt_driver);
if (err) if (err)
...@@ -343,7 +337,7 @@ static void __exit advwdt_exit(void) ...@@ -343,7 +337,7 @@ static void __exit advwdt_exit(void)
{ {
platform_device_unregister(advwdt_platform_device); platform_device_unregister(advwdt_platform_device);
platform_driver_unregister(&advwdt_driver); platform_driver_unregister(&advwdt_driver);
printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); pr_info("Watchdog Module Unloaded\n");
} }
module_init(advwdt_init); module_init(advwdt_init);
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -22,7 +24,6 @@ ...@@ -22,7 +24,6 @@
#include <linux/io.h> #include <linux/io.h>
#define WATCHDOG_NAME "ALi_M1535" #define WATCHDOG_NAME "ALi_M1535"
#define PFX WATCHDOG_NAME ": "
#define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */ #define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */
/* internal variables */ /* internal variables */
...@@ -39,8 +40,8 @@ MODULE_PARM_DESC(timeout, ...@@ -39,8 +40,8 @@ MODULE_PARM_DESC(timeout,
"Watchdog timeout in seconds. (0 < timeout < 18000, default=" "Watchdog timeout in seconds. (0 < timeout < 18000, default="
__MODULE_STRING(WATCHDOG_TIMEOUT) ")"); __MODULE_STRING(WATCHDOG_TIMEOUT) ")");
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default=" "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -268,8 +269,7 @@ static int ali_release(struct inode *inode, struct file *file) ...@@ -268,8 +269,7 @@ static int ali_release(struct inode *inode, struct file *file)
if (ali_expect_release == 42) if (ali_expect_release == 42)
ali_stop(); ali_stop();
else { else {
printk(KERN_CRIT PFX pr_crit("Unexpected close, not stopping watchdog!\n");
"Unexpected close, not stopping watchdog!\n");
ali_keepalive(); ali_keepalive();
} }
clear_bit(0, &ali_is_open); clear_bit(0, &ali_is_open);
...@@ -399,9 +399,8 @@ static int __init watchdog_init(void) ...@@ -399,9 +399,8 @@ static int __init watchdog_init(void)
if not reset to the default */ if not reset to the default */
if (timeout < 1 || timeout >= 18000) { if (timeout < 1 || timeout >= 18000) {
timeout = WATCHDOG_TIMEOUT; timeout = WATCHDOG_TIMEOUT;
printk(KERN_INFO PFX pr_info("timeout value must be 0 < timeout < 18000, using %d\n",
"timeout value must be 0 < timeout < 18000, using %d\n", timeout);
timeout);
} }
/* Calculate the watchdog's timeout */ /* Calculate the watchdog's timeout */
...@@ -409,20 +408,18 @@ static int __init watchdog_init(void) ...@@ -409,20 +408,18 @@ static int __init watchdog_init(void)
ret = register_reboot_notifier(&ali_notifier); ret = register_reboot_notifier(&ali_notifier);
if (ret != 0) { if (ret != 0) {
printk(KERN_ERR PFX pr_err("cannot register reboot notifier (err=%d)\n", ret);
"cannot register reboot notifier (err=%d)\n", ret);
goto out; goto out;
} }
ret = misc_register(&ali_miscdev); ret = misc_register(&ali_miscdev);
if (ret != 0) { if (ret != 0) {
printk(KERN_ERR PFX pr_err("cannot register miscdev on minor=%d (err=%d)\n",
"cannot register miscdev on minor=%d (err=%d)\n", WATCHDOG_MINOR, ret);
WATCHDOG_MINOR, ret);
goto unreg_reboot; goto unreg_reboot;
} }
printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d)\n", pr_info("initialized. timeout=%d sec (nowayout=%d)\n",
timeout, nowayout); timeout, nowayout);
out: out:
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
* -- Mike Waychison <michael.waychison@sun.com> * -- Mike Waychison <michael.waychison@sun.com>
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -36,9 +38,6 @@ ...@@ -36,9 +38,6 @@
#include <asm/system.h> #include <asm/system.h>
#define OUR_NAME "alim7101_wdt"
#define PFX OUR_NAME ": "
#define WDT_ENABLE 0x9C #define WDT_ENABLE 0x9C
#define WDT_DISABLE 0x8C #define WDT_DISABLE 0x8C
...@@ -79,8 +78,8 @@ static unsigned long wdt_is_open; ...@@ -79,8 +78,8 @@ static unsigned long wdt_is_open;
static char wdt_expect_close; static char wdt_expect_close;
static struct pci_dev *alim7101_pmu; static struct pci_dev *alim7101_pmu;
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default=" "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -112,8 +111,7 @@ static void wdt_timer_ping(unsigned long data) ...@@ -112,8 +111,7 @@ static void wdt_timer_ping(unsigned long data)
ALI_7101_GPIO_O, tmp & ~0x20); ALI_7101_GPIO_O, tmp & ~0x20);
} }
} else { } else {
printk(KERN_WARNING PFX pr_warn("Heartbeat lost! Will not ping the watchdog\n");
"Heartbeat lost! Will not ping the watchdog\n");
} }
/* Re-set the timer interval */ /* Re-set the timer interval */
mod_timer(&timer, jiffies + WDT_INTERVAL); mod_timer(&timer, jiffies + WDT_INTERVAL);
...@@ -162,7 +160,7 @@ static void wdt_startup(void) ...@@ -162,7 +160,7 @@ static void wdt_startup(void)
/* Start the timer */ /* Start the timer */
mod_timer(&timer, jiffies + WDT_INTERVAL); mod_timer(&timer, jiffies + WDT_INTERVAL);
printk(KERN_INFO PFX "Watchdog timer is now enabled.\n"); pr_info("Watchdog timer is now enabled\n");
} }
static void wdt_turnoff(void) static void wdt_turnoff(void)
...@@ -170,7 +168,7 @@ static void wdt_turnoff(void) ...@@ -170,7 +168,7 @@ static void wdt_turnoff(void)
/* Stop the timer */ /* Stop the timer */
del_timer_sync(&timer); del_timer_sync(&timer);
wdt_change(WDT_DISABLE); wdt_change(WDT_DISABLE);
printk(KERN_INFO PFX "Watchdog timer is now disabled...\n"); pr_info("Watchdog timer is now disabled...\n");
} }
static void wdt_keepalive(void) static void wdt_keepalive(void)
...@@ -226,8 +224,7 @@ static int fop_close(struct inode *inode, struct file *file) ...@@ -226,8 +224,7 @@ static int fop_close(struct inode *inode, struct file *file)
wdt_turnoff(); wdt_turnoff();
else { else {
/* wim: shouldn't there be a: del_timer(&timer); */ /* wim: shouldn't there be a: del_timer(&timer); */
printk(KERN_CRIT PFX pr_crit("device file closed unexpectedly. Will not stop the WDT!\n");
"device file closed unexpectedly. Will not stop the WDT!\n");
} }
clear_bit(0, &wdt_is_open); clear_bit(0, &wdt_is_open);
wdt_expect_close = 0; wdt_expect_close = 0;
...@@ -322,8 +319,7 @@ static int wdt_notify_sys(struct notifier_block *this, ...@@ -322,8 +319,7 @@ static int wdt_notify_sys(struct notifier_block *this,
* watchdog on reboot with no heartbeat * watchdog on reboot with no heartbeat
*/ */
wdt_change(WDT_ENABLE); wdt_change(WDT_ENABLE);
printk(KERN_INFO PFX "Watchdog timer is now enabled " pr_info("Watchdog timer is now enabled with no heartbeat - should reboot in ~1 second\n");
"with no heartbeat - should reboot in ~1 second.\n");
} }
return NOTIFY_DONE; return NOTIFY_DONE;
} }
...@@ -352,12 +348,11 @@ static int __init alim7101_wdt_init(void) ...@@ -352,12 +348,11 @@ static int __init alim7101_wdt_init(void)
struct pci_dev *ali1543_south; struct pci_dev *ali1543_south;
char tmp; char tmp;
printk(KERN_INFO PFX "Steve Hill <steve@navaho.co.uk>.\n"); pr_info("Steve Hill <steve@navaho.co.uk>\n");
alim7101_pmu = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, alim7101_pmu = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101,
NULL); NULL);
if (!alim7101_pmu) { if (!alim7101_pmu) {
printk(KERN_INFO PFX pr_info("ALi M7101 PMU not present - WDT not set\n");
"ALi M7101 PMU not present - WDT not set\n");
return -EBUSY; return -EBUSY;
} }
...@@ -367,56 +362,46 @@ static int __init alim7101_wdt_init(void) ...@@ -367,56 +362,46 @@ static int __init alim7101_wdt_init(void)
ali1543_south = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, ali1543_south = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533,
NULL); NULL);
if (!ali1543_south) { if (!ali1543_south) {
printk(KERN_INFO PFX pr_info("ALi 1543 South-Bridge not present - WDT not set\n");
"ALi 1543 South-Bridge not present - WDT not set\n");
goto err_out; goto err_out;
} }
pci_read_config_byte(ali1543_south, 0x5e, &tmp); pci_read_config_byte(ali1543_south, 0x5e, &tmp);
pci_dev_put(ali1543_south); pci_dev_put(ali1543_south);
if ((tmp & 0x1e) == 0x00) { if ((tmp & 0x1e) == 0x00) {
if (!use_gpio) { if (!use_gpio) {
printk(KERN_INFO PFX pr_info("Detected old alim7101 revision 'a1d'. If this is a cobalt board, set the 'use_gpio' module parameter.\n");
"Detected old alim7101 revision 'a1d'. "
"If this is a cobalt board, set the 'use_gpio' "
"module parameter.\n");
goto err_out; goto err_out;
} }
nowayout = 1; nowayout = 1;
} else if ((tmp & 0x1e) != 0x12 && (tmp & 0x1e) != 0x00) { } else if ((tmp & 0x1e) != 0x12 && (tmp & 0x1e) != 0x00) {
printk(KERN_INFO PFX pr_info("ALi 1543 South-Bridge does not have the correct revision number (???1001?) - WDT not set\n");
"ALi 1543 South-Bridge does not have the correct "
"revision number (???1001?) - WDT not set\n");
goto err_out; goto err_out;
} }
if (timeout < 1 || timeout > 3600) { if (timeout < 1 || timeout > 3600) {
/* arbitrary upper limit */ /* arbitrary upper limit */
timeout = WATCHDOG_TIMEOUT; timeout = WATCHDOG_TIMEOUT;
printk(KERN_INFO PFX pr_info("timeout value must be 1 <= x <= 3600, using %d\n",
"timeout value must be 1 <= x <= 3600, using %d\n", timeout);
timeout);
} }
rc = register_reboot_notifier(&wdt_notifier); rc = register_reboot_notifier(&wdt_notifier);
if (rc) { if (rc) {
printk(KERN_ERR PFX pr_err("cannot register reboot notifier (err=%d)\n", rc);
"cannot register reboot notifier (err=%d)\n", rc);
goto err_out; goto err_out;
} }
rc = misc_register(&wdt_miscdev); rc = misc_register(&wdt_miscdev);
if (rc) { if (rc) {
printk(KERN_ERR PFX pr_err("cannot register miscdev on minor=%d (err=%d)\n",
"cannot register miscdev on minor=%d (err=%d)\n", wdt_miscdev.minor, rc);
wdt_miscdev.minor, rc);
goto err_out_reboot; goto err_out_reboot;
} }
if (nowayout) if (nowayout)
__module_get(THIS_MODULE); __module_get(THIS_MODULE);
printk(KERN_INFO PFX "WDT driver for ALi M7101 initialised. " pr_info("WDT driver for ALi M7101 initialised. timeout=%d sec (nowayout=%d)\n",
"timeout=%d sec (nowayout=%d)\n",
timeout, nowayout); timeout, nowayout);
return 0; return 0;
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/errno.h> #include <linux/errno.h>
...@@ -39,7 +41,6 @@ ...@@ -39,7 +41,6 @@
#include <asm/addrspace.h> #include <asm/addrspace.h>
#include <asm/mach-ar7/ar7.h> #include <asm/mach-ar7/ar7.h>
#define DRVNAME "ar7_wdt"
#define LONGNAME "TI AR7 Watchdog Timer" #define LONGNAME "TI AR7 Watchdog Timer"
MODULE_AUTHOR("Nicolas Thill <nico@openwrt.org>"); MODULE_AUTHOR("Nicolas Thill <nico@openwrt.org>");
...@@ -51,8 +52,8 @@ static int margin = 60; ...@@ -51,8 +52,8 @@ static int margin = 60;
module_param(margin, int, 0); module_param(margin, int, 0);
MODULE_PARM_DESC(margin, "Watchdog margin in seconds"); MODULE_PARM_DESC(margin, "Watchdog margin in seconds");
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Disable watchdog shutdown on close"); MODULE_PARM_DESC(nowayout, "Disable watchdog shutdown on close");
#define READ_REG(x) readl((void __iomem *)&(x)) #define READ_REG(x) readl((void __iomem *)&(x))
...@@ -93,7 +94,7 @@ static void ar7_wdt_kick(u32 value) ...@@ -93,7 +94,7 @@ static void ar7_wdt_kick(u32 value)
return; return;
} }
} }
printk(KERN_ERR DRVNAME ": failed to unlock WDT kick reg\n"); pr_err("failed to unlock WDT kick reg\n");
} }
static void ar7_wdt_prescale(u32 value) static void ar7_wdt_prescale(u32 value)
...@@ -106,7 +107,7 @@ static void ar7_wdt_prescale(u32 value) ...@@ -106,7 +107,7 @@ static void ar7_wdt_prescale(u32 value)
return; return;
} }
} }
printk(KERN_ERR DRVNAME ": failed to unlock WDT prescale reg\n"); pr_err("failed to unlock WDT prescale reg\n");
} }
static void ar7_wdt_change(u32 value) static void ar7_wdt_change(u32 value)
...@@ -119,7 +120,7 @@ static void ar7_wdt_change(u32 value) ...@@ -119,7 +120,7 @@ static void ar7_wdt_change(u32 value)
return; return;
} }
} }
printk(KERN_ERR DRVNAME ": failed to unlock WDT change reg\n"); pr_err("failed to unlock WDT change reg\n");
} }
static void ar7_wdt_disable(u32 value) static void ar7_wdt_disable(u32 value)
...@@ -135,7 +136,7 @@ static void ar7_wdt_disable(u32 value) ...@@ -135,7 +136,7 @@ static void ar7_wdt_disable(u32 value)
} }
} }
} }
printk(KERN_ERR DRVNAME ": failed to unlock WDT disable reg\n"); pr_err("failed to unlock WDT disable reg\n");
} }
static void ar7_wdt_update_margin(int new_margin) static void ar7_wdt_update_margin(int new_margin)
...@@ -151,21 +152,20 @@ static void ar7_wdt_update_margin(int new_margin) ...@@ -151,21 +152,20 @@ static void ar7_wdt_update_margin(int new_margin)
change = 0xffff; change = 0xffff;
ar7_wdt_change(change); ar7_wdt_change(change);
margin = change * prescale_value / vbus_rate; margin = change * prescale_value / vbus_rate;
printk(KERN_INFO DRVNAME pr_info("timer margin %d seconds (prescale %d, change %d, freq %d)\n",
": timer margin %d seconds (prescale %d, change %d, freq %d)\n", margin, prescale_value, change, vbus_rate);
margin, prescale_value, change, vbus_rate);
} }
static void ar7_wdt_enable_wdt(void) static void ar7_wdt_enable_wdt(void)
{ {
printk(KERN_DEBUG DRVNAME ": enabling watchdog timer\n"); pr_debug("enabling watchdog timer\n");
ar7_wdt_disable(1); ar7_wdt_disable(1);
ar7_wdt_kick(1); ar7_wdt_kick(1);
} }
static void ar7_wdt_disable_wdt(void) static void ar7_wdt_disable_wdt(void)
{ {
printk(KERN_DEBUG DRVNAME ": disabling watchdog timer\n"); pr_debug("disabling watchdog timer\n");
ar7_wdt_disable(0); ar7_wdt_disable(0);
} }
...@@ -183,9 +183,7 @@ static int ar7_wdt_open(struct inode *inode, struct file *file) ...@@ -183,9 +183,7 @@ static int ar7_wdt_open(struct inode *inode, struct file *file)
static int ar7_wdt_release(struct inode *inode, struct file *file) static int ar7_wdt_release(struct inode *inode, struct file *file)
{ {
if (!expect_close) if (!expect_close)
printk(KERN_WARNING DRVNAME pr_warn("watchdog device closed unexpectedly, will not disable the watchdog timer\n");
": watchdog device closed unexpectedly,"
"will not disable the watchdog timer\n");
else if (!nowayout) else if (!nowayout)
ar7_wdt_disable_wdt(); ar7_wdt_disable_wdt();
clear_bit(0, &wdt_is_open); clear_bit(0, &wdt_is_open);
...@@ -283,28 +281,28 @@ static int __devinit ar7_wdt_probe(struct platform_device *pdev) ...@@ -283,28 +281,28 @@ static int __devinit ar7_wdt_probe(struct platform_device *pdev)
ar7_regs_wdt = ar7_regs_wdt =
platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
if (!ar7_regs_wdt) { if (!ar7_regs_wdt) {
printk(KERN_ERR DRVNAME ": could not get registers resource\n"); pr_err("could not get registers resource\n");
rc = -ENODEV; rc = -ENODEV;
goto out; goto out;
} }
if (!request_mem_region(ar7_regs_wdt->start, if (!request_mem_region(ar7_regs_wdt->start,
resource_size(ar7_regs_wdt), LONGNAME)) { resource_size(ar7_regs_wdt), LONGNAME)) {
printk(KERN_WARNING DRVNAME ": watchdog I/O region busy\n"); pr_warn("watchdog I/O region busy\n");
rc = -EBUSY; rc = -EBUSY;
goto out; goto out;
} }
ar7_wdt = ioremap(ar7_regs_wdt->start, resource_size(ar7_regs_wdt)); ar7_wdt = ioremap(ar7_regs_wdt->start, resource_size(ar7_regs_wdt));
if (!ar7_wdt) { if (!ar7_wdt) {
printk(KERN_ERR DRVNAME ": could not ioremap registers\n"); pr_err("could not ioremap registers\n");
rc = -ENXIO; rc = -ENXIO;
goto out_mem_region; goto out_mem_region;
} }
vbus_clk = clk_get(NULL, "vbus"); vbus_clk = clk_get(NULL, "vbus");
if (IS_ERR(vbus_clk)) { if (IS_ERR(vbus_clk)) {
printk(KERN_ERR DRVNAME ": could not get vbus clock\n"); pr_err("could not get vbus clock\n");
rc = PTR_ERR(vbus_clk); rc = PTR_ERR(vbus_clk);
goto out_mem_region; goto out_mem_region;
} }
...@@ -315,7 +313,7 @@ static int __devinit ar7_wdt_probe(struct platform_device *pdev) ...@@ -315,7 +313,7 @@ static int __devinit ar7_wdt_probe(struct platform_device *pdev)
rc = misc_register(&ar7_wdt_miscdev); rc = misc_register(&ar7_wdt_miscdev);
if (rc) { if (rc) {
printk(KERN_ERR DRVNAME ": unable to register misc device\n"); pr_err("unable to register misc device\n");
goto out_alloc; goto out_alloc;
} }
goto out; goto out;
......
...@@ -45,8 +45,8 @@ MODULE_PARM_DESC(timeout, ...@@ -45,8 +45,8 @@ MODULE_PARM_DESC(timeout,
"Timeout value. Limited to be 1 or 2 seconds. (default=" "Timeout value. Limited to be 1 or 2 seconds. (default="
__MODULE_STRING(TIMEOUT_DEFAULT) ")"); __MODULE_STRING(TIMEOUT_DEFAULT) ")");
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/fs.h> #include <linux/fs.h>
...@@ -28,14 +30,14 @@ ...@@ -28,14 +30,14 @@
#define WDT_MAX_TIME 256 /* seconds */ #define WDT_MAX_TIME 256 /* seconds */
static int wdt_time = WDT_DEFAULT_TIME; static int wdt_time = WDT_DEFAULT_TIME;
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(wdt_time, int, 0); module_param(wdt_time, int, 0);
MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default=" MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default="
__MODULE_STRING(WDT_DEFAULT_TIME) ")"); __MODULE_STRING(WDT_DEFAULT_TIME) ")");
#ifdef CONFIG_WATCHDOG_NOWAYOUT #ifdef CONFIG_WATCHDOG_NOWAYOUT
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default=" "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -209,8 +211,8 @@ static int __devinit at91wdt_probe(struct platform_device *pdev) ...@@ -209,8 +211,8 @@ static int __devinit at91wdt_probe(struct platform_device *pdev)
if (res) if (res)
return res; return res;
printk(KERN_INFO "AT91 Watchdog Timer enabled (%d seconds%s)\n", pr_info("AT91 Watchdog Timer enabled (%d seconds%s)\n",
wdt_time, nowayout ? ", nowayout" : ""); wdt_time, nowayout ? ", nowayout" : "");
return 0; return 0;
} }
...@@ -268,8 +270,8 @@ static int __init at91_wdt_init(void) ...@@ -268,8 +270,8 @@ static int __init at91_wdt_init(void)
if not reset to the default */ if not reset to the default */
if (at91_wdt_settimeout(wdt_time)) { if (at91_wdt_settimeout(wdt_time)) {
at91_wdt_settimeout(WDT_DEFAULT_TIME); at91_wdt_settimeout(WDT_DEFAULT_TIME);
pr_info("at91_wdt: wdt_time value must be 1 <= wdt_time <= 256" pr_info("wdt_time value must be 1 <= wdt_time <= 256, using %d\n",
", using %d\n", wdt_time); wdt_time);
} }
return platform_driver_register(&at91wdt_driver); return platform_driver_register(&at91wdt_driver);
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
* bootloader doesn't write to this register. * bootloader doesn't write to this register.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -60,8 +62,8 @@ module_param(heartbeat, int, 0); ...@@ -60,8 +62,8 @@ module_param(heartbeat, int, 0);
MODULE_PARM_DESC(heartbeat, "Watchdog heartbeats in seconds. " MODULE_PARM_DESC(heartbeat, "Watchdog heartbeats in seconds. "
"(default = " __MODULE_STRING(WDT_HEARTBEAT) ")"); "(default = " __MODULE_STRING(WDT_HEARTBEAT) ")");
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 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) ")"); "(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -96,7 +98,7 @@ static void at91_ping(unsigned long data) ...@@ -96,7 +98,7 @@ static void at91_ping(unsigned long data)
at91_wdt_reset(); at91_wdt_reset();
mod_timer(&at91wdt_private.timer, jiffies + WDT_TIMEOUT); mod_timer(&at91wdt_private.timer, jiffies + WDT_TIMEOUT);
} else } else
printk(KERN_CRIT DRV_NAME": I will reset your machine !\n"); pr_crit("I will reset your machine !\n");
} }
/* /*
...@@ -140,7 +142,7 @@ static int at91_wdt_settimeout(unsigned int timeout) ...@@ -140,7 +142,7 @@ static int at91_wdt_settimeout(unsigned int timeout)
/* Check if disabled */ /* Check if disabled */
mr = wdt_read(AT91_WDT_MR); mr = wdt_read(AT91_WDT_MR);
if (mr & AT91_WDT_WDDIS) { if (mr & AT91_WDT_WDDIS) {
printk(KERN_ERR DRV_NAME": sorry, watchdog is disabled\n"); pr_err("sorry, watchdog is disabled\n");
return -EIO; return -EIO;
} }
...@@ -283,7 +285,7 @@ static int __init at91wdt_probe(struct platform_device *pdev) ...@@ -283,7 +285,7 @@ static int __init at91wdt_probe(struct platform_device *pdev)
setup_timer(&at91wdt_private.timer, at91_ping, 0); setup_timer(&at91wdt_private.timer, at91_ping, 0);
mod_timer(&at91wdt_private.timer, jiffies + WDT_TIMEOUT); mod_timer(&at91wdt_private.timer, jiffies + WDT_TIMEOUT);
printk(KERN_INFO DRV_NAME " enabled (heartbeat=%d sec, nowayout=%d)\n", pr_info("enabled (heartbeat=%d sec, nowayout=%d)\n",
heartbeat, nowayout); heartbeat, nowayout);
return 0; return 0;
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
* *
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/fs.h> #include <linux/fs.h>
...@@ -45,8 +47,8 @@ ...@@ -45,8 +47,8 @@
#define WDOG_CTRL_ACTION_NMI 2 /* NMI */ #define WDOG_CTRL_ACTION_NMI 2 /* NMI */
#define WDOG_CTRL_ACTION_FCR 3 /* full chip reset */ #define WDOG_CTRL_ACTION_FCR 3 /* full chip reset */
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 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) ")"); "(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -114,8 +116,7 @@ static int ath79_wdt_release(struct inode *inode, struct file *file) ...@@ -114,8 +116,7 @@ static int ath79_wdt_release(struct inode *inode, struct file *file)
if (test_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags)) if (test_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags))
ath79_wdt_disable(); ath79_wdt_disable();
else { else {
pr_crit(DRIVER_NAME ": device closed unexpectedly, " pr_crit("device closed unexpectedly, watchdog timer will not stop!\n");
"watchdog timer will not stop!\n");
ath79_wdt_keepalive(); ath79_wdt_keepalive();
} }
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/fs.h> #include <linux/fs.h>
...@@ -33,14 +35,14 @@ ...@@ -33,14 +35,14 @@
#define WDT_MAX_TIME 255 /* seconds */ #define WDT_MAX_TIME 255 /* seconds */
static int wdt_time = WDT_DEFAULT_TIME; static int wdt_time = WDT_DEFAULT_TIME;
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(wdt_time, int, 0); module_param(wdt_time, int, 0);
MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default=" MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default="
__MODULE_STRING(WDT_DEFAULT_TIME) ")"); __MODULE_STRING(WDT_DEFAULT_TIME) ")");
#ifdef CONFIG_WATCHDOG_NOWAYOUT #ifdef CONFIG_WATCHDOG_NOWAYOUT
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default=" "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -91,7 +93,7 @@ static void bcm47xx_timer_tick(unsigned long unused) ...@@ -91,7 +93,7 @@ static void bcm47xx_timer_tick(unsigned long unused)
bcm47xx_wdt_hw_start(); bcm47xx_wdt_hw_start();
mod_timer(&wdt_timer, jiffies + HZ); mod_timer(&wdt_timer, jiffies + HZ);
} else { } else {
printk(KERN_CRIT DRV_NAME "Watchdog will fire soon!!!\n"); pr_crit("Watchdog will fire soon!!!\n");
} }
} }
...@@ -140,8 +142,7 @@ static int bcm47xx_wdt_release(struct inode *inode, struct file *file) ...@@ -140,8 +142,7 @@ static int bcm47xx_wdt_release(struct inode *inode, struct file *file)
if (expect_release == 42) { if (expect_release == 42) {
bcm47xx_wdt_stop(); bcm47xx_wdt_stop();
} else { } else {
printk(KERN_CRIT DRV_NAME pr_crit("Unexpected close, not stopping watchdog!\n");
": Unexpected close, not stopping watchdog!\n");
bcm47xx_wdt_start(); bcm47xx_wdt_start();
} }
...@@ -270,8 +271,7 @@ static int __init bcm47xx_wdt_init(void) ...@@ -270,8 +271,7 @@ static int __init bcm47xx_wdt_init(void)
if (bcm47xx_wdt_settimeout(wdt_time)) { if (bcm47xx_wdt_settimeout(wdt_time)) {
bcm47xx_wdt_settimeout(WDT_DEFAULT_TIME); bcm47xx_wdt_settimeout(WDT_DEFAULT_TIME);
printk(KERN_INFO DRV_NAME ": " pr_info("wdt_time value must be 0 < wdt_time < %d, using %d\n",
"wdt_time value must be 0 < wdt_time < %d, using %d\n",
(WDT_MAX_TIME + 1), wdt_time); (WDT_MAX_TIME + 1), wdt_time);
} }
...@@ -285,8 +285,8 @@ static int __init bcm47xx_wdt_init(void) ...@@ -285,8 +285,8 @@ static int __init bcm47xx_wdt_init(void)
return ret; return ret;
} }
printk(KERN_INFO "BCM47xx Watchdog Timer enabled (%d seconds%s)\n", pr_info("BCM47xx Watchdog Timer enabled (%d seconds%s)\n",
wdt_time, nowayout ? ", nowayout" : ""); wdt_time, nowayout ? ", nowayout" : "");
return 0; return 0;
} }
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/fs.h> #include <linux/fs.h>
...@@ -50,8 +52,8 @@ static struct { ...@@ -50,8 +52,8 @@ static struct {
static int expect_close; static int expect_close;
static int wdt_time = WDT_DEFAULT_TIME; static int wdt_time = WDT_DEFAULT_TIME;
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -82,7 +84,7 @@ static void bcm63xx_timer_tick(unsigned long unused) ...@@ -82,7 +84,7 @@ static void bcm63xx_timer_tick(unsigned long unused)
bcm63xx_wdt_hw_start(); bcm63xx_wdt_hw_start();
mod_timer(&bcm63xx_wdt_device.timer, jiffies + HZ); mod_timer(&bcm63xx_wdt_device.timer, jiffies + HZ);
} else } else
printk(KERN_CRIT PFX ": watchdog will restart system\n"); pr_crit("watchdog will restart system\n");
} }
static void bcm63xx_wdt_pet(void) static void bcm63xx_wdt_pet(void)
...@@ -126,8 +128,7 @@ static int bcm63xx_wdt_release(struct inode *inode, struct file *file) ...@@ -126,8 +128,7 @@ static int bcm63xx_wdt_release(struct inode *inode, struct file *file)
if (expect_close == 42) if (expect_close == 42)
bcm63xx_wdt_pause(); bcm63xx_wdt_pause();
else { else {
printk(KERN_CRIT PFX pr_crit("Unexpected close, not stopping watchdog!\n");
": Unexpected close, not stopping watchdog!\n");
bcm63xx_wdt_start(); bcm63xx_wdt_start();
} }
clear_bit(0, &bcm63xx_wdt_device.inuse); clear_bit(0, &bcm63xx_wdt_device.inuse);
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
* Licensed under the GPL-2 or later. * Licensed under the GPL-2 or later.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
...@@ -28,15 +30,8 @@ ...@@ -28,15 +30,8 @@
#define stamp(fmt, args...) \ #define stamp(fmt, args...) \
pr_debug("%s:%i: " fmt "\n", __func__, __LINE__, ## args) pr_debug("%s:%i: " fmt "\n", __func__, __LINE__, ## args)
#define stampit() stamp("here i am") #define stampit() stamp("here i am")
#define pr_devinit(fmt, args...) \
({ static const __devinitconst char __fmt[] = fmt; \
printk(__fmt, ## args); })
#define pr_init(fmt, args...) \
({ static const __initconst char __fmt[] = fmt; \
printk(__fmt, ## args); })
#define WATCHDOG_NAME "bfin-wdt" #define WATCHDOG_NAME "bfin-wdt"
#define PFX WATCHDOG_NAME ": "
/* The BF561 has two watchdogs (one per core), but since Linux /* The BF561 has two watchdogs (one per core), but since Linux
* only runs on core A, we'll just work with that one. * only runs on core A, we'll just work with that one.
...@@ -54,7 +49,7 @@ ...@@ -54,7 +49,7 @@
#define WATCHDOG_TIMEOUT 20 #define WATCHDOG_TIMEOUT 20
static unsigned int timeout = WATCHDOG_TIMEOUT; static unsigned int timeout = WATCHDOG_TIMEOUT;
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
static const struct watchdog_info bfin_wdt_info; static const struct watchdog_info bfin_wdt_info;
static unsigned long open_check; static unsigned long open_check;
static char expect_close; static char expect_close;
...@@ -126,7 +121,7 @@ static int bfin_wdt_set_timeout(unsigned long t) ...@@ -126,7 +121,7 @@ static int bfin_wdt_set_timeout(unsigned long t)
stamp("maxtimeout=%us newtimeout=%lus (cnt=%#x)", max_t, t, cnt); stamp("maxtimeout=%us newtimeout=%lus (cnt=%#x)", max_t, t, cnt);
if (t > max_t) { if (t > max_t) {
printk(KERN_WARNING PFX "timeout value is too large\n"); pr_warn("timeout value is too large\n");
return -EINVAL; return -EINVAL;
} }
...@@ -182,8 +177,7 @@ static int bfin_wdt_release(struct inode *inode, struct file *file) ...@@ -182,8 +177,7 @@ static int bfin_wdt_release(struct inode *inode, struct file *file)
if (expect_close == 42) if (expect_close == 42)
bfin_wdt_stop(); bfin_wdt_stop();
else { else {
printk(KERN_CRIT PFX pr_crit("Unexpected close, not stopping watchdog!\n");
"Unexpected close, not stopping watchdog!\n");
bfin_wdt_keepalive(); bfin_wdt_keepalive();
} }
expect_close = 0; expect_close = 0;
...@@ -368,14 +362,13 @@ static int __devinit bfin_wdt_probe(struct platform_device *pdev) ...@@ -368,14 +362,13 @@ static int __devinit bfin_wdt_probe(struct platform_device *pdev)
ret = misc_register(&bfin_wdt_miscdev); ret = misc_register(&bfin_wdt_miscdev);
if (ret) { if (ret) {
pr_devinit(KERN_ERR PFX pr_err("cannot register miscdev on minor=%d (err=%d)\n",
"cannot register miscdev on minor=%d (err=%d)\n", WATCHDOG_MINOR, ret);
WATCHDOG_MINOR, ret);
return ret; return ret;
} }
pr_devinit(KERN_INFO PFX "initialized: timeout=%d sec (nowayout=%d)\n", pr_info("initialized: timeout=%d sec (nowayout=%d)\n",
timeout, nowayout); timeout, nowayout);
return 0; return 0;
} }
...@@ -439,14 +432,14 @@ static int __init bfin_wdt_init(void) ...@@ -439,14 +432,14 @@ static int __init bfin_wdt_init(void)
*/ */
ret = platform_driver_register(&bfin_wdt_driver); ret = platform_driver_register(&bfin_wdt_driver);
if (ret) { if (ret) {
pr_init(KERN_ERR PFX "unable to register driver\n"); pr_err("unable to register driver\n");
return ret; return ret;
} }
bfin_wdt_device = platform_device_register_simple(WATCHDOG_NAME, bfin_wdt_device = platform_device_register_simple(WATCHDOG_NAME,
-1, NULL, 0); -1, NULL, 0);
if (IS_ERR(bfin_wdt_device)) { if (IS_ERR(bfin_wdt_device)) {
pr_init(KERN_ERR PFX "unable to register device\n"); pr_err("unable to register device\n");
platform_driver_unregister(&bfin_wdt_driver); platform_driver_unregister(&bfin_wdt_driver);
return PTR_ERR(bfin_wdt_device); return PTR_ERR(bfin_wdt_device);
} }
...@@ -479,7 +472,7 @@ MODULE_PARM_DESC(timeout, ...@@ -479,7 +472,7 @@ MODULE_PARM_DESC(timeout,
"Watchdog timeout in seconds. (1<=timeout<=((2^32)/SCLK), default=" "Watchdog timeout in seconds. (1<=timeout<=((2^32)/SCLK), default="
__MODULE_STRING(WATCHDOG_TIMEOUT) ")"); __MODULE_STRING(WATCHDOG_TIMEOUT) ")");
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default=" "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
* option) any later version. * option) any later version.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/smp.h> #include <linux/smp.h>
...@@ -225,8 +227,8 @@ static int booke_wdt_open(struct inode *inode, struct file *file) ...@@ -225,8 +227,8 @@ static int booke_wdt_open(struct inode *inode, struct file *file)
if (booke_wdt_enabled == 0) { if (booke_wdt_enabled == 0) {
booke_wdt_enabled = 1; booke_wdt_enabled = 1;
on_each_cpu(__booke_wdt_enable, NULL, 0); on_each_cpu(__booke_wdt_enable, NULL, 0);
pr_debug("booke_wdt: watchdog enabled (timeout = %llu sec)\n", pr_debug("watchdog enabled (timeout = %llu sec)\n",
period_to_sec(booke_wdt_period)); period_to_sec(booke_wdt_period));
} }
spin_unlock(&booke_wdt_lock); spin_unlock(&booke_wdt_lock);
...@@ -243,7 +245,7 @@ static int booke_wdt_release(struct inode *inode, struct file *file) ...@@ -243,7 +245,7 @@ static int booke_wdt_release(struct inode *inode, struct file *file)
*/ */
on_each_cpu(__booke_wdt_disable, NULL, 0); on_each_cpu(__booke_wdt_disable, NULL, 0);
booke_wdt_enabled = 0; booke_wdt_enabled = 0;
pr_debug("booke_wdt: watchdog disabled\n"); pr_debug("watchdog disabled\n");
#endif #endif
clear_bit(0, &wdt_is_active); clear_bit(0, &wdt_is_active);
...@@ -275,19 +277,19 @@ static int __init booke_wdt_init(void) ...@@ -275,19 +277,19 @@ static int __init booke_wdt_init(void)
{ {
int ret = 0; int ret = 0;
pr_info("booke_wdt: powerpc book-e watchdog driver loaded\n"); pr_info("powerpc book-e watchdog driver loaded\n");
ident.firmware_version = cur_cpu_spec->pvr_value; ident.firmware_version = cur_cpu_spec->pvr_value;
ret = misc_register(&booke_wdt_miscdev); ret = misc_register(&booke_wdt_miscdev);
if (ret) { if (ret) {
pr_err("booke_wdt: cannot register device (minor=%u, ret=%i)\n", pr_err("cannot register device (minor=%u, ret=%i)\n",
WATCHDOG_MINOR, ret); WATCHDOG_MINOR, ret);
return ret; return ret;
} }
spin_lock(&booke_wdt_lock); spin_lock(&booke_wdt_lock);
if (booke_wdt_enabled == 1) { if (booke_wdt_enabled == 1) {
pr_info("booke_wdt: watchdog enabled (timeout = %llu sec)\n", pr_info("watchdog enabled (timeout = %llu sec)\n",
period_to_sec(booke_wdt_period)); period_to_sec(booke_wdt_period));
on_each_cpu(__booke_wdt_enable, NULL, 0); on_each_cpu(__booke_wdt_enable, NULL, 0);
} }
......
...@@ -8,17 +8,15 @@ ...@@ -8,17 +8,15 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/fs.h>
#include <linux/miscdevice.h>
#include <linux/watchdog.h> #include <linux/watchdog.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/uaccess.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/err.h>
#define DRV_NAME "WDOG COH 901 327" #define DRV_NAME "WDOG COH 901 327"
...@@ -69,13 +67,11 @@ ...@@ -69,13 +67,11 @@
#define U300_WDOG_IFR_WILL_BARK_IRQ_FORCE_ENABLE 0x0001U #define U300_WDOG_IFR_WILL_BARK_IRQ_FORCE_ENABLE 0x0001U
/* Default timeout in seconds = 1 minute */ /* Default timeout in seconds = 1 minute */
static int margin = 60; static unsigned int margin = 60;
static resource_size_t phybase; static resource_size_t phybase;
static resource_size_t physize; static resource_size_t physize;
static int irq; static int irq;
static void __iomem *virtbase; static void __iomem *virtbase;
static unsigned long coh901327_users;
static unsigned long boot_status;
static struct device *parent; static struct device *parent;
/* /*
...@@ -155,34 +151,35 @@ static void coh901327_disable(void) ...@@ -155,34 +151,35 @@ static void coh901327_disable(void)
__func__, val); __func__, val);
} }
static void coh901327_start(void) static int coh901327_start(struct watchdog_device *wdt_dev)
{ {
coh901327_enable(margin * 100); coh901327_enable(wdt_dev->timeout * 100);
return 0;
}
static int coh901327_stop(struct watchdog_device *wdt_dev)
{
coh901327_disable();
return 0;
} }
static void coh901327_keepalive(void) static int coh901327_ping(struct watchdog_device *wdd)
{ {
clk_enable(clk); clk_enable(clk);
/* Feed the watchdog */ /* Feed the watchdog */
writew(U300_WDOG_FR_FEED_RESTART_TIMER, writew(U300_WDOG_FR_FEED_RESTART_TIMER,
virtbase + U300_WDOG_FR); virtbase + U300_WDOG_FR);
clk_disable(clk); clk_disable(clk);
return 0;
} }
static int coh901327_settimeout(int time) static int coh901327_settimeout(struct watchdog_device *wdt_dev,
unsigned int time)
{ {
/* wdt_dev->timeout = time;
* Max margin is 327 since the 10ms
* timeout register is max
* 0x7FFF = 327670ms ~= 327s.
*/
if (time <= 0 || time > 327)
return -EINVAL;
margin = time;
clk_enable(clk); clk_enable(clk);
/* Set new timeout value */ /* Set new timeout value */
writew(margin * 100, virtbase + U300_WDOG_TR); writew(time * 100, virtbase + U300_WDOG_TR);
/* Feed the dog */ /* Feed the dog */
writew(U300_WDOG_FR_FEED_RESTART_TIMER, writew(U300_WDOG_FR_FEED_RESTART_TIMER,
virtbase + U300_WDOG_FR); virtbase + U300_WDOG_FR);
...@@ -190,6 +187,23 @@ static int coh901327_settimeout(int time) ...@@ -190,6 +187,23 @@ static int coh901327_settimeout(int time)
return 0; return 0;
} }
static unsigned int coh901327_gettimeleft(struct watchdog_device *wdt_dev)
{
u16 val;
clk_enable(clk);
/* Read repeatedly until the value is stable! */
val = readw(virtbase + U300_WDOG_CR);
while (val & U300_WDOG_CR_VALID_IND)
val = readw(virtbase + U300_WDOG_CR);
val &= U300_WDOG_CR_COUNT_VALUE_MASK;
clk_disable(clk);
if (val != 0)
val /= 100;
return val;
}
/* /*
* This interrupt occurs 10 ms before the watchdog WILL bark. * This interrupt occurs 10 ms before the watchdog WILL bark.
*/ */
...@@ -218,130 +232,35 @@ static irqreturn_t coh901327_interrupt(int irq, void *data) ...@@ -218,130 +232,35 @@ static irqreturn_t coh901327_interrupt(int irq, void *data)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
/* static const struct watchdog_info coh901327_ident = {
* Allow only one user (daemon) to open the watchdog .options = WDIOF_CARDRESET | WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
*/ .identity = DRV_NAME,
static int coh901327_open(struct inode *inode, struct file *file) };
{
if (test_and_set_bit(1, &coh901327_users))
return -EBUSY;
coh901327_start();
return nonseekable_open(inode, file);
}
static int coh901327_release(struct inode *inode, struct file *file)
{
clear_bit(1, &coh901327_users);
coh901327_disable();
return 0;
}
static ssize_t coh901327_write(struct file *file, const char __user *data,
size_t len, loff_t *ppos)
{
if (len)
coh901327_keepalive();
return len;
}
static long coh901327_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
int ret = -ENOTTY;
u16 val;
int time;
int new_options;
union {
struct watchdog_info __user *ident;
int __user *i;
} uarg;
static const struct watchdog_info ident = {
.options = WDIOF_CARDRESET |
WDIOF_SETTIMEOUT |
WDIOF_KEEPALIVEPING,
.identity = "COH 901 327 Watchdog",
.firmware_version = 1,
};
uarg.i = (int __user *)arg;
switch (cmd) {
case WDIOC_GETSUPPORT:
ret = copy_to_user(uarg.ident, &ident,
sizeof(ident)) ? -EFAULT : 0;
break;
case WDIOC_GETSTATUS:
ret = put_user(0, uarg.i);
break;
case WDIOC_GETBOOTSTATUS:
ret = put_user(boot_status, uarg.i);
break;
case WDIOC_SETOPTIONS:
ret = get_user(new_options, uarg.i);
if (ret)
break;
if (new_options & WDIOS_DISABLECARD)
coh901327_disable();
if (new_options & WDIOS_ENABLECARD)
coh901327_start();
ret = 0;
break;
case WDIOC_KEEPALIVE:
coh901327_keepalive();
ret = 0;
break;
case WDIOC_SETTIMEOUT:
ret = get_user(time, uarg.i);
if (ret)
break;
ret = coh901327_settimeout(time);
if (ret)
break;
/* Then fall through to return set value */
case WDIOC_GETTIMEOUT:
ret = put_user(margin, uarg.i);
break;
case WDIOC_GETTIMELEFT:
clk_enable(clk);
/* Read repeatedly until the value is stable! */
val = readw(virtbase + U300_WDOG_CR);
while (val & U300_WDOG_CR_VALID_IND)
val = readw(virtbase + U300_WDOG_CR);
val &= U300_WDOG_CR_COUNT_VALUE_MASK;
clk_disable(clk);
if (val != 0)
val /= 100;
ret = put_user(val, uarg.i);
break;
}
return ret;
}
static const struct file_operations coh901327_fops = { static struct watchdog_ops coh901327_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.llseek = no_llseek, .start = coh901327_start,
.write = coh901327_write, .stop = coh901327_stop,
.unlocked_ioctl = coh901327_ioctl, .ping = coh901327_ping,
.open = coh901327_open, .set_timeout = coh901327_settimeout,
.release = coh901327_release, .get_timeleft = coh901327_gettimeleft,
}; };
static struct miscdevice coh901327_miscdev = { static struct watchdog_device coh901327_wdt = {
.minor = WATCHDOG_MINOR, .info = &coh901327_ident,
.name = "watchdog", .ops = &coh901327_ops,
.fops = &coh901327_fops, /*
* Max timeout is 327 since the 10ms
* timeout register is max
* 0x7FFF = 327670ms ~= 327s.
*/
.min_timeout = 0,
.max_timeout = 327,
}; };
static int __exit coh901327_remove(struct platform_device *pdev) static int __exit coh901327_remove(struct platform_device *pdev)
{ {
misc_deregister(&coh901327_miscdev); watchdog_unregister_device(&coh901327_wdt);
coh901327_disable(); coh901327_disable();
free_irq(irq, pdev); free_irq(irq, pdev);
clk_put(clk); clk_put(clk);
...@@ -350,7 +269,6 @@ static int __exit coh901327_remove(struct platform_device *pdev) ...@@ -350,7 +269,6 @@ static int __exit coh901327_remove(struct platform_device *pdev)
return 0; return 0;
} }
static int __init coh901327_probe(struct platform_device *pdev) static int __init coh901327_probe(struct platform_device *pdev)
{ {
int ret; int ret;
...@@ -393,7 +311,7 @@ static int __init coh901327_probe(struct platform_device *pdev) ...@@ -393,7 +311,7 @@ static int __init coh901327_probe(struct platform_device *pdev)
case U300_WDOG_SR_STATUS_TIMED_OUT: case U300_WDOG_SR_STATUS_TIMED_OUT:
dev_info(&pdev->dev, dev_info(&pdev->dev,
"watchdog timed out since last chip reset!\n"); "watchdog timed out since last chip reset!\n");
boot_status = WDIOF_CARDRESET; coh901327_wdt.bootstatus |= WDIOF_CARDRESET;
/* Status will be cleared below */ /* Status will be cleared below */
break; break;
case U300_WDOG_SR_STATUS_NORMAL: case U300_WDOG_SR_STATUS_NORMAL:
...@@ -435,7 +353,11 @@ static int __init coh901327_probe(struct platform_device *pdev) ...@@ -435,7 +353,11 @@ static int __init coh901327_probe(struct platform_device *pdev)
clk_disable(clk); clk_disable(clk);
ret = misc_register(&coh901327_miscdev); if (margin < 1 || margin > 327)
margin = 60;
coh901327_wdt.timeout = margin;
ret = watchdog_register_device(&coh901327_wdt);
if (ret == 0) if (ret == 0)
dev_info(&pdev->dev, dev_info(&pdev->dev,
"initialized. timer margin=%d sec\n", margin); "initialized. timer margin=%d sec\n", margin);
...@@ -543,8 +465,8 @@ module_exit(coh901327_exit); ...@@ -543,8 +465,8 @@ module_exit(coh901327_exit);
MODULE_AUTHOR("Linus Walleij <linus.walleij@stericsson.com>"); MODULE_AUTHOR("Linus Walleij <linus.walleij@stericsson.com>");
MODULE_DESCRIPTION("COH 901 327 Watchdog"); MODULE_DESCRIPTION("COH 901 327 Watchdog");
module_param(margin, int, 0); module_param(margin, uint, 0);
MODULE_PARM_DESC(margin, "Watchdog margin in seconds (default 60s)"); MODULE_PARM_DESC(margin, "Watchdog margin in seconds (default 60s)");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); MODULE_ALIAS("platform:coh901327-watchdog");
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
* *
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -71,7 +73,7 @@ static struct { ...@@ -71,7 +73,7 @@ static struct {
static void cpu5wdt_trigger(unsigned long unused) static void cpu5wdt_trigger(unsigned long unused)
{ {
if (verbose > 2) if (verbose > 2)
printk(KERN_DEBUG PFX "trigger at %i ticks\n", ticks); pr_debug("trigger at %i ticks\n", ticks);
if (cpu5wdt_device.running) if (cpu5wdt_device.running)
ticks--; ticks--;
...@@ -96,7 +98,7 @@ static void cpu5wdt_reset(void) ...@@ -96,7 +98,7 @@ static void cpu5wdt_reset(void)
ticks = cpu5wdt_device.default_ticks; ticks = cpu5wdt_device.default_ticks;
if (verbose) if (verbose)
printk(KERN_DEBUG PFX "reset (%i ticks)\n", (int) ticks); pr_debug("reset (%i ticks)\n", (int) ticks);
} }
...@@ -129,7 +131,7 @@ static int cpu5wdt_stop(void) ...@@ -129,7 +131,7 @@ static int cpu5wdt_stop(void)
ticks = cpu5wdt_device.default_ticks; ticks = cpu5wdt_device.default_ticks;
spin_unlock_irqrestore(&cpu5wdt_lock, flags); spin_unlock_irqrestore(&cpu5wdt_lock, flags);
if (verbose) if (verbose)
printk(KERN_CRIT PFX "stop not possible\n"); pr_crit("stop not possible\n");
return -EIO; return -EIO;
} }
...@@ -219,8 +221,7 @@ static int __devinit cpu5wdt_init(void) ...@@ -219,8 +221,7 @@ static int __devinit cpu5wdt_init(void)
int err; int err;
if (verbose) if (verbose)
printk(KERN_DEBUG PFX pr_debug("port=0x%x, verbose=%i\n", port, verbose);
"port=0x%x, verbose=%i\n", port, verbose);
init_completion(&cpu5wdt_device.stop); init_completion(&cpu5wdt_device.stop);
cpu5wdt_device.queue = 0; cpu5wdt_device.queue = 0;
...@@ -228,7 +229,7 @@ static int __devinit cpu5wdt_init(void) ...@@ -228,7 +229,7 @@ static int __devinit cpu5wdt_init(void)
cpu5wdt_device.default_ticks = ticks; cpu5wdt_device.default_ticks = ticks;
if (!request_region(port, CPU5WDT_EXTENT, PFX)) { if (!request_region(port, CPU5WDT_EXTENT, PFX)) {
printk(KERN_ERR PFX "request_region failed\n"); pr_err("request_region failed\n");
err = -EBUSY; err = -EBUSY;
goto no_port; goto no_port;
} }
...@@ -237,16 +238,16 @@ static int __devinit cpu5wdt_init(void) ...@@ -237,16 +238,16 @@ static int __devinit cpu5wdt_init(void)
val = inb(port + CPU5WDT_STATUS_REG); val = inb(port + CPU5WDT_STATUS_REG);
val = (val >> 2) & 1; val = (val >> 2) & 1;
if (!val) if (!val)
printk(KERN_INFO PFX "sorry, was my fault\n"); pr_info("sorry, was my fault\n");
err = misc_register(&cpu5wdt_misc); err = misc_register(&cpu5wdt_misc);
if (err < 0) { if (err < 0) {
printk(KERN_ERR PFX "misc_register failed\n"); pr_err("misc_register failed\n");
goto no_misc; goto no_misc;
} }
printk(KERN_INFO PFX "init success\n"); pr_info("init success\n");
return 0; return 0;
no_misc: no_misc:
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
* Copyright (C) 2008 David S. Miller <davem@davemloft.net> * Copyright (C) 2008 David S. Miller <davem@davemloft.net>
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/fs.h> #include <linux/fs.h>
...@@ -35,7 +37,6 @@ ...@@ -35,7 +37,6 @@
#include <asm/watchdog.h> #include <asm/watchdog.h>
#define DRIVER_NAME "cpwd" #define DRIVER_NAME "cpwd"
#define PFX DRIVER_NAME ": "
#define WD_OBPNAME "watchdog" #define WD_OBPNAME "watchdog"
#define WD_BADMODEL "SUNW,501-5336" #define WD_BADMODEL "SUNW,501-5336"
...@@ -385,8 +386,7 @@ static int cpwd_open(struct inode *inode, struct file *f) ...@@ -385,8 +386,7 @@ static int cpwd_open(struct inode *inode, struct file *f)
if (!p->initialized) { if (!p->initialized) {
if (request_irq(p->irq, &cpwd_interrupt, if (request_irq(p->irq, &cpwd_interrupt,
IRQF_SHARED, DRIVER_NAME, p)) { IRQF_SHARED, DRIVER_NAME, p)) {
printk(KERN_ERR PFX "Cannot register IRQ %d\n", pr_err("Cannot register IRQ %d\n", p->irq);
p->irq);
mutex_unlock(&cpwd_mutex); mutex_unlock(&cpwd_mutex);
return -EBUSY; return -EBUSY;
} }
...@@ -542,7 +542,7 @@ static int __devinit cpwd_probe(struct platform_device *op) ...@@ -542,7 +542,7 @@ static int __devinit cpwd_probe(struct platform_device *op)
p = kzalloc(sizeof(*p), GFP_KERNEL); p = kzalloc(sizeof(*p), GFP_KERNEL);
err = -ENOMEM; err = -ENOMEM;
if (!p) { if (!p) {
printk(KERN_ERR PFX "Unable to allocate struct cpwd.\n"); pr_err("Unable to allocate struct cpwd\n");
goto out; goto out;
} }
...@@ -553,14 +553,14 @@ static int __devinit cpwd_probe(struct platform_device *op) ...@@ -553,14 +553,14 @@ static int __devinit cpwd_probe(struct platform_device *op)
p->regs = of_ioremap(&op->resource[0], 0, p->regs = of_ioremap(&op->resource[0], 0,
4 * WD_TIMER_REGSZ, DRIVER_NAME); 4 * WD_TIMER_REGSZ, DRIVER_NAME);
if (!p->regs) { if (!p->regs) {
printk(KERN_ERR PFX "Unable to map registers.\n"); pr_err("Unable to map registers\n");
goto out_free; goto out_free;
} }
options = of_find_node_by_path("/options"); options = of_find_node_by_path("/options");
err = -ENODEV; err = -ENODEV;
if (!options) { if (!options) {
printk(KERN_ERR PFX "Unable to find /options node.\n"); pr_err("Unable to find /options node\n");
goto out_iounmap; goto out_iounmap;
} }
...@@ -605,8 +605,8 @@ static int __devinit cpwd_probe(struct platform_device *op) ...@@ -605,8 +605,8 @@ static int __devinit cpwd_probe(struct platform_device *op)
err = misc_register(&p->devs[i].misc); err = misc_register(&p->devs[i].misc);
if (err) { if (err) {
printk(KERN_ERR "Could not register misc device for " pr_err("Could not register misc device for dev %d\n",
"dev %d\n", i); i);
goto out_unregister; goto out_unregister;
} }
} }
...@@ -617,8 +617,8 @@ static int __devinit cpwd_probe(struct platform_device *op) ...@@ -617,8 +617,8 @@ static int __devinit cpwd_probe(struct platform_device *op)
cpwd_timer.data = (unsigned long) p; cpwd_timer.data = (unsigned long) p;
cpwd_timer.expires = WD_BTIMEOUT; cpwd_timer.expires = WD_BTIMEOUT;
printk(KERN_INFO PFX "PLD defect workaround enabled for " pr_info("PLD defect workaround enabled for model %s\n",
"model " WD_BADMODEL ".\n"); WD_BADMODEL);
} }
dev_set_drvdata(&op->dev, p); dev_set_drvdata(&op->dev, p);
......
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
* If we receive an expected close for the watchdog then we keep the timer * If we receive an expected close for the watchdog then we keep the timer
* running, otherwise the timer is stopped and the watchdog will expire. * running, otherwise the timer is stopped and the watchdog will expire.
*/ */
#define pr_fmt(fmt) "dw_wdt: " fmt
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/clk.h> #include <linux/clk.h>
...@@ -45,8 +46,8 @@ ...@@ -45,8 +46,8 @@
/* The maximum TOP (timeout period) value that can be set in the watchdog. */ /* The maximum TOP (timeout period) value that can be set in the watchdog. */
#define DW_WDT_MAX_TOP 15 #define DW_WDT_MAX_TOP 15
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 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) ")"); "(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
......
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
* Authors: Ray Lehtiniemi <rayl@mail.com>, * Authors: Ray Lehtiniemi <rayl@mail.com>,
* Alessandro Zummo <a.zummo@towertech.it> * Alessandro Zummo <a.zummo@towertech.it>
* *
* Copyright (c) 2012 H Hartley Sweeten <hsweeten@visionengravers.com>
* Convert to a platform device and use the watchdog framework API
*
* This file is licensed under the terms of the GNU General Public * This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any * License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied. * warranty of any kind, whether express or implied.
...@@ -25,187 +28,90 @@ ...@@ -25,187 +28,90 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/fs.h>
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
#include <linux/watchdog.h> #include <linux/watchdog.h>
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/uaccess.h>
#include <linux/io.h> #include <linux/io.h>
#define WDT_VERSION "0.3" #define WDT_VERSION "0.4"
#define PFX "ep93xx_wdt: "
/* default timeout (secs) */ /* default timeout (secs) */
#define WDT_TIMEOUT 30 #define WDT_TIMEOUT 30
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
static int timeout = WDT_TIMEOUT; module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
static unsigned int timeout = WDT_TIMEOUT;
module_param(timeout, uint, 0);
MODULE_PARM_DESC(timeout,
"Watchdog timeout in seconds. (1<=timeout<=3600, default="
__MODULE_STRING(WDT_TIMEOUT) ")");
static void __iomem *mmio_base; static void __iomem *mmio_base;
static struct timer_list timer; static struct timer_list timer;
static unsigned long next_heartbeat; static unsigned long next_heartbeat;
static unsigned long wdt_status;
static unsigned long boot_status;
#define WDT_IN_USE 0
#define WDT_OK_TO_CLOSE 1
#define EP93XX_WATCHDOG 0x00 #define EP93XX_WATCHDOG 0x00
#define EP93XX_WDSTATUS 0x04 #define EP93XX_WDSTATUS 0x04
/* reset the wdt every ~200ms */ /* reset the wdt every ~200ms - the heartbeat of the device is 0.250 seconds*/
#define WDT_INTERVAL (HZ/5) #define WDT_INTERVAL (HZ/5)
static void wdt_enable(void) static void ep93xx_wdt_timer_ping(unsigned long data)
{ {
writel(0xaaaa, mmio_base + EP93XX_WATCHDOG); if (time_before(jiffies, next_heartbeat))
} writel(0x5555, mmio_base + EP93XX_WATCHDOG);
static void wdt_disable(void)
{
writel(0xaa55, mmio_base + EP93XX_WATCHDOG);
}
static inline void wdt_ping(void) /* Re-set the timer interval */
{ mod_timer(&timer, jiffies + WDT_INTERVAL);
writel(0x5555, mmio_base + EP93XX_WATCHDOG);
} }
static void wdt_startup(void) static int ep93xx_wdt_start(struct watchdog_device *wdd)
{ {
next_heartbeat = jiffies + (timeout * HZ); next_heartbeat = jiffies + (timeout * HZ);
wdt_enable(); writel(0xaaaa, mmio_base + EP93XX_WATCHDOG);
mod_timer(&timer, jiffies + WDT_INTERVAL); mod_timer(&timer, jiffies + WDT_INTERVAL);
return 0;
} }
static void wdt_shutdown(void) static int ep93xx_wdt_stop(struct watchdog_device *wdd)
{ {
del_timer_sync(&timer); del_timer_sync(&timer);
wdt_disable(); writel(0xaa55, mmio_base + EP93XX_WATCHDOG);
return 0;
} }
static void wdt_keepalive(void) static int ep93xx_wdt_keepalive(struct watchdog_device *wdd)
{ {
/* user land ping */ /* user land ping */
next_heartbeat = jiffies + (timeout * HZ); next_heartbeat = jiffies + (timeout * HZ);
}
static int ep93xx_wdt_open(struct inode *inode, struct file *file)
{
if (test_and_set_bit(WDT_IN_USE, &wdt_status))
return -EBUSY;
clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
wdt_startup();
return nonseekable_open(inode, file);
}
static ssize_t
ep93xx_wdt_write(struct file *file, const char __user *data, size_t len,
loff_t *ppos)
{
if (len) {
if (!nowayout) {
size_t i;
clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
for (i = 0; i != len; i++) {
char c;
if (get_user(c, data + i))
return -EFAULT;
if (c == 'V')
set_bit(WDT_OK_TO_CLOSE, &wdt_status);
else
clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
}
}
wdt_keepalive();
}
return len; return 0;
} }
static const struct watchdog_info ident = { static const struct watchdog_info ep93xx_wdt_ident = {
.options = WDIOF_CARDRESET | WDIOF_MAGICCLOSE, .options = WDIOF_CARDRESET |
.identity = "EP93xx Watchdog", WDIOF_MAGICCLOSE |
WDIOF_KEEPALIVEPING,
.identity = "EP93xx Watchdog",
}; };
static long ep93xx_wdt_ioctl(struct file *file, static struct watchdog_ops ep93xx_wdt_ops = {
unsigned int cmd, unsigned long arg)
{
int ret = -ENOTTY;
switch (cmd) {
case WDIOC_GETSUPPORT:
ret = copy_to_user((struct watchdog_info __user *)arg, &ident,
sizeof(ident)) ? -EFAULT : 0;
break;
case WDIOC_GETSTATUS:
ret = put_user(0, (int __user *)arg);
break;
case WDIOC_GETBOOTSTATUS:
ret = put_user(boot_status, (int __user *)arg);
break;
case WDIOC_KEEPALIVE:
wdt_keepalive();
ret = 0;
break;
case WDIOC_GETTIMEOUT:
/* actually, it is 0.250 seconds.... */
ret = put_user(1, (int __user *)arg);
break;
}
return ret;
}
static int ep93xx_wdt_release(struct inode *inode, struct file *file)
{
if (test_bit(WDT_OK_TO_CLOSE, &wdt_status))
wdt_shutdown();
else
printk(KERN_CRIT PFX
"Device closed unexpectedly - timer will not stop\n");
clear_bit(WDT_IN_USE, &wdt_status);
clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
return 0;
}
static const struct file_operations ep93xx_wdt_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.write = ep93xx_wdt_write, .start = ep93xx_wdt_start,
.unlocked_ioctl = ep93xx_wdt_ioctl, .stop = ep93xx_wdt_stop,
.open = ep93xx_wdt_open, .ping = ep93xx_wdt_keepalive,
.release = ep93xx_wdt_release,
.llseek = no_llseek,
}; };
static struct miscdevice ep93xx_wdt_miscdev = { static struct watchdog_device ep93xx_wdt_wdd = {
.minor = WATCHDOG_MINOR, .info = &ep93xx_wdt_ident,
.name = "watchdog", .ops = &ep93xx_wdt_ops,
.fops = &ep93xx_wdt_fops,
}; };
static void ep93xx_timer_ping(unsigned long data)
{
if (time_before(jiffies, next_heartbeat))
wdt_ping();
/* Re-set the timer interval */
mod_timer(&timer, jiffies + WDT_INTERVAL);
}
static int __devinit ep93xx_wdt_probe(struct platform_device *pdev) static int __devinit ep93xx_wdt_probe(struct platform_device *pdev)
{ {
struct resource *res; struct resource *res;
...@@ -224,30 +130,35 @@ static int __devinit ep93xx_wdt_probe(struct platform_device *pdev) ...@@ -224,30 +130,35 @@ static int __devinit ep93xx_wdt_probe(struct platform_device *pdev)
if (!mmio_base) if (!mmio_base)
return -ENXIO; return -ENXIO;
err = misc_register(&ep93xx_wdt_miscdev);
val = readl(mmio_base + EP93XX_WATCHDOG);
boot_status = val & 0x01 ? 1 : 0;
printk(KERN_INFO PFX "EP93XX watchdog, driver version "
WDT_VERSION "%s\n",
(val & 0x08) ? " (nCS1 disable detected)" : "");
if (timeout < 1 || timeout > 3600) { if (timeout < 1 || timeout > 3600) {
timeout = WDT_TIMEOUT; timeout = WDT_TIMEOUT;
printk(KERN_INFO PFX dev_warn(&pdev->dev,
"timeout value must be 1<=x<=3600, using %d\n", "timeout value must be 1<=x<=3600, using %d\n",
timeout); timeout);
} }
setup_timer(&timer, ep93xx_timer_ping, 1); val = readl(mmio_base + EP93XX_WATCHDOG);
return err; ep93xx_wdt_wdd.bootstatus = (val & 0x01) ? WDIOF_CARDRESET : 0;
ep93xx_wdt_wdd.timeout = timeout;
watchdog_set_nowayout(&ep93xx_wdt_wdd, nowayout);
setup_timer(&timer, ep93xx_wdt_timer_ping, 1);
err = watchdog_register_device(&ep93xx_wdt_wdd);
if (err)
return err;
dev_info(&pdev->dev,
"EP93XX watchdog, driver version " WDT_VERSION "%s\n",
(val & 0x08) ? " (nCS1 disable detected)" : "");
return 0;
} }
static int __devexit ep93xx_wdt_remove(struct platform_device *pdev) static int __devexit ep93xx_wdt_remove(struct platform_device *pdev)
{ {
wdt_shutdown(); watchdog_unregister_device(&ep93xx_wdt_wdd);
misc_deregister(&ep93xx_wdt_miscdev);
return 0; return 0;
} }
...@@ -262,16 +173,9 @@ static struct platform_driver ep93xx_wdt_driver = { ...@@ -262,16 +173,9 @@ static struct platform_driver ep93xx_wdt_driver = {
module_platform_driver(ep93xx_wdt_driver); module_platform_driver(ep93xx_wdt_driver);
module_param(nowayout, int, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
module_param(timeout, int, 0);
MODULE_PARM_DESC(timeout,
"Watchdog timeout in seconds. (1<=timeout<=3600, default="
__MODULE_STRING(WDT_TIMEOUT) ")");
MODULE_AUTHOR("Ray Lehtiniemi <rayl@mail.com>," MODULE_AUTHOR("Ray Lehtiniemi <rayl@mail.com>,"
"Alessandro Zummo <a.zummo@towertech.it>"); "Alessandro Zummo <a.zummo@towertech.it>,"
"H Hartley Sweeten <hsweeten@visionengravers.com>");
MODULE_DESCRIPTION("EP93xx Watchdog"); MODULE_DESCRIPTION("EP93xx Watchdog");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_VERSION(WDT_VERSION); MODULE_VERSION(WDT_VERSION);
......
...@@ -45,6 +45,8 @@ ...@@ -45,6 +45,8 @@
* of the on-board SUPER I/O device SMSC FDC 37B782. * of the on-board SUPER I/O device SMSC FDC 37B782.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
...@@ -76,8 +78,8 @@ static char *ev = "int"; ...@@ -76,8 +78,8 @@ static char *ev = "int";
#define WDT_TIMEOUT 60 /* 1 minute */ #define WDT_TIMEOUT 60 /* 1 minute */
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default=" "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -144,11 +146,11 @@ static void eurwdt_activate_timer(void) ...@@ -144,11 +146,11 @@ static void eurwdt_activate_timer(void)
/* Setting interrupt line */ /* Setting interrupt line */
if (irq == 2 || irq > 15 || irq < 0) { if (irq == 2 || irq > 15 || irq < 0) {
printk(KERN_ERR ": invalid irq number\n"); pr_err("invalid irq number\n");
irq = 0; /* if invalid we disable interrupt */ irq = 0; /* if invalid we disable interrupt */
} }
if (irq == 0) if (irq == 0)
printk(KERN_INFO ": interrupt disabled\n"); pr_info("interrupt disabled\n");
eurwdt_write_reg(WDT_TIMER_CFG, irq << 4); eurwdt_write_reg(WDT_TIMER_CFG, irq << 4);
...@@ -163,12 +165,12 @@ static void eurwdt_activate_timer(void) ...@@ -163,12 +165,12 @@ static void eurwdt_activate_timer(void)
static irqreturn_t eurwdt_interrupt(int irq, void *dev_id) static irqreturn_t eurwdt_interrupt(int irq, void *dev_id)
{ {
printk(KERN_CRIT "timeout WDT timeout\n"); pr_crit("timeout WDT timeout\n");
#ifdef ONLY_TESTING #ifdef ONLY_TESTING
printk(KERN_CRIT "Would Reboot.\n"); pr_crit("Would Reboot\n");
#else #else
printk(KERN_CRIT "Initiating system reboot.\n"); pr_crit("Initiating system reboot\n");
emergency_restart(); emergency_restart();
#endif #endif
return IRQ_HANDLED; return IRQ_HANDLED;
...@@ -335,8 +337,7 @@ static int eurwdt_release(struct inode *inode, struct file *file) ...@@ -335,8 +337,7 @@ static int eurwdt_release(struct inode *inode, struct file *file)
if (eur_expect_close == 42) if (eur_expect_close == 42)
eurwdt_disable_timer(); eurwdt_disable_timer();
else { else {
printk(KERN_CRIT pr_crit("Unexpected close, not stopping watchdog!\n");
"eurwdt: Unexpected close, not stopping watchdog!\n");
eurwdt_ping(); eurwdt_ping();
} }
clear_bit(0, &eurwdt_is_open); clear_bit(0, &eurwdt_is_open);
...@@ -429,35 +430,32 @@ static int __init eurwdt_init(void) ...@@ -429,35 +430,32 @@ static int __init eurwdt_init(void)
ret = request_irq(irq, eurwdt_interrupt, 0, "eurwdt", NULL); ret = request_irq(irq, eurwdt_interrupt, 0, "eurwdt", NULL);
if (ret) { if (ret) {
printk(KERN_ERR "eurwdt: IRQ %d is not free.\n", irq); pr_err("IRQ %d is not free\n", irq);
goto out; goto out;
} }
if (!request_region(io, 2, "eurwdt")) { if (!request_region(io, 2, "eurwdt")) {
printk(KERN_ERR "eurwdt: IO %X is not free.\n", io); pr_err("IO %X is not free\n", io);
ret = -EBUSY; ret = -EBUSY;
goto outirq; goto outirq;
} }
ret = register_reboot_notifier(&eurwdt_notifier); ret = register_reboot_notifier(&eurwdt_notifier);
if (ret) { if (ret) {
printk(KERN_ERR pr_err("can't register reboot notifier (err=%d)\n", ret);
"eurwdt: can't register reboot notifier (err=%d)\n", ret);
goto outreg; goto outreg;
} }
ret = misc_register(&eurwdt_miscdev); ret = misc_register(&eurwdt_miscdev);
if (ret) { if (ret) {
printk(KERN_ERR "eurwdt: can't misc_register on minor=%d\n", pr_err("can't misc_register on minor=%d\n", WATCHDOG_MINOR);
WATCHDOG_MINOR);
goto outreboot; goto outreboot;
} }
eurwdt_unlock_chip(); eurwdt_unlock_chip();
ret = 0; ret = 0;
printk(KERN_INFO "Eurotech WDT driver 0.01 at %X (Interrupt %d)" pr_info("Eurotech WDT driver 0.01 at %X (Interrupt %d) - timeout event: %s\n",
" - timeout event: %s\n",
io, irq, (!strcmp("int", ev) ? "int" : "reboot")); io, irq, (!strcmp("int", ev) ? "int" : "reboot"));
out: out:
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/err.h> #include <linux/err.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -189,8 +191,7 @@ static inline int superio_enter(int base) ...@@ -189,8 +191,7 @@ static inline int superio_enter(int base)
{ {
/* Don't step on other drivers' I/O space by accident */ /* Don't step on other drivers' I/O space by accident */
if (!request_muxed_region(base, 2, DRVNAME)) { if (!request_muxed_region(base, 2, DRVNAME)) {
printk(KERN_ERR DRVNAME ": I/O address 0x%04x already in use\n", pr_err("I/O address 0x%04x already in use\n", (int)base);
(int)base);
return -EBUSY; return -EBUSY;
} }
...@@ -217,7 +218,7 @@ static int watchdog_set_timeout(int timeout) ...@@ -217,7 +218,7 @@ static int watchdog_set_timeout(int timeout)
{ {
if (timeout <= 0 if (timeout <= 0
|| timeout > max_timeout) { || timeout > max_timeout) {
printk(KERN_ERR DRVNAME ": watchdog timeout out of range\n"); pr_err("watchdog timeout out of range\n");
return -EINVAL; return -EINVAL;
} }
...@@ -252,7 +253,7 @@ static int watchdog_set_pulse_width(unsigned int pw) ...@@ -252,7 +253,7 @@ static int watchdog_set_pulse_width(unsigned int pw)
} else if (pw <= 5000) { } else if (pw <= 5000) {
watchdog.pulse_val = 3; watchdog.pulse_val = 3;
} else { } else {
printk(KERN_ERR DRVNAME ": pulse width out of range\n"); pr_err("pulse width out of range\n");
err = -EINVAL; err = -EINVAL;
goto exit_unlock; goto exit_unlock;
} }
...@@ -309,8 +310,7 @@ static int f71862fg_pin_configure(unsigned short ioaddr) ...@@ -309,8 +310,7 @@ static int f71862fg_pin_configure(unsigned short ioaddr)
if (ioaddr) if (ioaddr)
superio_set_bit(ioaddr, SIO_REG_MFUNCT1, 1); superio_set_bit(ioaddr, SIO_REG_MFUNCT1, 1);
} else { } else {
printk(KERN_ERR DRVNAME ": Invalid argument f71862fg_pin=%d\n", pr_err("Invalid argument f71862fg_pin=%d\n", f71862fg_pin);
f71862fg_pin);
return -EINVAL; return -EINVAL;
} }
return 0; return 0;
...@@ -487,8 +487,7 @@ static int watchdog_release(struct inode *inode, struct file *file) ...@@ -487,8 +487,7 @@ static int watchdog_release(struct inode *inode, struct file *file)
if (!watchdog.expect_close) { if (!watchdog.expect_close) {
watchdog_keepalive(); watchdog_keepalive();
printk(KERN_CRIT DRVNAME pr_crit("Unexpected close, not stopping watchdog!\n");
": Unexpected close, not stopping watchdog!\n");
} else if (!nowayout) { } else if (!nowayout) {
watchdog_stop(); watchdog_stop();
} }
...@@ -672,25 +671,22 @@ static int __init watchdog_init(int sioaddr) ...@@ -672,25 +671,22 @@ static int __init watchdog_init(int sioaddr)
err = misc_register(&watchdog_miscdev); err = misc_register(&watchdog_miscdev);
if (err) { if (err) {
printk(KERN_ERR DRVNAME pr_err("cannot register miscdev on minor=%d\n",
": cannot register miscdev on minor=%d\n", watchdog_miscdev.minor);
watchdog_miscdev.minor);
goto exit_reboot; goto exit_reboot;
} }
if (start_withtimeout) { if (start_withtimeout) {
if (start_withtimeout <= 0 if (start_withtimeout <= 0
|| start_withtimeout > max_timeout) { || start_withtimeout > max_timeout) {
printk(KERN_ERR DRVNAME pr_err("starting timeout out of range\n");
": starting timeout out of range\n");
err = -EINVAL; err = -EINVAL;
goto exit_miscdev; goto exit_miscdev;
} }
err = watchdog_start(); err = watchdog_start();
if (err) { if (err) {
printk(KERN_ERR DRVNAME pr_err("cannot start watchdog timer\n");
": cannot start watchdog timer\n");
goto exit_miscdev; goto exit_miscdev;
} }
...@@ -720,8 +716,7 @@ static int __init watchdog_init(int sioaddr) ...@@ -720,8 +716,7 @@ static int __init watchdog_init(int sioaddr)
if (nowayout) if (nowayout)
__module_get(THIS_MODULE); __module_get(THIS_MODULE);
printk(KERN_INFO DRVNAME pr_info("watchdog started with initial timeout of %u sec\n",
": watchdog started with initial timeout of %u sec\n",
start_withtimeout); start_withtimeout);
} }
...@@ -746,7 +741,7 @@ static int __init f71808e_find(int sioaddr) ...@@ -746,7 +741,7 @@ static int __init f71808e_find(int sioaddr)
devid = superio_inw(sioaddr, SIO_REG_MANID); devid = superio_inw(sioaddr, SIO_REG_MANID);
if (devid != SIO_FINTEK_ID) { if (devid != SIO_FINTEK_ID) {
pr_debug(DRVNAME ": Not a Fintek device\n"); pr_debug("Not a Fintek device\n");
err = -ENODEV; err = -ENODEV;
goto exit; goto exit;
} }
...@@ -774,13 +769,13 @@ static int __init f71808e_find(int sioaddr) ...@@ -774,13 +769,13 @@ static int __init f71808e_find(int sioaddr)
err = -ENODEV; err = -ENODEV;
goto exit; goto exit;
default: default:
printk(KERN_INFO DRVNAME ": Unrecognized Fintek device: %04x\n", pr_info("Unrecognized Fintek device: %04x\n",
(unsigned int)devid); (unsigned int)devid);
err = -ENODEV; err = -ENODEV;
goto exit; goto exit;
} }
printk(KERN_INFO DRVNAME ": Found %s watchdog chip, revision %d\n", pr_info("Found %s watchdog chip, revision %d\n",
f71808e_names[watchdog.type], f71808e_names[watchdog.type],
(int)superio_inb(sioaddr, SIO_REG_DEVREV)); (int)superio_inb(sioaddr, SIO_REG_DEVREV));
exit: exit:
...@@ -808,8 +803,7 @@ static int __init f71808e_init(void) ...@@ -808,8 +803,7 @@ static int __init f71808e_init(void)
static void __exit f71808e_exit(void) static void __exit f71808e_exit(void)
{ {
if (watchdog_is_running()) { if (watchdog_is_running()) {
printk(KERN_WARNING DRVNAME pr_warn("Watchdog timer still running, stopping it\n");
": Watchdog timer still running, stopping it\n");
watchdog_stop(); watchdog_stop();
} }
misc_deregister(&watchdog_miscdev); misc_deregister(&watchdog_miscdev);
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
* capabilities) a kernel-based watchdog. * capabilities) a kernel-based watchdog.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -68,8 +70,8 @@ static unsigned int bus_clk; ...@@ -68,8 +70,8 @@ static unsigned int bus_clk;
static char expect_close; static char expect_close;
static DEFINE_SPINLOCK(gef_wdt_spinlock); static DEFINE_SPINLOCK(gef_wdt_spinlock);
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -110,7 +112,7 @@ static void gef_wdt_handler_enable(void) ...@@ -110,7 +112,7 @@ static void gef_wdt_handler_enable(void)
if (gef_wdt_toggle_wdc(GEF_WDC_ENABLED_FALSE, if (gef_wdt_toggle_wdc(GEF_WDC_ENABLED_FALSE,
GEF_WDC_ENABLE_SHIFT)) { GEF_WDC_ENABLE_SHIFT)) {
gef_wdt_service(); gef_wdt_service();
printk(KERN_NOTICE "gef_wdt: watchdog activated\n"); pr_notice("watchdog activated\n");
} }
} }
...@@ -118,7 +120,7 @@ static void gef_wdt_handler_disable(void) ...@@ -118,7 +120,7 @@ static void gef_wdt_handler_disable(void)
{ {
if (gef_wdt_toggle_wdc(GEF_WDC_ENABLED_TRUE, if (gef_wdt_toggle_wdc(GEF_WDC_ENABLED_TRUE,
GEF_WDC_ENABLE_SHIFT)) GEF_WDC_ENABLE_SHIFT))
printk(KERN_NOTICE "gef_wdt: watchdog deactivated\n"); pr_notice("watchdog deactivated\n");
} }
static void gef_wdt_set_timeout(unsigned int timeout) static void gef_wdt_set_timeout(unsigned int timeout)
...@@ -234,8 +236,7 @@ static int gef_wdt_release(struct inode *inode, struct file *file) ...@@ -234,8 +236,7 @@ static int gef_wdt_release(struct inode *inode, struct file *file)
if (expect_close == 42) if (expect_close == 42)
gef_wdt_handler_disable(); gef_wdt_handler_disable();
else { else {
printk(KERN_CRIT pr_crit("unexpected close, not stopping timer!\n");
"gef_wdt: unexpected close, not stopping timer!\n");
gef_wdt_service(); gef_wdt_service();
} }
expect_close = 0; expect_close = 0;
...@@ -313,7 +314,7 @@ static struct platform_driver gef_wdt_driver = { ...@@ -313,7 +314,7 @@ static struct platform_driver gef_wdt_driver = {
static int __init gef_wdt_init(void) static int __init gef_wdt_init(void)
{ {
printk(KERN_INFO "GE watchdog driver\n"); pr_info("GE watchdog driver\n");
return platform_driver_register(&gef_wdt_driver); return platform_driver_register(&gef_wdt_driver);
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
...@@ -39,8 +40,8 @@ MODULE_PARM_DESC(timeout, ...@@ -39,8 +40,8 @@ MODULE_PARM_DESC(timeout,
"Watchdog timeout in seconds. 1<= timeout <=131, default=" "Watchdog timeout in seconds. 1<= timeout <=131, default="
__MODULE_STRING(WATCHDOG_TIMEOUT) "."); __MODULE_STRING(WATCHDOG_TIMEOUT) ".");
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default=" "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -100,7 +101,7 @@ static int geodewdt_release(struct inode *inode, struct file *file) ...@@ -100,7 +101,7 @@ static int geodewdt_release(struct inode *inode, struct file *file)
geodewdt_disable(); geodewdt_disable();
module_put(THIS_MODULE); module_put(THIS_MODULE);
} else { } else {
printk(KERN_CRIT "Unexpected close - watchdog is not stopping.\n"); pr_crit("Unexpected close - watchdog is not stopping\n");
geodewdt_ping(); geodewdt_ping();
set_bit(WDT_FLAGS_ORPHAN, &wdt_flags); set_bit(WDT_FLAGS_ORPHAN, &wdt_flags);
...@@ -220,7 +221,7 @@ static int __devinit geodewdt_probe(struct platform_device *dev) ...@@ -220,7 +221,7 @@ static int __devinit geodewdt_probe(struct platform_device *dev)
wdt_timer = cs5535_mfgpt_alloc_timer(MFGPT_TIMER_ANY, MFGPT_DOMAIN_WORKING); wdt_timer = cs5535_mfgpt_alloc_timer(MFGPT_TIMER_ANY, MFGPT_DOMAIN_WORKING);
if (!wdt_timer) { if (!wdt_timer) {
printk(KERN_ERR "geodewdt: No timers were available\n"); pr_err("No timers were available\n");
return -ENODEV; return -ENODEV;
} }
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
* *
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/device.h> #include <linux/device.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -45,7 +47,7 @@ ...@@ -45,7 +47,7 @@
static unsigned int soft_margin = DEFAULT_MARGIN; /* in seconds */ static unsigned int soft_margin = DEFAULT_MARGIN; /* in seconds */
static unsigned int reload; /* the computed soft_margin */ static unsigned int reload; /* the computed soft_margin */
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
static char expect_release; static char expect_release;
static unsigned long hpwdt_is_open; static unsigned long hpwdt_is_open;
...@@ -235,8 +237,7 @@ static int __devinit cru_detect(unsigned long map_entry, ...@@ -235,8 +237,7 @@ static int __devinit cru_detect(unsigned long map_entry,
asminline_call(&cmn_regs, bios32_entrypoint); asminline_call(&cmn_regs, bios32_entrypoint);
if (cmn_regs.u1.ral != 0) { if (cmn_regs.u1.ral != 0) {
printk(KERN_WARNING pr_warn("Call succeeded but with an error: 0x%x\n",
"hpwdt: Call succeeded but with an error: 0x%x\n",
cmn_regs.u1.ral); cmn_regs.u1.ral);
} else { } else {
physical_bios_base = cmn_regs.u2.rebx; physical_bios_base = cmn_regs.u2.rebx;
...@@ -256,14 +257,10 @@ static int __devinit cru_detect(unsigned long map_entry, ...@@ -256,14 +257,10 @@ static int __devinit cru_detect(unsigned long map_entry,
} }
} }
printk(KERN_DEBUG "hpwdt: CRU Base Address: 0x%lx\n", pr_debug("CRU Base Address: 0x%lx\n", physical_bios_base);
physical_bios_base); pr_debug("CRU Offset Address: 0x%lx\n", physical_bios_offset);
printk(KERN_DEBUG "hpwdt: CRU Offset Address: 0x%lx\n", pr_debug("CRU Length: 0x%lx\n", cru_length);
physical_bios_offset); pr_debug("CRU Mapped Address: %p\n", &cru_rom_addr);
printk(KERN_DEBUG "hpwdt: CRU Length: 0x%lx\n",
cru_length);
printk(KERN_DEBUG "hpwdt: CRU Mapped Address: %p\n",
&cru_rom_addr);
} }
iounmap(bios32_map); iounmap(bios32_map);
return retval; return retval;
...@@ -458,16 +455,13 @@ static void hpwdt_ping(void) ...@@ -458,16 +455,13 @@ static void hpwdt_ping(void)
static int hpwdt_change_timer(int new_margin) static int hpwdt_change_timer(int new_margin)
{ {
if (new_margin < 1 || new_margin > HPWDT_MAX_TIMER) { if (new_margin < 1 || new_margin > HPWDT_MAX_TIMER) {
printk(KERN_WARNING pr_warn("New value passed in is invalid: %d seconds\n",
"hpwdt: New value passed in is invalid: %d seconds.\n",
new_margin); new_margin);
return -EINVAL; return -EINVAL;
} }
soft_margin = new_margin; soft_margin = new_margin;
printk(KERN_DEBUG pr_debug("New timer passed in is %d seconds\n", new_margin);
"hpwdt: New timer passed in is %d seconds.\n",
new_margin);
reload = SECS_TO_TICKS(soft_margin); reload = SECS_TO_TICKS(soft_margin);
return 0; return 0;
...@@ -535,8 +529,7 @@ static int hpwdt_release(struct inode *inode, struct file *file) ...@@ -535,8 +529,7 @@ static int hpwdt_release(struct inode *inode, struct file *file)
if (expect_release == 42) { if (expect_release == 42) {
hpwdt_stop(); hpwdt_stop();
} else { } else {
printk(KERN_CRIT pr_crit("Unexpected close, not stopping watchdog!\n");
"hpwdt: Unexpected close, not stopping watchdog!\n");
hpwdt_ping(); hpwdt_ping();
} }
...@@ -881,7 +874,7 @@ MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); ...@@ -881,7 +874,7 @@ MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
module_param(soft_margin, int, 0); module_param(soft_margin, int, 0);
MODULE_PARM_DESC(soft_margin, "Watchdog timeout in seconds"); MODULE_PARM_DESC(soft_margin, "Watchdog timeout in seconds");
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
* Includes, defines, variables, module parameters, ... * Includes, defines, variables, module parameters, ...
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -44,7 +46,6 @@ ...@@ -44,7 +46,6 @@
#define ESB_VERSION "0.05" #define ESB_VERSION "0.05"
#define ESB_MODULE_NAME "i6300ESB timer" #define ESB_MODULE_NAME "i6300ESB timer"
#define ESB_DRIVER_NAME ESB_MODULE_NAME ", v" ESB_VERSION #define ESB_DRIVER_NAME ESB_MODULE_NAME ", v" ESB_VERSION
#define PFX ESB_MODULE_NAME ": "
/* PCI configuration registers */ /* PCI configuration registers */
#define ESB_CONFIG_REG 0x60 /* Config register */ #define ESB_CONFIG_REG 0x60 /* Config register */
...@@ -94,8 +95,8 @@ MODULE_PARM_DESC(heartbeat, ...@@ -94,8 +95,8 @@ MODULE_PARM_DESC(heartbeat,
"Watchdog heartbeat in seconds. (1<heartbeat<2046, default=" "Watchdog heartbeat in seconds. (1<heartbeat<2046, default="
__MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); __MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default=" "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -213,8 +214,7 @@ static int esb_release(struct inode *inode, struct file *file) ...@@ -213,8 +214,7 @@ static int esb_release(struct inode *inode, struct file *file)
if (esb_expect_close == 42) if (esb_expect_close == 42)
esb_timer_stop(); esb_timer_stop();
else { else {
printk(KERN_CRIT PFX pr_crit("Unexpected close, not stopping watchdog!\n");
"Unexpected close, not stopping watchdog!\n");
esb_timer_keepalive(); esb_timer_keepalive();
} }
clear_bit(0, &timer_alive); clear_bit(0, &timer_alive);
...@@ -347,19 +347,19 @@ MODULE_DEVICE_TABLE(pci, esb_pci_tbl); ...@@ -347,19 +347,19 @@ MODULE_DEVICE_TABLE(pci, esb_pci_tbl);
static unsigned char __devinit esb_getdevice(struct pci_dev *pdev) static unsigned char __devinit esb_getdevice(struct pci_dev *pdev)
{ {
if (pci_enable_device(pdev)) { if (pci_enable_device(pdev)) {
printk(KERN_ERR PFX "failed to enable device\n"); pr_err("failed to enable device\n");
goto err_devput; goto err_devput;
} }
if (pci_request_region(pdev, 0, ESB_MODULE_NAME)) { if (pci_request_region(pdev, 0, ESB_MODULE_NAME)) {
printk(KERN_ERR PFX "failed to request region\n"); pr_err("failed to request region\n");
goto err_disable; goto err_disable;
} }
BASEADDR = pci_ioremap_bar(pdev, 0); BASEADDR = pci_ioremap_bar(pdev, 0);
if (BASEADDR == NULL) { if (BASEADDR == NULL) {
/* Something's wrong here, BASEADDR has to be set */ /* Something's wrong here, BASEADDR has to be set */
printk(KERN_ERR PFX "failed to get BASEADDR\n"); pr_err("failed to get BASEADDR\n");
goto err_release; goto err_release;
} }
...@@ -397,7 +397,7 @@ static void __devinit esb_initdevice(void) ...@@ -397,7 +397,7 @@ static void __devinit esb_initdevice(void)
/* Check that the WDT isn't already locked */ /* Check that the WDT isn't already locked */
pci_read_config_byte(esb_pci, ESB_LOCK_REG, &val1); pci_read_config_byte(esb_pci, ESB_LOCK_REG, &val1);
if (val1 & ESB_WDT_LOCK) if (val1 & ESB_WDT_LOCK)
printk(KERN_WARNING PFX "nowayout already set\n"); pr_warn("nowayout already set\n");
/* Set the timer to watchdog mode and disable it for now */ /* Set the timer to watchdog mode and disable it for now */
pci_write_config_byte(esb_pci, ESB_LOCK_REG, 0x00); pci_write_config_byte(esb_pci, ESB_LOCK_REG, 0x00);
...@@ -423,11 +423,11 @@ static int __devinit esb_probe(struct pci_dev *pdev, ...@@ -423,11 +423,11 @@ static int __devinit esb_probe(struct pci_dev *pdev,
cards_found++; cards_found++;
if (cards_found == 1) if (cards_found == 1)
printk(KERN_INFO PFX "Intel 6300ESB WatchDog Timer Driver v%s\n", pr_info("Intel 6300ESB WatchDog Timer Driver v%s\n",
ESB_VERSION); ESB_VERSION);
if (cards_found > 1) { if (cards_found > 1) {
printk(KERN_ERR PFX "This driver only supports 1 device\n"); pr_err("This driver only supports 1 device\n");
return -ENODEV; return -ENODEV;
} }
...@@ -439,9 +439,8 @@ static int __devinit esb_probe(struct pci_dev *pdev, ...@@ -439,9 +439,8 @@ static int __devinit esb_probe(struct pci_dev *pdev,
if not reset to the default */ if not reset to the default */
if (heartbeat < 0x1 || heartbeat > 2 * 0x03ff) { if (heartbeat < 0x1 || heartbeat > 2 * 0x03ff) {
heartbeat = WATCHDOG_HEARTBEAT; heartbeat = WATCHDOG_HEARTBEAT;
printk(KERN_INFO PFX pr_info("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 */ /* Initialize the watchdog and make sure it does not run */
...@@ -450,14 +449,12 @@ static int __devinit esb_probe(struct pci_dev *pdev, ...@@ -450,14 +449,12 @@ static int __devinit esb_probe(struct pci_dev *pdev,
/* Register the watchdog so that userspace has access to it */ /* 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 pr_err("cannot register miscdev on minor=%d (err=%d)\n",
"cannot register miscdev on minor=%d (err=%d)\n", WATCHDOG_MINOR, ret);
WATCHDOG_MINOR, ret);
goto err_unmap; goto err_unmap;
} }
printk(KERN_INFO PFX pr_info("initialized (0x%p). heartbeat=%d sec (nowayout=%d)\n",
"initialized (0x%p). heartbeat=%d sec (nowayout=%d)\n", BASEADDR, heartbeat, nowayout);
BASEADDR, heartbeat, nowayout);
return 0; return 0;
err_unmap: err_unmap:
...@@ -503,7 +500,7 @@ static int __init watchdog_init(void) ...@@ -503,7 +500,7 @@ static int __init watchdog_init(void)
static void __exit watchdog_cleanup(void) static void __exit watchdog_cleanup(void)
{ {
pci_unregister_driver(&esb_driver); pci_unregister_driver(&esb_driver);
printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); pr_info("Watchdog Module Unloaded\n");
} }
module_init(watchdog_init); module_init(watchdog_init);
......
...@@ -17,10 +17,11 @@ ...@@ -17,10 +17,11 @@
* Includes, defines, variables, module parameters, ... * Includes, defines, variables, module parameters, ...
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
/* Module and version information */ /* Module and version information */
#define DRV_NAME "iTCO_vendor_support" #define DRV_NAME "iTCO_vendor_support"
#define DRV_VERSION "1.04" #define DRV_VERSION "1.04"
#define PFX DRV_NAME ": "
/* Includes */ /* Includes */
#include <linux/module.h> /* For module specific items */ #include <linux/module.h> /* For module specific items */
...@@ -355,13 +356,13 @@ EXPORT_SYMBOL(iTCO_vendor_check_noreboot_on); ...@@ -355,13 +356,13 @@ EXPORT_SYMBOL(iTCO_vendor_check_noreboot_on);
static int __init iTCO_vendor_init_module(void) static int __init iTCO_vendor_init_module(void)
{ {
printk(KERN_INFO PFX "vendor-support=%d\n", vendorsupport); pr_info("vendor-support=%d\n", vendorsupport);
return 0; return 0;
} }
static void __exit iTCO_vendor_exit_module(void) static void __exit iTCO_vendor_exit_module(void)
{ {
printk(KERN_INFO PFX "Module Unloaded\n"); pr_info("Module Unloaded\n");
} }
module_init(iTCO_vendor_init_module); module_init(iTCO_vendor_init_module);
......
...@@ -43,10 +43,11 @@ ...@@ -43,10 +43,11 @@
* Includes, defines, variables, module parameters, ... * Includes, defines, variables, module parameters, ...
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
/* Module and version information */ /* Module and version information */
#define DRV_NAME "iTCO_wdt" #define DRV_NAME "iTCO_wdt"
#define DRV_VERSION "1.07" #define DRV_VERSION "1.07"
#define PFX DRV_NAME ": "
/* Includes */ /* Includes */
#include <linux/module.h> /* For module specific items */ #include <linux/module.h> /* For module specific items */
...@@ -413,8 +414,8 @@ MODULE_PARM_DESC(heartbeat, "Watchdog timeout in seconds. " ...@@ -413,8 +414,8 @@ MODULE_PARM_DESC(heartbeat, "Watchdog timeout in seconds. "
"5..76 (TCO v1) or 3..614 (TCO v2), default=" "5..76 (TCO v1) or 3..614 (TCO v2), default="
__MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); __MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default=" "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -489,8 +490,7 @@ static int iTCO_wdt_start(void) ...@@ -489,8 +490,7 @@ static int iTCO_wdt_start(void)
/* disable chipset's NO_REBOOT bit */ /* disable chipset's NO_REBOOT bit */
if (iTCO_wdt_unset_NO_REBOOT_bit()) { if (iTCO_wdt_unset_NO_REBOOT_bit()) {
spin_unlock(&iTCO_wdt_private.io_lock); spin_unlock(&iTCO_wdt_private.io_lock);
printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, " pr_err("failed to reset NO_REBOOT flag, reboot disabled by hardware/BIOS\n");
"reboot disabled by hardware/BIOS\n");
return -EIO; return -EIO;
} }
...@@ -661,8 +661,7 @@ static int iTCO_wdt_release(struct inode *inode, struct file *file) ...@@ -661,8 +661,7 @@ static int iTCO_wdt_release(struct inode *inode, struct file *file)
if (expect_release == 42) { if (expect_release == 42) {
iTCO_wdt_stop(); iTCO_wdt_stop();
} else { } else {
printk(KERN_CRIT PFX pr_crit("Unexpected close, not stopping watchdog!\n");
"Unexpected close, not stopping watchdog!\n");
iTCO_wdt_keepalive(); iTCO_wdt_keepalive();
} }
clear_bit(0, &is_active); clear_bit(0, &is_active);
...@@ -804,8 +803,7 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev, ...@@ -804,8 +803,7 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev,
base_address &= 0x0000ff80; base_address &= 0x0000ff80;
if (base_address == 0x00000000) { if (base_address == 0x00000000) {
/* Something's wrong here, ACPIBASE has to be set */ /* Something's wrong here, ACPIBASE has to be set */
printk(KERN_ERR PFX "failed to get TCOBASE address, " pr_err("failed to get TCOBASE address, device disabled by hardware/BIOS\n");
"device disabled by hardware/BIOS\n");
return -ENODEV; return -ENODEV;
} }
iTCO_wdt_private.iTCO_version = iTCO_wdt_private.iTCO_version =
...@@ -820,8 +818,7 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev, ...@@ -820,8 +818,7 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev,
if (iTCO_wdt_private.iTCO_version == 2) { if (iTCO_wdt_private.iTCO_version == 2) {
pci_read_config_dword(pdev, 0xf0, &base_address); pci_read_config_dword(pdev, 0xf0, &base_address);
if ((base_address & 1) == 0) { if ((base_address & 1) == 0) {
printk(KERN_ERR PFX "RCBA is disabled by hardware" pr_err("RCBA is disabled by hardware/BIOS, device disabled\n");
"/BIOS, device disabled\n");
ret = -ENODEV; ret = -ENODEV;
goto out; goto out;
} }
...@@ -831,8 +828,7 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev, ...@@ -831,8 +828,7 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev,
/* Check chipset's NO_REBOOT bit */ /* Check chipset's NO_REBOOT bit */
if (iTCO_wdt_unset_NO_REBOOT_bit() && iTCO_vendor_check_noreboot_on()) { if (iTCO_wdt_unset_NO_REBOOT_bit() && iTCO_vendor_check_noreboot_on()) {
printk(KERN_INFO PFX "unable to reset NO_REBOOT flag, " pr_info("unable to reset NO_REBOOT flag, device disabled by hardware/BIOS\n");
"device disabled by hardware/BIOS\n");
ret = -ENODEV; /* Cannot reset NO_REBOOT bit */ ret = -ENODEV; /* Cannot reset NO_REBOOT bit */
goto out_unmap; goto out_unmap;
} }
...@@ -842,9 +838,8 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev, ...@@ -842,9 +838,8 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev,
/* The TCO logic uses the TCO_EN bit in the SMI_EN register */ /* The TCO logic uses the TCO_EN bit in the SMI_EN register */
if (!request_region(SMI_EN, 4, "iTCO_wdt")) { if (!request_region(SMI_EN, 4, "iTCO_wdt")) {
printk(KERN_ERR PFX pr_err("I/O address 0x%04lx already in use, device disabled\n",
"I/O address 0x%04lx already in use, " SMI_EN);
"device disabled\n", SMI_EN);
ret = -EIO; ret = -EIO;
goto out_unmap; goto out_unmap;
} }
...@@ -858,17 +853,16 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev, ...@@ -858,17 +853,16 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev,
/* The TCO I/O registers reside in a 32-byte range pointed to /* The TCO I/O registers reside in a 32-byte range pointed to
by the TCOBASE value */ by the TCOBASE value */
if (!request_region(TCOBASE, 0x20, "iTCO_wdt")) { if (!request_region(TCOBASE, 0x20, "iTCO_wdt")) {
printk(KERN_ERR PFX "I/O address 0x%04lx already in use " pr_err("I/O address 0x%04lx already in use, device disabled\n",
"device disabled\n", TCOBASE); TCOBASE);
ret = -EIO; ret = -EIO;
goto unreg_smi_en; goto unreg_smi_en;
} }
printk(KERN_INFO PFX pr_info("Found a %s TCO device (Version=%d, TCOBASE=0x%04lx)\n",
"Found a %s TCO device (Version=%d, TCOBASE=0x%04lx)\n", iTCO_chipset_info[ent->driver_data].name,
iTCO_chipset_info[ent->driver_data].name, iTCO_chipset_info[ent->driver_data].iTCO_version,
iTCO_chipset_info[ent->driver_data].iTCO_version, TCOBASE);
TCOBASE);
/* Clear out the (probably old) status */ /* Clear out the (probably old) status */
outw(0x0008, TCO1_STS); /* Clear the Time Out Status bit */ outw(0x0008, TCO1_STS); /* Clear the Time Out Status bit */
...@@ -882,20 +876,18 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev, ...@@ -882,20 +876,18 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev,
if not reset to the default */ if not reset to the default */
if (iTCO_wdt_set_heartbeat(heartbeat)) { if (iTCO_wdt_set_heartbeat(heartbeat)) {
iTCO_wdt_set_heartbeat(WATCHDOG_HEARTBEAT); iTCO_wdt_set_heartbeat(WATCHDOG_HEARTBEAT);
printk(KERN_INFO PFX pr_info("timeout value out of range, using %d\n", heartbeat);
"timeout value out of range, using %d\n", heartbeat);
} }
ret = misc_register(&iTCO_wdt_miscdev); ret = misc_register(&iTCO_wdt_miscdev);
if (ret != 0) { if (ret != 0) {
printk(KERN_ERR PFX pr_err("cannot register miscdev on minor=%d (err=%d)\n",
"cannot register miscdev on minor=%d (err=%d)\n", WATCHDOG_MINOR, ret);
WATCHDOG_MINOR, ret);
goto unreg_region; goto unreg_region;
} }
printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n", pr_info("initialized. heartbeat=%d sec (nowayout=%d)\n",
heartbeat, nowayout); heartbeat, nowayout);
return 0; return 0;
...@@ -947,7 +939,7 @@ static int __devinit iTCO_wdt_probe(struct platform_device *dev) ...@@ -947,7 +939,7 @@ static int __devinit iTCO_wdt_probe(struct platform_device *dev)
} }
if (!found) if (!found)
printk(KERN_INFO PFX "No device detected.\n"); pr_info("No device detected\n");
return ret; return ret;
} }
...@@ -979,8 +971,7 @@ static int __init iTCO_wdt_init_module(void) ...@@ -979,8 +971,7 @@ static int __init iTCO_wdt_init_module(void)
{ {
int err; int err;
printk(KERN_INFO PFX "Intel TCO WatchDog Timer Driver v%s\n", pr_info("Intel TCO WatchDog Timer Driver v%s\n", DRV_VERSION);
DRV_VERSION);
err = platform_driver_register(&iTCO_wdt_driver); err = platform_driver_register(&iTCO_wdt_driver);
if (err) if (err)
...@@ -1004,7 +995,7 @@ static void __exit iTCO_wdt_cleanup_module(void) ...@@ -1004,7 +995,7 @@ static void __exit iTCO_wdt_cleanup_module(void)
{ {
platform_device_unregister(iTCO_wdt_platform_device); platform_device_unregister(iTCO_wdt_platform_device);
platform_driver_unregister(&iTCO_wdt_driver); platform_driver_unregister(&iTCO_wdt_driver);
printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); pr_info("Watchdog Module Unloaded\n");
} }
module_init(iTCO_wdt_init_module); module_init(iTCO_wdt_init_module);
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
* *
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
...@@ -53,7 +55,6 @@ static char expect_close; ...@@ -53,7 +55,6 @@ static char expect_close;
/* Module information */ /* Module information */
#define DRV_NAME "ib700wdt" #define DRV_NAME "ib700wdt"
#define PFX DRV_NAME ": "
/* /*
* *
...@@ -102,8 +103,8 @@ MODULE_PARM_DESC(timeout, ...@@ -102,8 +103,8 @@ MODULE_PARM_DESC(timeout,
"Watchdog timeout in seconds. 0<= timeout <=30, default=" "Watchdog timeout in seconds. 0<= timeout <=30, default="
__MODULE_STRING(WATCHDOG_TIMEOUT) "."); __MODULE_STRING(WATCHDOG_TIMEOUT) ".");
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default=" "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -246,8 +247,7 @@ static int ibwdt_close(struct inode *inode, struct file *file) ...@@ -246,8 +247,7 @@ static int ibwdt_close(struct inode *inode, struct file *file)
if (expect_close == 42) { if (expect_close == 42) {
ibwdt_disable(); ibwdt_disable();
} else { } else {
printk(KERN_CRIT PFX pr_crit("WDT device closed unexpectedly. WDT will not stop!\n");
"WDT device closed unexpectedly. WDT will not stop!\n");
ibwdt_ping(); ibwdt_ping();
} }
clear_bit(0, &ibwdt_is_open); clear_bit(0, &ibwdt_is_open);
...@@ -284,16 +284,14 @@ static int __devinit ibwdt_probe(struct platform_device *dev) ...@@ -284,16 +284,14 @@ static int __devinit ibwdt_probe(struct platform_device *dev)
#if WDT_START != WDT_STOP #if WDT_START != WDT_STOP
if (!request_region(WDT_STOP, 1, "IB700 WDT")) { if (!request_region(WDT_STOP, 1, "IB700 WDT")) {
printk(KERN_ERR PFX "STOP method I/O %X is not available.\n", pr_err("STOP method I/O %X is not available\n", WDT_STOP);
WDT_STOP);
res = -EIO; res = -EIO;
goto out_nostopreg; goto out_nostopreg;
} }
#endif #endif
if (!request_region(WDT_START, 1, "IB700 WDT")) { if (!request_region(WDT_START, 1, "IB700 WDT")) {
printk(KERN_ERR PFX "START method I/O %X is not available.\n", pr_err("START method I/O %X is not available\n", WDT_START);
WDT_START);
res = -EIO; res = -EIO;
goto out_nostartreg; goto out_nostartreg;
} }
...@@ -302,13 +300,12 @@ static int __devinit ibwdt_probe(struct platform_device *dev) ...@@ -302,13 +300,12 @@ static int __devinit ibwdt_probe(struct platform_device *dev)
* if not reset to the default */ * if not reset to the default */
if (ibwdt_set_heartbeat(timeout)) { if (ibwdt_set_heartbeat(timeout)) {
ibwdt_set_heartbeat(WATCHDOG_TIMEOUT); ibwdt_set_heartbeat(WATCHDOG_TIMEOUT);
printk(KERN_INFO PFX pr_info("timeout value must be 0<=x<=30, using %d\n", timeout);
"timeout value must be 0<=x<=30, using %d\n", timeout);
} }
res = misc_register(&ibwdt_miscdev); res = misc_register(&ibwdt_miscdev);
if (res) { if (res) {
printk(KERN_ERR PFX "failed to register misc device\n"); pr_err("failed to register misc device\n");
goto out_nomisc; goto out_nomisc;
} }
return 0; return 0;
...@@ -353,8 +350,7 @@ static int __init ibwdt_init(void) ...@@ -353,8 +350,7 @@ static int __init ibwdt_init(void)
{ {
int err; int err;
printk(KERN_INFO PFX pr_info("WDT driver for IB700 single board computer initialising\n");
"WDT driver for IB700 single board computer initialising.\n");
err = platform_driver_register(&ibwdt_driver); err = platform_driver_register(&ibwdt_driver);
if (err) if (err)
...@@ -378,7 +374,7 @@ static void __exit ibwdt_exit(void) ...@@ -378,7 +374,7 @@ static void __exit ibwdt_exit(void)
{ {
platform_device_unregister(ibwdt_platform_device); platform_device_unregister(ibwdt_platform_device);
platform_driver_unregister(&ibwdt_driver); platform_driver_unregister(&ibwdt_driver);
printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); pr_info("Watchdog Module Unloaded\n");
} }
module_init(ibwdt_init); module_init(ibwdt_init);
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
* of the GNU Public License, incorporated herein by reference. * of the GNU Public License, incorporated herein by reference.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -31,8 +33,6 @@ enum { ...@@ -31,8 +33,6 @@ enum {
ASMTYPE_SPRUCE, ASMTYPE_SPRUCE,
}; };
#define PFX "ibmasr: "
#define TOPAZ_ASR_REG_OFFSET 4 #define TOPAZ_ASR_REG_OFFSET 4
#define TOPAZ_ASR_TOGGLE 0x40 #define TOPAZ_ASR_TOGGLE 0x40
#define TOPAZ_ASR_DISABLE 0x80 #define TOPAZ_ASR_DISABLE 0x80
...@@ -60,7 +60,7 @@ enum { ...@@ -60,7 +60,7 @@ enum {
#define SPRUCE_ASR_TOGGLE_MASK 0x02 /* bit 0: 0, then 1, then 0 */ #define SPRUCE_ASR_TOGGLE_MASK 0x02 /* bit 0: 0, then 1, then 0 */
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
static unsigned long asr_is_open; static unsigned long asr_is_open;
static char asr_expect_close; static char asr_expect_close;
...@@ -234,12 +234,11 @@ static int __init asr_get_base_address(void) ...@@ -234,12 +234,11 @@ static int __init asr_get_base_address(void)
} }
if (!request_region(asr_base, asr_length, "ibmasr")) { if (!request_region(asr_base, asr_length, "ibmasr")) {
printk(KERN_ERR PFX "address %#x already in use\n", pr_err("address %#x already in use\n", asr_base);
asr_base);
return -EBUSY; return -EBUSY;
} }
printk(KERN_INFO PFX "found %sASR @ addr %#x\n", type, asr_base); pr_info("found %sASR @ addr %#x\n", type, asr_base);
return 0; return 0;
} }
...@@ -332,8 +331,7 @@ static int asr_release(struct inode *inode, struct file *file) ...@@ -332,8 +331,7 @@ static int asr_release(struct inode *inode, struct file *file)
if (asr_expect_close == 42) if (asr_expect_close == 42)
asr_disable(); asr_disable();
else { else {
printk(KERN_CRIT PFX pr_crit("unexpected close, not stopping watchdog!\n");
"unexpected close, not stopping watchdog!\n");
asr_toggle(); asr_toggle();
} }
clear_bit(0, &asr_is_open); clear_bit(0, &asr_is_open);
...@@ -393,7 +391,7 @@ static int __init ibmasr_init(void) ...@@ -393,7 +391,7 @@ static int __init ibmasr_init(void)
rc = misc_register(&asr_miscdev); rc = misc_register(&asr_miscdev);
if (rc < 0) { if (rc < 0) {
release_region(asr_base, asr_length); release_region(asr_base, asr_length);
printk(KERN_ERR PFX "failed to register misc device\n"); pr_err("failed to register misc device\n");
return rc; return rc;
} }
...@@ -413,7 +411,7 @@ static void __exit ibmasr_exit(void) ...@@ -413,7 +411,7 @@ static void __exit ibmasr_exit(void)
module_init(ibmasr_init); module_init(ibmasr_init);
module_exit(ibmasr_exit); module_exit(ibmasr_exit);
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default=" "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
......
...@@ -46,6 +46,9 @@ ...@@ -46,6 +46,9 @@
#define IMX2_WDT_SEQ1 0x5555 /* -> service sequence 1 */ #define IMX2_WDT_SEQ1 0x5555 /* -> service sequence 1 */
#define IMX2_WDT_SEQ2 0xAAAA /* -> service sequence 2 */ #define IMX2_WDT_SEQ2 0xAAAA /* -> service sequence 2 */
#define IMX2_WDT_WRSR 0x04 /* Reset Status Register */
#define IMX2_WDT_WRSR_TOUT (1 << 1) /* -> Reset due to Timeout */
#define IMX2_WDT_MAX_TIME 128 #define IMX2_WDT_MAX_TIME 128
#define IMX2_WDT_DEFAULT_TIME 60 /* in seconds */ #define IMX2_WDT_DEFAULT_TIME 60 /* in seconds */
...@@ -65,8 +68,8 @@ static struct { ...@@ -65,8 +68,8 @@ static struct {
static struct miscdevice imx2_wdt_miscdev; static struct miscdevice imx2_wdt_miscdev;
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -175,6 +178,7 @@ static long imx2_wdt_ioctl(struct file *file, unsigned int cmd, ...@@ -175,6 +178,7 @@ static long imx2_wdt_ioctl(struct file *file, unsigned int cmd,
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
int __user *p = argp; int __user *p = argp;
int new_value; int new_value;
u16 val;
switch (cmd) { switch (cmd) {
case WDIOC_GETSUPPORT: case WDIOC_GETSUPPORT:
...@@ -182,9 +186,13 @@ static long imx2_wdt_ioctl(struct file *file, unsigned int cmd, ...@@ -182,9 +186,13 @@ static long imx2_wdt_ioctl(struct file *file, unsigned int cmd,
sizeof(struct watchdog_info)) ? -EFAULT : 0; sizeof(struct watchdog_info)) ? -EFAULT : 0;
case WDIOC_GETSTATUS: case WDIOC_GETSTATUS:
case WDIOC_GETBOOTSTATUS:
return put_user(0, p); return put_user(0, p);
case WDIOC_GETBOOTSTATUS:
val = __raw_readw(imx2_wdt.base + IMX2_WDT_WRSR);
new_value = val & IMX2_WDT_WRSR_TOUT ? WDIOF_CARDRESET : 0;
return put_user(new_value, p);
case WDIOC_KEEPALIVE: case WDIOC_KEEPALIVE:
imx2_wdt_ping(); imx2_wdt_ping();
return 0; return 0;
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
* based on softdog.c by Alan Cox <alan@lxorguk.ukuu.org.uk> * based on softdog.c by Alan Cox <alan@lxorguk.ukuu.org.uk>
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -26,14 +28,13 @@ ...@@ -26,14 +28,13 @@
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <asm/sgi/mc.h> #include <asm/sgi/mc.h>
#define PFX "indydog: "
static unsigned long indydog_alive; static unsigned long indydog_alive;
static DEFINE_SPINLOCK(indydog_lock); static DEFINE_SPINLOCK(indydog_lock);
#define WATCHDOG_TIMEOUT 30 /* 30 sec default timeout */ #define WATCHDOG_TIMEOUT 30 /* 30 sec default timeout */
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default=" "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -60,7 +61,7 @@ static void indydog_stop(void) ...@@ -60,7 +61,7 @@ static void indydog_stop(void)
sgimc->cpuctrl0 = mc_ctrl0; sgimc->cpuctrl0 = mc_ctrl0;
spin_unlock(&indydog_lock); spin_unlock(&indydog_lock);
printk(KERN_INFO PFX "Stopped watchdog timer.\n"); pr_info("Stopped watchdog timer\n");
} }
static void indydog_ping(void) static void indydog_ping(void)
...@@ -83,7 +84,7 @@ static int indydog_open(struct inode *inode, struct file *file) ...@@ -83,7 +84,7 @@ static int indydog_open(struct inode *inode, struct file *file)
indydog_start(); indydog_start();
indydog_ping(); indydog_ping();
printk(KERN_INFO "Started watchdog timer.\n"); pr_info("Started watchdog timer\n");
return nonseekable_open(inode, file); return nonseekable_open(inode, file);
} }
...@@ -178,30 +179,25 @@ static struct notifier_block indydog_notifier = { ...@@ -178,30 +179,25 @@ static struct notifier_block indydog_notifier = {
.notifier_call = indydog_notify_sys, .notifier_call = indydog_notify_sys,
}; };
static char banner[] __initdata =
KERN_INFO PFX "Hardware Watchdog Timer for SGI IP22: 0.3\n";
static int __init watchdog_init(void) static int __init watchdog_init(void)
{ {
int ret; int ret;
ret = register_reboot_notifier(&indydog_notifier); ret = register_reboot_notifier(&indydog_notifier);
if (ret) { if (ret) {
printk(KERN_ERR PFX pr_err("cannot register reboot notifier (err=%d)\n", ret);
"cannot register reboot notifier (err=%d)\n", ret);
return ret; return ret;
} }
ret = misc_register(&indydog_miscdev); ret = misc_register(&indydog_miscdev);
if (ret) { if (ret) {
printk(KERN_ERR PFX pr_err("cannot register miscdev on minor=%d (err=%d)\n",
"cannot register miscdev on minor=%d (err=%d)\n", WATCHDOG_MINOR, ret);
WATCHDOG_MINOR, ret);
unregister_reboot_notifier(&indydog_notifier); unregister_reboot_notifier(&indydog_notifier);
return ret; return ret;
} }
printk(banner); pr_info("Hardware Watchdog Timer for SGI IP22: 0.3\n");
return 0; return 0;
} }
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
* *
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -96,15 +98,14 @@ static struct intel_scu_watchdog_dev watchdog_device; ...@@ -96,15 +98,14 @@ static struct intel_scu_watchdog_dev watchdog_device;
static void watchdog_fire(void) static void watchdog_fire(void)
{ {
if (force_boot) { if (force_boot) {
printk(KERN_CRIT PFX "Initiating system reboot.\n"); pr_crit("Initiating system reboot\n");
emergency_restart(); emergency_restart();
printk(KERN_CRIT PFX "Reboot didn't ?????\n"); pr_crit("Reboot didn't ?????\n");
} }
else { else {
printk(KERN_CRIT PFX "Immediate Reboot Disabled\n"); pr_crit("Immediate Reboot Disabled\n");
printk(KERN_CRIT PFX pr_crit("System will reset when watchdog timer times out!\n");
"System will reset when watchdog timer times out!\n");
} }
} }
...@@ -112,8 +113,8 @@ static int check_timer_margin(int new_margin) ...@@ -112,8 +113,8 @@ static int check_timer_margin(int new_margin)
{ {
if ((new_margin < MIN_TIME_CYCLE) || if ((new_margin < MIN_TIME_CYCLE) ||
(new_margin > MAX_TIME - timer_set)) { (new_margin > MAX_TIME - timer_set)) {
pr_debug("Watchdog timer: value of new_margin %d is out of the range %d to %d\n", pr_debug("value of new_margin %d is out of the range %d to %d\n",
new_margin, MIN_TIME_CYCLE, MAX_TIME - timer_set); new_margin, MIN_TIME_CYCLE, MAX_TIME - timer_set);
return -EINVAL; return -EINVAL;
} }
return 0; return 0;
...@@ -156,14 +157,14 @@ static irqreturn_t watchdog_timer_interrupt(int irq, void *dev_id) ...@@ -156,14 +157,14 @@ static irqreturn_t watchdog_timer_interrupt(int irq, void *dev_id)
int int_status; int int_status;
int_status = ioread32(watchdog_device.timer_interrupt_status_addr); int_status = ioread32(watchdog_device.timer_interrupt_status_addr);
pr_debug("Watchdog timer: irq, int_status: %x\n", int_status); pr_debug("irq, int_status: %x\n", int_status);
if (int_status != 0) if (int_status != 0)
return IRQ_NONE; return IRQ_NONE;
/* has the timer been started? If not, then this is spurious */ /* has the timer been started? If not, then this is spurious */
if (watchdog_device.timer_started == 0) { if (watchdog_device.timer_started == 0) {
pr_debug("Watchdog timer: spurious interrupt received\n"); pr_debug("spurious interrupt received\n");
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -220,16 +221,15 @@ static int intel_scu_set_heartbeat(u32 t) ...@@ -220,16 +221,15 @@ static int intel_scu_set_heartbeat(u32 t)
(watchdog_device.timer_set - timer_margin) (watchdog_device.timer_set - timer_margin)
* watchdog_device.timer_tbl_ptr->freq_hz; * watchdog_device.timer_tbl_ptr->freq_hz;
pr_debug("Watchdog timer: set_heartbeat: timer freq is %d\n", pr_debug("set_heartbeat: timer freq is %d\n",
watchdog_device.timer_tbl_ptr->freq_hz); watchdog_device.timer_tbl_ptr->freq_hz);
pr_debug("Watchdog timer: set_heartbeat: timer_set is %x (hex)\n", pr_debug("set_heartbeat: timer_set is %x (hex)\n",
watchdog_device.timer_set); watchdog_device.timer_set);
pr_debug("Watchdog timer: set_hearbeat: timer_margin is %x (hex)\n", pr_debug("set_hearbeat: timer_margin is %x (hex)\n", timer_margin);
timer_margin); pr_debug("set_heartbeat: threshold is %x (hex)\n",
pr_debug("Watchdog timer: set_heartbeat: threshold is %x (hex)\n", watchdog_device.threshold);
watchdog_device.threshold); pr_debug("set_heartbeat: soft_threshold is %x (hex)\n",
pr_debug("Watchdog timer: set_heartbeat: soft_threshold is %x (hex)\n", watchdog_device.soft_threshold);
watchdog_device.soft_threshold);
/* Adjust thresholds by FREQ_ADJUSTMENT factor, to make the */ /* Adjust thresholds by FREQ_ADJUSTMENT factor, to make the */
/* watchdog timing come out right. */ /* watchdog timing come out right. */
...@@ -264,7 +264,7 @@ static int intel_scu_set_heartbeat(u32 t) ...@@ -264,7 +264,7 @@ static int intel_scu_set_heartbeat(u32 t)
if (MAX_RETRY < retry_count++) { if (MAX_RETRY < retry_count++) {
/* Unable to set timer value */ /* Unable to set timer value */
pr_err("Watchdog timer: Unable to set timer\n"); pr_err("Unable to set timer\n");
return -ENODEV; return -ENODEV;
} }
...@@ -321,18 +321,17 @@ static int intel_scu_release(struct inode *inode, struct file *file) ...@@ -321,18 +321,17 @@ static int intel_scu_release(struct inode *inode, struct file *file)
*/ */
if (!test_and_clear_bit(0, &watchdog_device.driver_open)) { if (!test_and_clear_bit(0, &watchdog_device.driver_open)) {
pr_debug("Watchdog timer: intel_scu_release, without open\n"); pr_debug("intel_scu_release, without open\n");
return -ENOTTY; return -ENOTTY;
} }
if (!watchdog_device.timer_started) { if (!watchdog_device.timer_started) {
/* Just close, since timer has not been started */ /* Just close, since timer has not been started */
pr_debug("Watchdog timer: closed, without starting timer\n"); pr_debug("closed, without starting timer\n");
return 0; return 0;
} }
printk(KERN_CRIT PFX pr_crit("Unexpected close of /dev/watchdog!\n");
"Unexpected close of /dev/watchdog!\n");
/* Since the timer was started, prevent future reopens */ /* Since the timer was started, prevent future reopens */
watchdog_device.driver_closed = 1; watchdog_device.driver_closed = 1;
...@@ -454,9 +453,8 @@ static int __init intel_scu_watchdog_init(void) ...@@ -454,9 +453,8 @@ static int __init intel_scu_watchdog_init(void)
/* Check value of timer_set boot parameter */ /* Check value of timer_set boot parameter */
if ((timer_set < MIN_TIME_CYCLE) || if ((timer_set < MIN_TIME_CYCLE) ||
(timer_set > MAX_TIME - MIN_TIME_CYCLE)) { (timer_set > MAX_TIME - MIN_TIME_CYCLE)) {
pr_err("Watchdog timer: value of timer_set %x (hex) " pr_err("value of timer_set %x (hex) is out of range from %x to %x (hex)\n",
"is out of range from %x to %x (hex)\n", timer_set, MIN_TIME_CYCLE, MAX_TIME - MIN_TIME_CYCLE);
timer_set, MIN_TIME_CYCLE, MAX_TIME - MIN_TIME_CYCLE);
return -EINVAL; return -EINVAL;
} }
...@@ -467,19 +465,18 @@ static int __init intel_scu_watchdog_init(void) ...@@ -467,19 +465,18 @@ static int __init intel_scu_watchdog_init(void)
watchdog_device.timer_tbl_ptr = sfi_get_mtmr(sfi_mtimer_num-1); watchdog_device.timer_tbl_ptr = sfi_get_mtmr(sfi_mtimer_num-1);
if (watchdog_device.timer_tbl_ptr == NULL) { if (watchdog_device.timer_tbl_ptr == NULL) {
pr_debug("Watchdog timer - Intel SCU watchdog: timer is not available\n"); pr_debug("timer is not available\n");
return -ENODEV; return -ENODEV;
} }
/* make sure the timer exists */ /* make sure the timer exists */
if (watchdog_device.timer_tbl_ptr->phys_addr == 0) { if (watchdog_device.timer_tbl_ptr->phys_addr == 0) {
pr_debug("Watchdog timer - Intel SCU watchdog - timer %d does not have valid physical memory\n", pr_debug("timer %d does not have valid physical memory\n",
sfi_mtimer_num); sfi_mtimer_num);
return -ENODEV; return -ENODEV;
} }
if (watchdog_device.timer_tbl_ptr->irq == 0) { if (watchdog_device.timer_tbl_ptr->irq == 0) {
pr_debug("Watchdog timer: timer %d invalid irq\n", pr_debug("timer %d invalid irq\n", sfi_mtimer_num);
sfi_mtimer_num);
return -ENODEV; return -ENODEV;
} }
...@@ -487,7 +484,7 @@ static int __init intel_scu_watchdog_init(void) ...@@ -487,7 +484,7 @@ static int __init intel_scu_watchdog_init(void)
20); 20);
if (tmp_addr == NULL) { if (tmp_addr == NULL) {
pr_debug("Watchdog timer: timer unable to ioremap\n"); pr_debug("timer unable to ioremap\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -512,7 +509,7 @@ static int __init intel_scu_watchdog_init(void) ...@@ -512,7 +509,7 @@ static int __init intel_scu_watchdog_init(void)
ret = register_reboot_notifier(&watchdog_device.intel_scu_notifier); ret = register_reboot_notifier(&watchdog_device.intel_scu_notifier);
if (ret) { if (ret) {
pr_err("Watchdog timer: cannot register notifier %d)\n", ret); pr_err("cannot register notifier %d)\n", ret);
goto register_reboot_error; goto register_reboot_error;
} }
...@@ -522,8 +519,8 @@ static int __init intel_scu_watchdog_init(void) ...@@ -522,8 +519,8 @@ static int __init intel_scu_watchdog_init(void)
ret = misc_register(&watchdog_device.miscdev); ret = misc_register(&watchdog_device.miscdev);
if (ret) { if (ret) {
pr_err("Watchdog timer: cannot register miscdev %d err =%d\n", pr_err("cannot register miscdev %d err =%d\n",
WATCHDOG_MINOR, ret); WATCHDOG_MINOR, ret);
goto misc_register_error; goto misc_register_error;
} }
...@@ -532,7 +529,7 @@ static int __init intel_scu_watchdog_init(void) ...@@ -532,7 +529,7 @@ static int __init intel_scu_watchdog_init(void)
IRQF_SHARED, "watchdog", IRQF_SHARED, "watchdog",
&watchdog_device.timer_load_count_addr); &watchdog_device.timer_load_count_addr);
if (ret) { if (ret) {
pr_err("Watchdog timer: error requesting irq %d\n", ret); pr_err("error requesting irq %d\n", ret);
goto request_irq_error; goto request_irq_error;
} }
/* Make sure timer is disabled before returning */ /* Make sure timer is disabled before returning */
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#ifndef __INTEL_SCU_WATCHDOG_H #ifndef __INTEL_SCU_WATCHDOG_H
#define __INTEL_SCU_WATCHDOG_H #define __INTEL_SCU_WATCHDOG_H
#define PFX "Intel_SCU: "
#define WDT_VER "0.3" #define WDT_VER "0.3"
/* minimum time between interrupts */ /* minimum time between interrupts */
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
* Dan Williams <dan.j.williams@intel.com> * Dan Williams <dan.j.williams@intel.com>
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/fs.h> #include <linux/fs.h>
...@@ -34,7 +36,7 @@ ...@@ -34,7 +36,7 @@
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <mach/hardware.h> #include <mach/hardware.h>
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
static unsigned long wdt_status; static unsigned long wdt_status;
static unsigned long boot_status; static unsigned long boot_status;
static DEFINE_SPINLOCK(wdt_lock); static DEFINE_SPINLOCK(wdt_lock);
...@@ -85,7 +87,7 @@ static int wdt_disable(void) ...@@ -85,7 +87,7 @@ static int wdt_disable(void)
write_wdtcr(IOP_WDTCR_DIS); write_wdtcr(IOP_WDTCR_DIS);
clear_bit(WDT_ENABLED, &wdt_status); clear_bit(WDT_ENABLED, &wdt_status);
spin_unlock(&wdt_lock); spin_unlock(&wdt_lock);
printk(KERN_INFO "WATCHDOG: Disabled\n"); pr_info("Disabled\n");
return 0; return 0;
} else } else
return 1; return 1;
...@@ -197,8 +199,8 @@ static int iop_wdt_release(struct inode *inode, struct file *file) ...@@ -197,8 +199,8 @@ static int iop_wdt_release(struct inode *inode, struct file *file)
*/ */
if (state != 0) { if (state != 0) {
wdt_enable(); wdt_enable();
printk(KERN_CRIT "WATCHDOG: Device closed unexpectedly - " pr_crit("Device closed unexpectedly - reset in %lu seconds\n",
"reset in %lu seconds\n", iop_watchdog_timeout()); iop_watchdog_timeout());
} }
clear_bit(WDT_IN_USE, &wdt_status); clear_bit(WDT_IN_USE, &wdt_status);
...@@ -238,8 +240,7 @@ static int __init iop_wdt_init(void) ...@@ -238,8 +240,7 @@ static int __init iop_wdt_init(void)
with an open */ with an open */
ret = misc_register(&iop_wdt_miscdev); ret = misc_register(&iop_wdt_miscdev);
if (ret == 0) if (ret == 0)
printk(KERN_INFO "iop watchdog timer: timeout %lu sec\n", pr_info("timeout %lu sec\n", iop_watchdog_timeout());
iop_watchdog_timeout());
return ret; return ret;
} }
...@@ -252,7 +253,7 @@ static void __exit iop_wdt_exit(void) ...@@ -252,7 +253,7 @@ static void __exit iop_wdt_exit(void)
module_init(iop_wdt_init); module_init(iop_wdt_init);
module_exit(iop_wdt_exit); module_exit(iop_wdt_exit);
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started"); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
MODULE_AUTHOR("Curt E Bruns <curt.e.bruns@intel.com>"); MODULE_AUTHOR("Curt E Bruns <curt.e.bruns@intel.com>");
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
* software is provided AS-IS with no warranties. * software is provided AS-IS with no warranties.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -33,6 +35,7 @@ ...@@ -33,6 +35,7 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#define DEBUG
#define NAME "it8712f_wdt" #define NAME "it8712f_wdt"
MODULE_AUTHOR("Jorge Boncompte - DTI2 <jorge@dti2.net>"); MODULE_AUTHOR("Jorge Boncompte - DTI2 <jorge@dti2.net>");
...@@ -45,8 +48,8 @@ static int margin = 60; /* in seconds */ ...@@ -45,8 +48,8 @@ static int margin = 60; /* in seconds */
module_param(margin, int, 0); module_param(margin, int, 0);
MODULE_PARM_DESC(margin, "Watchdog margin in seconds"); MODULE_PARM_DESC(margin, "Watchdog margin in seconds");
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Disable watchdog shutdown on close"); MODULE_PARM_DESC(nowayout, "Disable watchdog shutdown on close");
static unsigned long wdt_open; static unsigned long wdt_open;
...@@ -158,10 +161,10 @@ static void it8712f_wdt_update_margin(void) ...@@ -158,10 +161,10 @@ static void it8712f_wdt_update_margin(void)
*/ */
if (units <= max_units) { if (units <= max_units) {
config |= WDT_UNIT_SEC; /* else UNIT is MINUTES */ config |= WDT_UNIT_SEC; /* else UNIT is MINUTES */
printk(KERN_INFO NAME ": timer margin %d seconds\n", units); pr_info("timer margin %d seconds\n", units);
} else { } else {
units /= 60; units /= 60;
printk(KERN_INFO NAME ": timer margin %d minutes\n", units); pr_info("timer margin %d minutes\n", units);
} }
superio_outb(config, WDT_CONFIG); superio_outb(config, WDT_CONFIG);
...@@ -184,7 +187,7 @@ static int it8712f_wdt_enable(void) ...@@ -184,7 +187,7 @@ static int it8712f_wdt_enable(void)
if (ret) if (ret)
return ret; return ret;
printk(KERN_DEBUG NAME ": enabling watchdog timer\n"); pr_debug("enabling watchdog timer\n");
superio_select(LDN_GPIO); superio_select(LDN_GPIO);
superio_outb(wdt_control_reg, WDT_CONTROL); superio_outb(wdt_control_reg, WDT_CONTROL);
...@@ -204,7 +207,7 @@ static int it8712f_wdt_disable(void) ...@@ -204,7 +207,7 @@ static int it8712f_wdt_disable(void)
if (ret) if (ret)
return ret; return ret;
printk(KERN_DEBUG NAME ": disabling watchdog timer\n"); pr_debug("disabling watchdog timer\n");
superio_select(LDN_GPIO); superio_select(LDN_GPIO);
superio_outb(0, WDT_CONFIG); superio_outb(0, WDT_CONFIG);
...@@ -331,12 +334,10 @@ static int it8712f_wdt_open(struct inode *inode, struct file *file) ...@@ -331,12 +334,10 @@ static int it8712f_wdt_open(struct inode *inode, struct file *file)
static int it8712f_wdt_release(struct inode *inode, struct file *file) static int it8712f_wdt_release(struct inode *inode, struct file *file)
{ {
if (expect_close != 42) { if (expect_close != 42) {
printk(KERN_WARNING NAME pr_warn("watchdog device closed unexpectedly, will not disable the watchdog timer\n");
": watchdog device closed unexpectedly, will not"
" disable the watchdog timer\n");
} else if (!nowayout) { } else if (!nowayout) {
if (it8712f_wdt_disable()) if (it8712f_wdt_disable())
printk(KERN_WARNING NAME "Watchdog disable failed\n"); pr_warn("Watchdog disable failed\n");
} }
expect_close = 0; expect_close = 0;
clear_bit(0, &wdt_open); clear_bit(0, &wdt_open);
...@@ -374,13 +375,13 @@ static int __init it8712f_wdt_find(unsigned short *address) ...@@ -374,13 +375,13 @@ static int __init it8712f_wdt_find(unsigned short *address)
superio_select(LDN_GAME); superio_select(LDN_GAME);
superio_outb(1, ACT_REG); superio_outb(1, ACT_REG);
if (!(superio_inb(ACT_REG) & 0x01)) { if (!(superio_inb(ACT_REG) & 0x01)) {
printk(KERN_ERR NAME ": Device not activated, skipping\n"); pr_err("Device not activated, skipping\n");
goto exit; goto exit;
} }
*address = superio_inw(BASE_REG); *address = superio_inw(BASE_REG);
if (*address == 0) { if (*address == 0) {
printk(KERN_ERR NAME ": Base address not set, skipping\n"); pr_err("Base address not set, skipping\n");
goto exit; goto exit;
} }
...@@ -394,8 +395,7 @@ static int __init it8712f_wdt_find(unsigned short *address) ...@@ -394,8 +395,7 @@ static int __init it8712f_wdt_find(unsigned short *address)
if (margin > (max_units * 60)) if (margin > (max_units * 60))
margin = (max_units * 60); margin = (max_units * 60);
printk(KERN_INFO NAME ": Found IT%04xF chip revision %d - " pr_info("Found IT%04xF chip revision %d - using DogFood address 0x%x\n",
"using DogFood address 0x%x\n",
chip_type, revision, *address); chip_type, revision, *address);
exit: exit:
...@@ -411,27 +411,26 @@ static int __init it8712f_wdt_init(void) ...@@ -411,27 +411,26 @@ static int __init it8712f_wdt_init(void)
return -ENODEV; return -ENODEV;
if (!request_region(address, 1, "IT8712F Watchdog")) { if (!request_region(address, 1, "IT8712F Watchdog")) {
printk(KERN_WARNING NAME ": watchdog I/O region busy\n"); pr_warn("watchdog I/O region busy\n");
return -EBUSY; return -EBUSY;
} }
err = it8712f_wdt_disable(); err = it8712f_wdt_disable();
if (err) { if (err) {
printk(KERN_ERR NAME ": unable to disable watchdog timer.\n"); pr_err("unable to disable watchdog timer\n");
goto out; goto out;
} }
err = register_reboot_notifier(&it8712f_wdt_notifier); err = register_reboot_notifier(&it8712f_wdt_notifier);
if (err) { if (err) {
printk(KERN_ERR NAME ": unable to register reboot notifier\n"); pr_err("unable to register reboot notifier\n");
goto out; goto out;
} }
err = misc_register(&it8712f_wdt_miscdev); err = misc_register(&it8712f_wdt_miscdev);
if (err) { if (err) {
printk(KERN_ERR NAME pr_err("cannot register miscdev on minor=%d (err=%d)\n",
": cannot register miscdev on minor=%d (err=%d)\n", WATCHDOG_MINOR, err);
WATCHDOG_MINOR, err);
goto reboot_out; goto reboot_out;
} }
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -47,7 +49,6 @@ ...@@ -47,7 +49,6 @@
#define WATCHDOG_VERSION "1.14" #define WATCHDOG_VERSION "1.14"
#define WATCHDOG_NAME "IT87 WDT" #define WATCHDOG_NAME "IT87 WDT"
#define PFX WATCHDOG_NAME ": "
#define DRIVER_VERSION WATCHDOG_NAME " driver, v" WATCHDOG_VERSION "\n" #define DRIVER_VERSION WATCHDOG_NAME " driver, v" WATCHDOG_VERSION "\n"
#define WD_MAGIC 'V' #define WD_MAGIC 'V'
...@@ -142,7 +143,7 @@ static int nogameport = DEFAULT_NOGAMEPORT; ...@@ -142,7 +143,7 @@ static int nogameport = DEFAULT_NOGAMEPORT;
static int exclusive = DEFAULT_EXCLUSIVE; static int exclusive = DEFAULT_EXCLUSIVE;
static int timeout = DEFAULT_TIMEOUT; static int timeout = DEFAULT_TIMEOUT;
static int testmode = DEFAULT_TESTMODE; static int testmode = DEFAULT_TESTMODE;
static int nowayout = DEFAULT_NOWAYOUT; static bool nowayout = DEFAULT_NOWAYOUT;
module_param(nogameport, int, 0); module_param(nogameport, int, 0);
MODULE_PARM_DESC(nogameport, "Forbid the activation of game port, default=" MODULE_PARM_DESC(nogameport, "Forbid the activation of game port, default="
...@@ -156,7 +157,7 @@ MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds, default=" ...@@ -156,7 +157,7 @@ MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds, default="
module_param(testmode, int, 0); module_param(testmode, int, 0);
MODULE_PARM_DESC(testmode, "Watchdog test mode (1 = no reboot), default=" MODULE_PARM_DESC(testmode, "Watchdog test mode (1 = no reboot), default="
__MODULE_STRING(DEFAULT_TESTMODE)); __MODULE_STRING(DEFAULT_TESTMODE));
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started, default=" MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started, default="
__MODULE_STRING(WATCHDOG_NOWAYOUT)); __MODULE_STRING(WATCHDOG_NOWAYOUT));
...@@ -428,8 +429,7 @@ static int wdt_release(struct inode *inode, struct file *file) ...@@ -428,8 +429,7 @@ static int wdt_release(struct inode *inode, struct file *file)
clear_bit(WDTS_TIMER_RUN, &wdt_status); clear_bit(WDTS_TIMER_RUN, &wdt_status);
} else { } else {
wdt_keepalive(); wdt_keepalive();
printk(KERN_CRIT PFX pr_crit("unexpected close, not stopping watchdog!\n");
"unexpected close, not stopping watchdog!\n");
} }
} }
clear_bit(WDTS_DEV_OPEN, &wdt_status); clear_bit(WDTS_DEV_OPEN, &wdt_status);
...@@ -621,16 +621,14 @@ static int __init it87_wdt_init(void) ...@@ -621,16 +621,14 @@ static int __init it87_wdt_init(void)
try_gameport = 0; try_gameport = 0;
break; break;
case IT8705_ID: case IT8705_ID:
printk(KERN_ERR PFX pr_err("Unsupported Chip found, Chip %04x Revision %02x\n",
"Unsupported Chip found, Chip %04x Revision %02x\n",
chip_type, chip_rev); chip_type, chip_rev);
return -ENODEV; return -ENODEV;
case NO_DEV_ID: case NO_DEV_ID:
printk(KERN_ERR PFX "no device\n"); pr_err("no device\n");
return -ENODEV; return -ENODEV;
default: default:
printk(KERN_ERR PFX pr_err("Unknown Chip found, Chip %04x Revision %04x\n",
"Unknown Chip found, Chip %04x Revision %04x\n",
chip_type, chip_rev); chip_type, chip_rev);
return -ENODEV; return -ENODEV;
} }
...@@ -663,13 +661,11 @@ static int __init it87_wdt_init(void) ...@@ -663,13 +661,11 @@ static int __init it87_wdt_init(void)
if (!test_bit(WDTS_USE_GP, &wdt_status)) { if (!test_bit(WDTS_USE_GP, &wdt_status)) {
if (!request_region(CIR_BASE, 8, WATCHDOG_NAME)) { if (!request_region(CIR_BASE, 8, WATCHDOG_NAME)) {
if (gp_rreq_fail) if (gp_rreq_fail)
printk(KERN_ERR PFX pr_err("I/O Address 0x%04x and 0x%04x already in use\n",
"I/O Address 0x%04x and 0x%04x" base, CIR_BASE);
" already in use\n", base, CIR_BASE);
else else
printk(KERN_ERR PFX pr_err("I/O Address 0x%04x already in use\n",
"I/O Address 0x%04x already in use\n", CIR_BASE);
CIR_BASE);
rc = -EIO; rc = -EIO;
goto err_out; goto err_out;
} }
...@@ -688,9 +684,8 @@ static int __init it87_wdt_init(void) ...@@ -688,9 +684,8 @@ static int __init it87_wdt_init(void)
if (timeout < 1 || timeout > max_units * 60) { if (timeout < 1 || timeout > max_units * 60) {
timeout = DEFAULT_TIMEOUT; timeout = DEFAULT_TIMEOUT;
printk(KERN_WARNING PFX pr_warn("Timeout value out of range, use default %d sec\n",
"Timeout value out of range, use default %d sec\n", DEFAULT_TIMEOUT);
DEFAULT_TIMEOUT);
} }
if (timeout > max_units) if (timeout > max_units)
...@@ -698,16 +693,14 @@ static int __init it87_wdt_init(void) ...@@ -698,16 +693,14 @@ static int __init it87_wdt_init(void)
rc = register_reboot_notifier(&wdt_notifier); rc = register_reboot_notifier(&wdt_notifier);
if (rc) { if (rc) {
printk(KERN_ERR PFX pr_err("Cannot register reboot notifier (err=%d)\n", rc);
"Cannot register reboot notifier (err=%d)\n", rc);
goto err_out_region; goto err_out_region;
} }
rc = misc_register(&wdt_miscdev); rc = misc_register(&wdt_miscdev);
if (rc) { if (rc) {
printk(KERN_ERR PFX pr_err("Cannot register miscdev on minor=%d (err=%d)\n",
"Cannot register miscdev on minor=%d (err=%d)\n", wdt_miscdev.minor, rc);
wdt_miscdev.minor, rc);
goto err_out_reboot; goto err_out_reboot;
} }
...@@ -722,9 +715,8 @@ static int __init it87_wdt_init(void) ...@@ -722,9 +715,8 @@ static int __init it87_wdt_init(void)
outb(0x09, CIR_IER(base)); outb(0x09, CIR_IER(base));
} }
printk(KERN_INFO PFX "Chip IT%04x revision %d initialized. " pr_info("Chip IT%04x revision %d initialized. timeout=%d sec (nowayout=%d testmode=%d exclusive=%d nogameport=%d)\n",
"timeout=%d sec (nowayout=%d testmode=%d exclusive=%d " chip_type, chip_rev, timeout,
"nogameport=%d)\n", chip_type, chip_rev, timeout,
nowayout, testmode, exclusive, nogameport); nowayout, testmode, exclusive, nogameport);
superio_exit(); superio_exit();
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
* warranty of any kind, whether express or implied. * warranty of any kind, whether express or implied.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -29,7 +31,7 @@ ...@@ -29,7 +31,7 @@
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <mach/hardware.h> #include <mach/hardware.h>
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
static unsigned int heartbeat = 60; /* (secs) Default is 1 minute */ static unsigned int heartbeat = 60; /* (secs) Default is 1 minute */
static unsigned long wdt_status; static unsigned long wdt_status;
static DEFINE_SPINLOCK(wdt_lock); static DEFINE_SPINLOCK(wdt_lock);
...@@ -158,8 +160,7 @@ static int ixp2000_wdt_release(struct inode *inode, struct file *file) ...@@ -158,8 +160,7 @@ static int ixp2000_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(); wdt_disable();
else else
printk(KERN_CRIT "WATCHDOG: Device closed unexpectedly - " pr_crit("Device closed unexpectedly - timer will not stop\n");
"timer will not stop\n");
clear_bit(WDT_IN_USE, &wdt_status); clear_bit(WDT_IN_USE, &wdt_status);
clear_bit(WDT_OK_TO_CLOSE, &wdt_status); clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
...@@ -185,7 +186,7 @@ static struct miscdevice ixp2000_wdt_miscdev = { ...@@ -185,7 +186,7 @@ static struct miscdevice ixp2000_wdt_miscdev = {
static int __init ixp2000_wdt_init(void) static int __init ixp2000_wdt_init(void)
{ {
if ((*IXP2000_PRODUCT_ID & 0x001ffef0) == 0x00000000) { if ((*IXP2000_PRODUCT_ID & 0x001ffef0) == 0x00000000) {
printk(KERN_INFO "Unable to use IXP2000 watchdog due to IXP2800 erratum #25.\n"); pr_info("Unable to use IXP2000 watchdog due to IXP2800 erratum #25\n");
return -EIO; return -EIO;
} }
wdt_tick_rate = (*IXP2000_T1_CLD * HZ) / 256; wdt_tick_rate = (*IXP2000_T1_CLD * HZ) / 256;
...@@ -206,7 +207,7 @@ MODULE_DESCRIPTION("IXP2000 Network Processor Watchdog"); ...@@ -206,7 +207,7 @@ MODULE_DESCRIPTION("IXP2000 Network Processor Watchdog");
module_param(heartbeat, int, 0); module_param(heartbeat, int, 0);
MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds (default 60s)"); MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds (default 60s)");
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started"); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
* warranty of any kind, whether express or implied. * warranty of any kind, whether express or implied.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -25,7 +27,7 @@ ...@@ -25,7 +27,7 @@
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <mach/hardware.h> #include <mach/hardware.h>
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
static int heartbeat = 60; /* (secs) Default is 1 minute */ static int heartbeat = 60; /* (secs) Default is 1 minute */
static unsigned long wdt_status; static unsigned long wdt_status;
static unsigned long boot_status; static unsigned long boot_status;
...@@ -147,8 +149,7 @@ static int ixp4xx_wdt_release(struct inode *inode, struct file *file) ...@@ -147,8 +149,7 @@ static int ixp4xx_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(); wdt_disable();
else else
printk(KERN_CRIT "WATCHDOG: Device closed unexpectedly - " pr_crit("Device closed unexpectedly - timer will not stop\n");
"timer will not stop\n");
clear_bit(WDT_IN_USE, &wdt_status); clear_bit(WDT_IN_USE, &wdt_status);
clear_bit(WDT_OK_TO_CLOSE, &wdt_status); clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
...@@ -176,8 +177,7 @@ static int __init ixp4xx_wdt_init(void) ...@@ -176,8 +177,7 @@ static int __init ixp4xx_wdt_init(void)
int ret; int ret;
if (!(read_cpuid_id() & 0xf) && !cpu_is_ixp46x()) { if (!(read_cpuid_id() & 0xf) && !cpu_is_ixp46x()) {
printk(KERN_ERR "IXP4XXX Watchdog: Rev. A0 IXP42x CPU detected" pr_err("Rev. A0 IXP42x CPU detected - watchdog disabled\n");
" - watchdog disabled\n");
return -ENODEV; return -ENODEV;
} }
...@@ -185,8 +185,7 @@ static int __init ixp4xx_wdt_init(void) ...@@ -185,8 +185,7 @@ static int __init ixp4xx_wdt_init(void)
WDIOF_CARDRESET : 0; WDIOF_CARDRESET : 0;
ret = misc_register(&ixp4xx_wdt_miscdev); ret = misc_register(&ixp4xx_wdt_miscdev);
if (ret == 0) if (ret == 0)
printk(KERN_INFO "IXP4xx Watchdog Timer: heartbeat %d sec\n", pr_info("timer heartbeat %d sec\n", heartbeat);
heartbeat);
return ret; return ret;
} }
...@@ -205,7 +204,7 @@ MODULE_DESCRIPTION("IXP4xx Network Processor Watchdog"); ...@@ -205,7 +204,7 @@ MODULE_DESCRIPTION("IXP4xx Network Processor Watchdog");
module_param(heartbeat, int, 0); module_param(heartbeat, int, 0);
MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds (default 60s)"); MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds (default 60s)");
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started"); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
...@@ -17,18 +17,15 @@ ...@@ -17,18 +17,15 @@
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
#include <linux/watchdog.h> #include <linux/watchdog.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/bitops.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/spinlock.h>
#include <linux/uaccess.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/err.h>
#include <asm/mach-jz4740/timer.h> #include <asm/mach-jz4740/timer.h>
...@@ -41,9 +38,6 @@ ...@@ -41,9 +38,6 @@
#define JZ_WDT_CLOCK_RTC 0x2 #define JZ_WDT_CLOCK_RTC 0x2
#define JZ_WDT_CLOCK_EXT 0x4 #define JZ_WDT_CLOCK_EXT 0x4
#define WDT_IN_USE 0
#define WDT_OK_TO_CLOSE 1
#define JZ_WDT_CLOCK_DIV_SHIFT 3 #define JZ_WDT_CLOCK_DIV_SHIFT 3
#define JZ_WDT_CLOCK_DIV_1 (0 << JZ_WDT_CLOCK_DIV_SHIFT) #define JZ_WDT_CLOCK_DIV_1 (0 << JZ_WDT_CLOCK_DIV_SHIFT)
...@@ -56,32 +50,44 @@ ...@@ -56,32 +50,44 @@
#define DEFAULT_HEARTBEAT 5 #define DEFAULT_HEARTBEAT 5
#define MAX_HEARTBEAT 2048 #define MAX_HEARTBEAT 2048
static struct { static bool nowayout = WATCHDOG_NOWAYOUT;
void __iomem *base; module_param(nowayout, bool, 0);
struct resource *mem; MODULE_PARM_DESC(nowayout,
struct clk *rtc_clk; "Watchdog cannot be stopped once started (default="
unsigned long status; __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
} jz4740_wdt;
static int heartbeat = DEFAULT_HEARTBEAT; static unsigned int heartbeat = DEFAULT_HEARTBEAT;
module_param(heartbeat, uint, 0);
MODULE_PARM_DESC(heartbeat,
"Watchdog heartbeat period in seconds from 1 to "
__MODULE_STRING(MAX_HEARTBEAT) ", default "
__MODULE_STRING(DEFAULT_HEARTBEAT));
struct jz4740_wdt_drvdata {
struct watchdog_device wdt;
void __iomem *base;
struct clk *rtc_clk;
};
static void jz4740_wdt_service(void) static int jz4740_wdt_ping(struct watchdog_device *wdt_dev)
{ {
writew(0x0, jz4740_wdt.base + JZ_REG_WDT_TIMER_COUNTER); struct jz4740_wdt_drvdata *drvdata = watchdog_get_drvdata(wdt_dev);
writew(0x0, drvdata->base + JZ_REG_WDT_TIMER_COUNTER);
return 0;
} }
static void jz4740_wdt_set_heartbeat(int new_heartbeat) static int jz4740_wdt_set_timeout(struct watchdog_device *wdt_dev,
unsigned int new_timeout)
{ {
struct jz4740_wdt_drvdata *drvdata = watchdog_get_drvdata(wdt_dev);
unsigned int rtc_clk_rate; unsigned int rtc_clk_rate;
unsigned int timeout_value; unsigned int timeout_value;
unsigned short clock_div = JZ_WDT_CLOCK_DIV_1; unsigned short clock_div = JZ_WDT_CLOCK_DIV_1;
heartbeat = new_heartbeat; rtc_clk_rate = clk_get_rate(drvdata->rtc_clk);
rtc_clk_rate = clk_get_rate(jz4740_wdt.rtc_clk);
timeout_value = rtc_clk_rate * heartbeat; timeout_value = rtc_clk_rate * new_timeout;
while (timeout_value > 0xffff) { while (timeout_value > 0xffff) {
if (clock_div == JZ_WDT_CLOCK_DIV_1024) { if (clock_div == JZ_WDT_CLOCK_DIV_1024) {
/* Requested timeout too high; /* Requested timeout too high;
...@@ -93,199 +99,115 @@ static void jz4740_wdt_set_heartbeat(int new_heartbeat) ...@@ -93,199 +99,115 @@ static void jz4740_wdt_set_heartbeat(int new_heartbeat)
clock_div += (1 << JZ_WDT_CLOCK_DIV_SHIFT); clock_div += (1 << JZ_WDT_CLOCK_DIV_SHIFT);
} }
writeb(0x0, jz4740_wdt.base + JZ_REG_WDT_COUNTER_ENABLE); writeb(0x0, drvdata->base + JZ_REG_WDT_COUNTER_ENABLE);
writew(clock_div, jz4740_wdt.base + JZ_REG_WDT_TIMER_CONTROL); writew(clock_div, drvdata->base + JZ_REG_WDT_TIMER_CONTROL);
writew((u16)timeout_value, jz4740_wdt.base + JZ_REG_WDT_TIMER_DATA); writew((u16)timeout_value, drvdata->base + JZ_REG_WDT_TIMER_DATA);
writew(0x0, jz4740_wdt.base + JZ_REG_WDT_TIMER_COUNTER); writew(0x0, drvdata->base + JZ_REG_WDT_TIMER_COUNTER);
writew(clock_div | JZ_WDT_CLOCK_RTC, writew(clock_div | JZ_WDT_CLOCK_RTC,
jz4740_wdt.base + JZ_REG_WDT_TIMER_CONTROL); drvdata->base + JZ_REG_WDT_TIMER_CONTROL);
writeb(0x1, jz4740_wdt.base + JZ_REG_WDT_COUNTER_ENABLE); writeb(0x1, drvdata->base + JZ_REG_WDT_COUNTER_ENABLE);
}
static void jz4740_wdt_enable(void) wdt_dev->timeout = new_timeout;
{ return 0;
jz4740_timer_enable_watchdog();
jz4740_wdt_set_heartbeat(heartbeat);
}
static void jz4740_wdt_disable(void)
{
jz4740_timer_disable_watchdog();
writeb(0x0, jz4740_wdt.base + JZ_REG_WDT_COUNTER_ENABLE);
} }
static int jz4740_wdt_open(struct inode *inode, struct file *file) static int jz4740_wdt_start(struct watchdog_device *wdt_dev)
{ {
if (test_and_set_bit(WDT_IN_USE, &jz4740_wdt.status)) jz4740_timer_enable_watchdog();
return -EBUSY; jz4740_wdt_set_timeout(wdt_dev, wdt_dev->timeout);
jz4740_wdt_enable();
return nonseekable_open(inode, file); return 0;
} }
static ssize_t jz4740_wdt_write(struct file *file, const char *data, static int jz4740_wdt_stop(struct watchdog_device *wdt_dev)
size_t len, loff_t *ppos)
{ {
if (len) { struct jz4740_wdt_drvdata *drvdata = watchdog_get_drvdata(wdt_dev);
size_t i;
clear_bit(WDT_OK_TO_CLOSE, &jz4740_wdt.status);
for (i = 0; i != len; i++) {
char c;
if (get_user(c, data + i)) jz4740_timer_disable_watchdog();
return -EFAULT; writeb(0x0, drvdata->base + JZ_REG_WDT_COUNTER_ENABLE);
if (c == 'V')
set_bit(WDT_OK_TO_CLOSE, &jz4740_wdt.status);
}
jz4740_wdt_service();
}
return len; return 0;
} }
static const struct watchdog_info ident = { static const struct watchdog_info jz4740_wdt_info = {
.options = WDIOF_KEEPALIVEPING, .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
.identity = "jz4740 Watchdog", .identity = "jz4740 Watchdog",
}; };
static long jz4740_wdt_ioctl(struct file *file, static const struct watchdog_ops jz4740_wdt_ops = {
unsigned int cmd, unsigned long arg)
{
int ret = -ENOTTY;
int heartbeat_seconds;
switch (cmd) {
case WDIOC_GETSUPPORT:
ret = copy_to_user((struct watchdog_info *)arg, &ident,
sizeof(ident)) ? -EFAULT : 0;
break;
case WDIOC_GETSTATUS:
case WDIOC_GETBOOTSTATUS:
ret = put_user(0, (int *)arg);
break;
case WDIOC_KEEPALIVE:
jz4740_wdt_service();
return 0;
case WDIOC_SETTIMEOUT:
if (get_user(heartbeat_seconds, (int __user *)arg))
return -EFAULT;
jz4740_wdt_set_heartbeat(heartbeat_seconds);
return 0;
case WDIOC_GETTIMEOUT:
return put_user(heartbeat, (int *)arg);
default:
break;
}
return ret;
}
static int jz4740_wdt_release(struct inode *inode, struct file *file)
{
jz4740_wdt_service();
if (test_and_clear_bit(WDT_OK_TO_CLOSE, &jz4740_wdt.status))
jz4740_wdt_disable();
clear_bit(WDT_IN_USE, &jz4740_wdt.status);
return 0;
}
static const struct file_operations jz4740_wdt_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.llseek = no_llseek, .start = jz4740_wdt_start,
.write = jz4740_wdt_write, .stop = jz4740_wdt_stop,
.unlocked_ioctl = jz4740_wdt_ioctl, .ping = jz4740_wdt_ping,
.open = jz4740_wdt_open, .set_timeout = jz4740_wdt_set_timeout,
.release = jz4740_wdt_release,
};
static struct miscdevice jz4740_wdt_miscdev = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &jz4740_wdt_fops,
}; };
static int __devinit jz4740_wdt_probe(struct platform_device *pdev) static int __devinit jz4740_wdt_probe(struct platform_device *pdev)
{ {
int ret = 0, size; struct jz4740_wdt_drvdata *drvdata;
struct resource *res; struct watchdog_device *jz4740_wdt;
struct device *dev = &pdev->dev; struct resource *res;
int ret;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res == NULL) { drvdata = devm_kzalloc(&pdev->dev, sizeof(struct jz4740_wdt_drvdata),
dev_err(dev, "failed to get memory region resource\n"); GFP_KERNEL);
return -ENXIO; if (!drvdata) {
dev_err(&pdev->dev, "Unable to alloacate watchdog device\n");
return -ENOMEM;
} }
size = resource_size(res); if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT)
jz4740_wdt.mem = request_mem_region(res->start, size, pdev->name); heartbeat = DEFAULT_HEARTBEAT;
if (jz4740_wdt.mem == NULL) {
dev_err(dev, "failed to get memory region\n");
return -EBUSY;
}
jz4740_wdt.base = ioremap_nocache(res->start, size); jz4740_wdt = &drvdata->wdt;
if (jz4740_wdt.base == NULL) { jz4740_wdt->info = &jz4740_wdt_info;
dev_err(dev, "failed to map memory region\n"); jz4740_wdt->ops = &jz4740_wdt_ops;
jz4740_wdt->timeout = heartbeat;
jz4740_wdt->min_timeout = 1;
jz4740_wdt->max_timeout = MAX_HEARTBEAT;
watchdog_set_nowayout(jz4740_wdt, nowayout);
watchdog_set_drvdata(jz4740_wdt, drvdata);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
drvdata->base = devm_request_and_ioremap(&pdev->dev, res);
if (drvdata->base == NULL) {
ret = -EBUSY; ret = -EBUSY;
goto err_release_region; goto err_out;
} }
jz4740_wdt.rtc_clk = clk_get(NULL, "rtc"); drvdata->rtc_clk = clk_get(NULL, "rtc");
if (IS_ERR(jz4740_wdt.rtc_clk)) { if (IS_ERR(drvdata->rtc_clk)) {
dev_err(dev, "cannot find RTC clock\n"); dev_err(&pdev->dev, "cannot find RTC clock\n");
ret = PTR_ERR(jz4740_wdt.rtc_clk); ret = PTR_ERR(drvdata->rtc_clk);
goto err_iounmap; goto err_out;
} }
ret = misc_register(&jz4740_wdt_miscdev); ret = watchdog_register_device(&drvdata->wdt);
if (ret < 0) { if (ret < 0)
dev_err(dev, "cannot register misc device\n");
goto err_disable_clk; goto err_disable_clk;
}
platform_set_drvdata(pdev, drvdata);
return 0; return 0;
err_disable_clk: err_disable_clk:
clk_put(jz4740_wdt.rtc_clk); clk_put(drvdata->rtc_clk);
err_iounmap: err_out:
iounmap(jz4740_wdt.base);
err_release_region:
release_mem_region(jz4740_wdt.mem->start,
resource_size(jz4740_wdt.mem));
return ret; return ret;
} }
static int __devexit jz4740_wdt_remove(struct platform_device *pdev) static int __devexit jz4740_wdt_remove(struct platform_device *pdev)
{ {
jz4740_wdt_disable(); struct jz4740_wdt_drvdata *drvdata = platform_get_drvdata(pdev);
misc_deregister(&jz4740_wdt_miscdev);
clk_put(jz4740_wdt.rtc_clk);
iounmap(jz4740_wdt.base); jz4740_wdt_stop(&drvdata->wdt);
jz4740_wdt.base = NULL; watchdog_unregister_device(&drvdata->wdt);
clk_put(drvdata->rtc_clk);
release_mem_region(jz4740_wdt.mem->start,
resource_size(jz4740_wdt.mem));
jz4740_wdt.mem = NULL;
return 0; return 0;
} }
static struct platform_driver jz4740_wdt_driver = { static struct platform_driver jz4740_wdt_driver = {
.probe = jz4740_wdt_probe, .probe = jz4740_wdt_probe,
.remove = __devexit_p(jz4740_wdt_remove), .remove = __devexit_p(jz4740_wdt_remove),
...@@ -299,13 +221,6 @@ module_platform_driver(jz4740_wdt_driver); ...@@ -299,13 +221,6 @@ module_platform_driver(jz4740_wdt_driver);
MODULE_AUTHOR("Paul Cercueil <paul@crapouillou.net>"); MODULE_AUTHOR("Paul Cercueil <paul@crapouillou.net>");
MODULE_DESCRIPTION("jz4740 Watchdog Driver"); MODULE_DESCRIPTION("jz4740 Watchdog Driver");
module_param(heartbeat, int, 0);
MODULE_PARM_DESC(heartbeat,
"Watchdog heartbeat period in seconds from 1 to "
__MODULE_STRING(MAX_HEARTBEAT) ", default "
__MODULE_STRING(DEFAULT_HEARTBEAT));
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
MODULE_ALIAS("platform:jz4740-wdt"); MODULE_ALIAS("platform:jz4740-wdt");
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/fs.h> #include <linux/fs.h>
...@@ -28,14 +30,14 @@ ...@@ -28,14 +30,14 @@
#define WDT_MAX_TIME 171 /* seconds */ #define WDT_MAX_TIME 171 /* seconds */
static int wdt_time = WDT_DEFAULT_TIME; static int wdt_time = WDT_DEFAULT_TIME;
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(wdt_time, int, 0); module_param(wdt_time, int, 0);
MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default=" MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default="
__MODULE_STRING(WDT_DEFAULT_TIME) ")"); __MODULE_STRING(WDT_DEFAULT_TIME) ")");
#ifdef CONFIG_WATCHDOG_NOWAYOUT #ifdef CONFIG_WATCHDOG_NOWAYOUT
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
#endif #endif
...@@ -233,8 +235,8 @@ static int __devinit ks8695wdt_probe(struct platform_device *pdev) ...@@ -233,8 +235,8 @@ static int __devinit ks8695wdt_probe(struct platform_device *pdev)
if (res) if (res)
return res; return res;
printk(KERN_INFO "KS8695 Watchdog Timer enabled (%d seconds%s)\n", pr_info("KS8695 Watchdog Timer enabled (%d seconds%s)\n",
wdt_time, nowayout ? ", nowayout" : ""); wdt_time, nowayout ? ", nowayout" : "");
return 0; return 0;
} }
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
* Based on EP93xx wdt driver * Based on EP93xx wdt driver
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
...@@ -38,7 +40,7 @@ ...@@ -38,7 +40,7 @@
#define LTQ_WDT_DIVIDER 0x40000 #define LTQ_WDT_DIVIDER 0x40000
#define LTQ_MAX_TIMEOUT ((1 << 16) - 1) /* the reload field is 16 bit */ #define LTQ_MAX_TIMEOUT ((1 << 16) - 1) /* the reload field is 16 bit */
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
static void __iomem *ltq_wdt_membase; static void __iomem *ltq_wdt_membase;
static unsigned long ltq_io_region_clk_rate; static unsigned long ltq_io_region_clk_rate;
...@@ -160,7 +162,7 @@ ltq_wdt_release(struct inode *inode, struct file *file) ...@@ -160,7 +162,7 @@ ltq_wdt_release(struct inode *inode, struct file *file)
if (ltq_wdt_ok_to_close) if (ltq_wdt_ok_to_close)
ltq_wdt_disable(); ltq_wdt_disable();
else else
pr_err("ltq_wdt: watchdog closed without warning\n"); pr_err("watchdog closed without warning\n");
ltq_wdt_ok_to_close = 0; ltq_wdt_ok_to_close = 0;
clear_bit(0, &ltq_wdt_in_use); clear_bit(0, &ltq_wdt_in_use);
...@@ -249,7 +251,7 @@ exit_ltq_wdt(void) ...@@ -249,7 +251,7 @@ exit_ltq_wdt(void)
module_init(init_ltq_wdt); module_init(init_ltq_wdt);
module_exit(exit_ltq_wdt); module_exit(exit_ltq_wdt);
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started"); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
MODULE_AUTHOR("John Crispin <blogic@openwrt.org>"); MODULE_AUTHOR("John Crispin <blogic@openwrt.org>");
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
* warranty of any kind, whether express or implied. * warranty of any kind, whether express or implied.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -32,7 +34,7 @@ ...@@ -32,7 +34,7 @@
#include <asm/m54xxsim.h> #include <asm/m54xxsim.h>
#include <asm/m54xxgpt.h> #include <asm/m54xxgpt.h>
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
static unsigned int heartbeat = 30; /* (secs) Default is 0.5 minute */ static unsigned int heartbeat = 30; /* (secs) Default is 0.5 minute */
static unsigned long wdt_status; static unsigned long wdt_status;
...@@ -166,8 +168,7 @@ static int m54xx_wdt_release(struct inode *inode, struct file *file) ...@@ -166,8 +168,7 @@ static int m54xx_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(); wdt_disable();
else { else {
printk(KERN_CRIT "WATCHDOG: Device closed unexpectedly - " pr_crit("Device closed unexpectedly - timer will not stop\n");
"timer will not stop\n");
wdt_keepalive(); wdt_keepalive();
} }
clear_bit(WDT_IN_USE, &wdt_status); clear_bit(WDT_IN_USE, &wdt_status);
...@@ -196,11 +197,10 @@ static int __init m54xx_wdt_init(void) ...@@ -196,11 +197,10 @@ static int __init m54xx_wdt_init(void)
{ {
if (!request_mem_region(MCF_MBAR + MCF_GPT_GCIR0, 4, if (!request_mem_region(MCF_MBAR + MCF_GPT_GCIR0, 4,
"Coldfire M54xx Watchdog")) { "Coldfire M54xx Watchdog")) {
printk(KERN_WARNING pr_warn("I/O region busy\n");
"Coldfire M54xx Watchdog : I/O region busy\n");
return -EBUSY; return -EBUSY;
} }
printk(KERN_INFO "ColdFire watchdog driver is loaded.\n"); pr_info("driver is loaded\n");
return misc_register(&m54xx_wdt_miscdev); return misc_register(&m54xx_wdt_miscdev);
} }
...@@ -220,7 +220,7 @@ MODULE_DESCRIPTION("Coldfire M54xx Watchdog"); ...@@ -220,7 +220,7 @@ MODULE_DESCRIPTION("Coldfire M54xx Watchdog");
module_param(heartbeat, int, 0); module_param(heartbeat, int, 0);
MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds (default 30s)"); MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds (default 30s)");
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started"); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
* Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT * Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -93,8 +95,8 @@ MODULE_DESCRIPTION("MachZ ZF-Logic Watchdog driver"); ...@@ -93,8 +95,8 @@ MODULE_DESCRIPTION("MachZ ZF-Logic Watchdog driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default=" "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -141,10 +143,10 @@ static unsigned long next_heartbeat; ...@@ -141,10 +143,10 @@ static unsigned long next_heartbeat;
#define ZF_CTIMEOUT 0xffff #define ZF_CTIMEOUT 0xffff
#ifndef ZF_DEBUG #ifndef ZF_DEBUG
# define dprintk(format, args...) #define dprintk(format, args...)
#else #else
# define dprintk(format, args...) printk(KERN_DEBUG PFX \ #define dprintk(format, args...) \
":%s:%d: " format, __func__, __LINE__ , ## args) pr_debug(":%s:%d: " format, __func__, __LINE__ , ## args)
#endif #endif
...@@ -203,7 +205,7 @@ static void zf_timer_off(void) ...@@ -203,7 +205,7 @@ static void zf_timer_off(void)
zf_set_control(ctrl_reg); zf_set_control(ctrl_reg);
spin_unlock_irqrestore(&zf_port_lock, flags); spin_unlock_irqrestore(&zf_port_lock, flags);
printk(KERN_INFO PFX ": Watchdog timer is now disabled\n"); pr_info("Watchdog timer is now disabled\n");
} }
...@@ -233,7 +235,7 @@ static void zf_timer_on(void) ...@@ -233,7 +235,7 @@ static void zf_timer_on(void)
zf_set_control(ctrl_reg); zf_set_control(ctrl_reg);
spin_unlock_irqrestore(&zf_port_lock, flags); spin_unlock_irqrestore(&zf_port_lock, flags);
printk(KERN_INFO PFX ": Watchdog timer is now enabled\n"); pr_info("Watchdog timer is now enabled\n");
} }
...@@ -263,7 +265,7 @@ static void zf_ping(unsigned long data) ...@@ -263,7 +265,7 @@ static void zf_ping(unsigned long data)
mod_timer(&zf_timer, jiffies + ZF_HW_TIMEO); mod_timer(&zf_timer, jiffies + ZF_HW_TIMEO);
} else } else
printk(KERN_CRIT PFX ": I will reset your machine\n"); pr_crit("I will reset your machine\n");
} }
static ssize_t zf_write(struct file *file, const char __user *buf, size_t count, static ssize_t zf_write(struct file *file, const char __user *buf, size_t count,
...@@ -342,8 +344,7 @@ static int zf_close(struct inode *inode, struct file *file) ...@@ -342,8 +344,7 @@ static int zf_close(struct inode *inode, struct file *file)
zf_timer_off(); zf_timer_off();
else { else {
del_timer(&zf_timer); del_timer(&zf_timer);
printk(KERN_ERR PFX ": device file closed unexpectedly. " pr_err("device file closed unexpectedly. Will not stop the WDT!\n");
"Will not stop the WDT!\n");
} }
clear_bit(0, &zf_is_open); clear_bit(0, &zf_is_open);
zf_expect_close = 0; zf_expect_close = 0;
...@@ -390,19 +391,18 @@ static void __init zf_show_action(int act) ...@@ -390,19 +391,18 @@ static void __init zf_show_action(int act)
{ {
static const char * const str[] = { "RESET", "SMI", "NMI", "SCI" }; static const char * const str[] = { "RESET", "SMI", "NMI", "SCI" };
printk(KERN_INFO PFX ": Watchdog using action = %s\n", str[act]); pr_info("Watchdog using action = %s\n", str[act]);
} }
static int __init zf_init(void) static int __init zf_init(void)
{ {
int ret; int ret;
printk(KERN_INFO PFX pr_info("MachZ ZF-Logic Watchdog driver initializing\n");
": MachZ ZF-Logic Watchdog driver initializing.\n");
ret = zf_get_ZFL_version(); ret = zf_get_ZFL_version();
if (!ret || ret == 0xffff) { if (!ret || ret == 0xffff) {
printk(KERN_WARNING PFX ": no ZF-Logic found\n"); pr_warn("no ZF-Logic found\n");
return -ENODEV; return -ENODEV;
} }
...@@ -414,23 +414,20 @@ static int __init zf_init(void) ...@@ -414,23 +414,20 @@ static int __init zf_init(void)
zf_show_action(action); zf_show_action(action);
if (!request_region(ZF_IOBASE, 3, "MachZ ZFL WDT")) { if (!request_region(ZF_IOBASE, 3, "MachZ ZFL WDT")) {
printk(KERN_ERR "cannot reserve I/O ports at %d\n", pr_err("cannot reserve I/O ports at %d\n", ZF_IOBASE);
ZF_IOBASE);
ret = -EBUSY; ret = -EBUSY;
goto no_region; goto no_region;
} }
ret = register_reboot_notifier(&zf_notifier); ret = register_reboot_notifier(&zf_notifier);
if (ret) { if (ret) {
printk(KERN_ERR "can't register reboot notifier (err=%d)\n", pr_err("can't register reboot notifier (err=%d)\n", ret);
ret);
goto no_reboot; goto no_reboot;
} }
ret = misc_register(&zf_miscdev); ret = misc_register(&zf_miscdev);
if (ret) { if (ret) {
printk(KERN_ERR "can't misc_register on minor=%d\n", pr_err("can't misc_register on minor=%d\n", WATCHDOG_MINOR);
WATCHDOG_MINOR);
goto no_misc; goto no_misc;
} }
......
...@@ -18,23 +18,20 @@ ...@@ -18,23 +18,20 @@
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
#include <linux/watchdog.h> #include <linux/watchdog.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/uaccess.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/device.h>
#include <linux/slab.h> #include <linux/slab.h>
#define DEFAULT_HEARTBEAT 60 #define DEFAULT_HEARTBEAT 60
#define MAX_HEARTBEAT 60 #define MAX_HEARTBEAT 60
static int heartbeat = DEFAULT_HEARTBEAT; static unsigned int heartbeat = DEFAULT_HEARTBEAT;
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
/* /*
* Memory mapping: a single byte, 3 first lower bits to select bit 3 * Memory mapping: a single byte, 3 first lower bits to select bit 3
...@@ -45,15 +42,8 @@ static int nowayout = WATCHDOG_NOWAYOUT; ...@@ -45,15 +42,8 @@ static int nowayout = WATCHDOG_NOWAYOUT;
static DEFINE_SPINLOCK(io_lock); static DEFINE_SPINLOCK(io_lock);
static unsigned long wdt_status;
#define WDT_IN_USE 0
#define WDT_RUNNING 1
#define WDT_OK_TO_CLOSE 2
static int nodelay; static int nodelay;
static struct resource *wdt_mem;
static void __iomem *wdt_base; static void __iomem *wdt_base;
static struct platform_device *max63xx_pdev;
/* /*
* The timeout values used are actually the absolute minimum the chip * The timeout values used are actually the absolute minimum the chip
...@@ -117,7 +107,7 @@ max63xx_select_timeout(struct max63xx_timeout *table, int value) ...@@ -117,7 +107,7 @@ max63xx_select_timeout(struct max63xx_timeout *table, int value)
return NULL; return NULL;
} }
static void max63xx_wdt_ping(void) static int max63xx_wdt_ping(struct watchdog_device *wdd)
{ {
u8 val; u8 val;
...@@ -129,15 +119,14 @@ static void max63xx_wdt_ping(void) ...@@ -129,15 +119,14 @@ static void max63xx_wdt_ping(void)
__raw_writeb(val & ~MAX6369_WDI, wdt_base); __raw_writeb(val & ~MAX6369_WDI, wdt_base);
spin_unlock(&io_lock); spin_unlock(&io_lock);
return 0;
} }
static void max63xx_wdt_enable(struct max63xx_timeout *entry) static int max63xx_wdt_start(struct watchdog_device *wdd)
{ {
struct max63xx_timeout *entry = watchdog_get_drvdata(wdd);
u8 val; u8 val;
if (test_and_set_bit(WDT_RUNNING, &wdt_status))
return;
spin_lock(&io_lock); spin_lock(&io_lock);
val = __raw_readb(wdt_base); val = __raw_readb(wdt_base);
...@@ -149,10 +138,11 @@ static void max63xx_wdt_enable(struct max63xx_timeout *entry) ...@@ -149,10 +138,11 @@ static void max63xx_wdt_enable(struct max63xx_timeout *entry)
/* check for a edge triggered startup */ /* check for a edge triggered startup */
if (entry->tdelay == 0) if (entry->tdelay == 0)
max63xx_wdt_ping(); max63xx_wdt_ping(wdd);
return 0;
} }
static void max63xx_wdt_disable(void) static int max63xx_wdt_stop(struct watchdog_device *wdd)
{ {
u8 val; u8 val;
...@@ -164,113 +154,29 @@ static void max63xx_wdt_disable(void) ...@@ -164,113 +154,29 @@ static void max63xx_wdt_disable(void)
__raw_writeb(val, wdt_base); __raw_writeb(val, wdt_base);
spin_unlock(&io_lock); spin_unlock(&io_lock);
return 0;
clear_bit(WDT_RUNNING, &wdt_status);
}
static int max63xx_wdt_open(struct inode *inode, struct file *file)
{
if (test_and_set_bit(WDT_IN_USE, &wdt_status))
return -EBUSY;
max63xx_wdt_enable(current_timeout);
clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
return nonseekable_open(inode, file);
}
static ssize_t max63xx_wdt_write(struct file *file, const char *data,
size_t len, loff_t *ppos)
{
if (len) {
if (!nowayout) {
size_t i;
clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
for (i = 0; i != len; i++) {
char c;
if (get_user(c, data + i))
return -EFAULT;
if (c == 'V')
set_bit(WDT_OK_TO_CLOSE, &wdt_status);
}
}
max63xx_wdt_ping();
}
return len;
} }
static const struct watchdog_info ident = { static const struct watchdog_info max63xx_wdt_info = {
.options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING, .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
.identity = "max63xx Watchdog", .identity = "max63xx Watchdog",
}; };
static long max63xx_wdt_ioctl(struct file *file, unsigned int cmd, static const struct watchdog_ops max63xx_wdt_ops = {
unsigned long arg) .owner = THIS_MODULE,
{ .start = max63xx_wdt_start,
int ret = -ENOTTY; .stop = max63xx_wdt_stop,
.ping = max63xx_wdt_ping,
switch (cmd) {
case WDIOC_GETSUPPORT:
ret = copy_to_user((struct watchdog_info *)arg, &ident,
sizeof(ident)) ? -EFAULT : 0;
break;
case WDIOC_GETSTATUS:
case WDIOC_GETBOOTSTATUS:
ret = put_user(0, (int *)arg);
break;
case WDIOC_KEEPALIVE:
max63xx_wdt_ping();
ret = 0;
break;
case WDIOC_GETTIMEOUT:
ret = put_user(heartbeat, (int *)arg);
break;
}
return ret;
}
static int max63xx_wdt_release(struct inode *inode, struct file *file)
{
if (test_bit(WDT_OK_TO_CLOSE, &wdt_status))
max63xx_wdt_disable();
else
dev_crit(&max63xx_pdev->dev,
"device closed unexpectedly - timer will not stop\n");
clear_bit(WDT_IN_USE, &wdt_status);
clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
return 0;
}
static const struct file_operations max63xx_wdt_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.write = max63xx_wdt_write,
.unlocked_ioctl = max63xx_wdt_ioctl,
.open = max63xx_wdt_open,
.release = max63xx_wdt_release,
}; };
static struct miscdevice max63xx_wdt_miscdev = { static struct watchdog_device max63xx_wdt_dev = {
.minor = WATCHDOG_MINOR, .info = &max63xx_wdt_info,
.name = "watchdog", .ops = &max63xx_wdt_ops,
.fops = &max63xx_wdt_fops,
}; };
static int __devinit max63xx_wdt_probe(struct platform_device *pdev) static int __devinit max63xx_wdt_probe(struct platform_device *pdev)
{ {
int ret = 0; struct resource *wdt_mem;
int size;
struct device *dev = &pdev->dev;
struct max63xx_timeout *table; struct max63xx_timeout *table;
table = (struct max63xx_timeout *)pdev->id_entry->driver_data; table = (struct max63xx_timeout *)pdev->id_entry->driver_data;
...@@ -278,68 +184,34 @@ static int __devinit max63xx_wdt_probe(struct platform_device *pdev) ...@@ -278,68 +184,34 @@ static int __devinit max63xx_wdt_probe(struct platform_device *pdev)
if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT) if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT)
heartbeat = DEFAULT_HEARTBEAT; heartbeat = DEFAULT_HEARTBEAT;
dev_info(dev, "requesting %ds heartbeat\n", heartbeat); dev_info(&pdev->dev, "requesting %ds heartbeat\n", heartbeat);
current_timeout = max63xx_select_timeout(table, heartbeat); current_timeout = max63xx_select_timeout(table, heartbeat);
if (!current_timeout) { if (!current_timeout) {
dev_err(dev, "unable to satisfy heartbeat request\n"); dev_err(&pdev->dev, "unable to satisfy heartbeat request\n");
return -EINVAL; return -EINVAL;
} }
dev_info(dev, "using %ds heartbeat with %ds initial delay\n", dev_info(&pdev->dev, "using %ds heartbeat with %ds initial delay\n",
current_timeout->twd, current_timeout->tdelay); current_timeout->twd, current_timeout->tdelay);
heartbeat = current_timeout->twd; heartbeat = current_timeout->twd;
max63xx_pdev = pdev;
wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (wdt_mem == NULL) { wdt_base = devm_request_and_ioremap(&pdev->dev, wdt_mem);
dev_err(dev, "failed to get memory region resource\n"); if (!wdt_base)
return -ENOENT; return -ENOMEM;
}
size = resource_size(wdt_mem); max63xx_wdt_dev.timeout = heartbeat;
if (!request_mem_region(wdt_mem->start, size, pdev->name)) { watchdog_set_nowayout(&max63xx_wdt_dev, nowayout);
dev_err(dev, "failed to get memory region\n"); watchdog_set_drvdata(&max63xx_wdt_dev, current_timeout);
return -ENOENT;
}
wdt_base = ioremap(wdt_mem->start, size);
if (!wdt_base) {
dev_err(dev, "failed to map memory region\n");
ret = -ENOMEM;
goto out_request;
}
ret = misc_register(&max63xx_wdt_miscdev); return watchdog_register_device(&max63xx_wdt_dev);
if (ret < 0) {
dev_err(dev, "cannot register misc device\n");
goto out_unmap;
}
return 0;
out_unmap:
iounmap(wdt_base);
out_request:
release_mem_region(wdt_mem->start, size);
wdt_mem = NULL;
return ret;
} }
static int __devexit max63xx_wdt_remove(struct platform_device *pdev) static int __devexit max63xx_wdt_remove(struct platform_device *pdev)
{ {
misc_deregister(&max63xx_wdt_miscdev); watchdog_unregister_device(&max63xx_wdt_dev);
if (wdt_mem) {
release_mem_region(wdt_mem->start, resource_size(wdt_mem));
wdt_mem = NULL;
}
if (wdt_base)
iounmap(wdt_base);
return 0; return 0;
} }
...@@ -375,7 +247,7 @@ MODULE_PARM_DESC(heartbeat, ...@@ -375,7 +247,7 @@ MODULE_PARM_DESC(heartbeat,
__MODULE_STRING(MAX_HEARTBEAT) ", default " __MODULE_STRING(MAX_HEARTBEAT) ", default "
__MODULE_STRING(DEFAULT_HEARTBEAT)); __MODULE_STRING(DEFAULT_HEARTBEAT));
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
......
...@@ -39,9 +39,10 @@ ...@@ -39,9 +39,10 @@
* *
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#define VERSION "0.6" #define VERSION "0.6"
#define WATCHDOG_NAME "mixcomwd" #define WATCHDOG_NAME "mixcomwd"
#define PFX WATCHDOG_NAME ": "
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
...@@ -107,8 +108,8 @@ static int mixcomwd_timer_alive; ...@@ -107,8 +108,8 @@ static int mixcomwd_timer_alive;
static DEFINE_TIMER(mixcomwd_timer, mixcomwd_timerfun, 0, 0); static DEFINE_TIMER(mixcomwd_timer, mixcomwd_timerfun, 0, 0);
static char expect_close; static char expect_close;
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default=" "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -156,15 +157,13 @@ static int mixcomwd_release(struct inode *inode, struct file *file) ...@@ -156,15 +157,13 @@ static int mixcomwd_release(struct inode *inode, struct file *file)
{ {
if (expect_close == 42) { if (expect_close == 42) {
if (mixcomwd_timer_alive) { if (mixcomwd_timer_alive) {
printk(KERN_ERR PFX pr_err("release called while internal timer alive\n");
"release called while internal timer alive");
return -EBUSY; return -EBUSY;
} }
mixcomwd_timer_alive = 1; mixcomwd_timer_alive = 1;
mod_timer(&mixcomwd_timer, jiffies + 5 * HZ); mod_timer(&mixcomwd_timer, jiffies + 5 * HZ);
} else } else
printk(KERN_CRIT PFX pr_crit("WDT device closed unexpectedly. WDT will not stop!\n");
"WDT device closed unexpectedly. WDT will not stop!\n");
clear_bit(0, &mixcomwd_opened); clear_bit(0, &mixcomwd_opened);
expect_close = 0; expect_close = 0;
...@@ -274,22 +273,19 @@ static int __init mixcomwd_init(void) ...@@ -274,22 +273,19 @@ static int __init mixcomwd_init(void)
} }
if (!found) { if (!found) {
printk(KERN_ERR PFX pr_err("No card detected, or port not available\n");
"No card detected, or port not available.\n");
return -ENODEV; return -ENODEV;
} }
ret = misc_register(&mixcomwd_miscdev); ret = misc_register(&mixcomwd_miscdev);
if (ret) { if (ret) {
printk(KERN_ERR PFX pr_err("cannot register miscdev on minor=%d (err=%d)\n",
"cannot register miscdev on minor=%d (err=%d)\n", WATCHDOG_MINOR, ret);
WATCHDOG_MINOR, ret);
goto error_misc_register_watchdog; goto error_misc_register_watchdog;
} }
printk(KERN_INFO pr_info("MixCOM watchdog driver v%s, watchdog port at 0x%3x\n",
"MixCOM watchdog driver v%s, watchdog port at 0x%3x\n", VERSION, watchdog_port);
VERSION, watchdog_port);
return 0; return 0;
...@@ -303,8 +299,7 @@ static void __exit mixcomwd_exit(void) ...@@ -303,8 +299,7 @@ static void __exit mixcomwd_exit(void)
{ {
if (!nowayout) { if (!nowayout) {
if (mixcomwd_timer_alive) { if (mixcomwd_timer_alive) {
printk(KERN_WARNING PFX "I quit now, hardware will" pr_warn("I quit now, hardware will probably reboot!\n");
" probably reboot!\n");
del_timer_sync(&mixcomwd_timer); del_timer_sync(&mixcomwd_timer);
mixcomwd_timer_alive = 0; mixcomwd_timer_alive = 0;
} }
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
* option) any later version. * option) any later version.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -60,8 +62,8 @@ module_param(reset, bool, 0); ...@@ -60,8 +62,8 @@ module_param(reset, bool, 0);
MODULE_PARM_DESC(reset, MODULE_PARM_DESC(reset,
"Watchdog Interrupt/Reset Mode. 0 = interrupt, 1 = reset"); "Watchdog Interrupt/Reset Mode. 0 = interrupt, 1 = reset");
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 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) ")"); "(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -96,7 +98,7 @@ static void mpc8xxx_wdt_timer_ping(unsigned long arg) ...@@ -96,7 +98,7 @@ static void mpc8xxx_wdt_timer_ping(unsigned long arg)
static void mpc8xxx_wdt_pr_warn(const char *msg) static void mpc8xxx_wdt_pr_warn(const char *msg)
{ {
pr_crit("mpc8xxx_wdt: %s, expect the %s soon!\n", msg, pr_crit("%s, expect the %s soon!\n", msg,
reset ? "reset" : "machine check exception"); reset ? "reset" : "machine check exception");
} }
...@@ -209,7 +211,7 @@ static int __devinit mpc8xxx_wdt_probe(struct platform_device *ofdev) ...@@ -209,7 +211,7 @@ static int __devinit mpc8xxx_wdt_probe(struct platform_device *ofdev)
enabled = in_be32(&wd_base->swcrr) & SWCRR_SWEN; enabled = in_be32(&wd_base->swcrr) & SWCRR_SWEN;
if (!enabled && wdt_type->hw_enabled) { if (!enabled && wdt_type->hw_enabled) {
pr_info("mpc8xxx_wdt: could not be enabled in software\n"); pr_info("could not be enabled in software\n");
ret = -ENOSYS; ret = -ENOSYS;
goto err_unmap; goto err_unmap;
} }
...@@ -226,9 +228,8 @@ static int __devinit mpc8xxx_wdt_probe(struct platform_device *ofdev) ...@@ -226,9 +228,8 @@ static int __devinit mpc8xxx_wdt_probe(struct platform_device *ofdev)
goto err_unmap; goto err_unmap;
#endif #endif
pr_info("WDT driver for MPC8xxx initialized. mode:%s timeout=%d " pr_info("WDT driver for MPC8xxx initialized. mode:%s timeout=%d (%d seconds)\n",
"(%d seconds)\n", reset ? "reset" : "interrupt", timeout, reset ? "reset" : "interrupt", timeout, timeout_sec);
timeout_sec);
/* /*
* If the watchdog was previously enabled or we're running on * If the watchdog was previously enabled or we're running on
...@@ -303,7 +304,7 @@ static int mpc8xxx_wdt_init_late(void) ...@@ -303,7 +304,7 @@ static int mpc8xxx_wdt_init_late(void)
ret = misc_register(&mpc8xxx_wdt_miscdev); ret = misc_register(&mpc8xxx_wdt_miscdev);
if (ret) { if (ret) {
pr_err("cannot register miscdev on minor=%d (err=%d)\n", pr_err("cannot register miscdev on minor=%d (err=%d)\n",
WATCHDOG_MINOR, ret); WATCHDOG_MINOR, ret);
return ret; return ret;
} }
return 0; return 0;
......
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
* (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk> * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk>
* *
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -44,7 +47,7 @@ struct mpcore_wdt { ...@@ -44,7 +47,7 @@ struct mpcore_wdt {
char expect_close; char expect_close;
}; };
static struct platform_device *mpcore_wdt_dev; static struct platform_device *mpcore_wdt_pdev;
static DEFINE_SPINLOCK(wdt_lock); static DEFINE_SPINLOCK(wdt_lock);
#define TIMER_MARGIN 60 #define TIMER_MARGIN 60
...@@ -54,8 +57,8 @@ MODULE_PARM_DESC(mpcore_margin, ...@@ -54,8 +57,8 @@ MODULE_PARM_DESC(mpcore_margin,
"MPcore timer margin in seconds. (0 < mpcore_margin < 65536, default=" "MPcore timer margin in seconds. (0 < mpcore_margin < 65536, default="
__MODULE_STRING(TIMER_MARGIN) ")"); __MODULE_STRING(TIMER_MARGIN) ")");
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default=" "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -148,7 +151,7 @@ static int mpcore_wdt_set_heartbeat(int t) ...@@ -148,7 +151,7 @@ static int mpcore_wdt_set_heartbeat(int t)
*/ */
static int mpcore_wdt_open(struct inode *inode, struct file *file) static int mpcore_wdt_open(struct inode *inode, struct file *file)
{ {
struct mpcore_wdt *wdt = platform_get_drvdata(mpcore_wdt_dev); struct mpcore_wdt *wdt = platform_get_drvdata(mpcore_wdt_pdev);
if (test_and_set_bit(0, &wdt->timer_alive)) if (test_and_set_bit(0, &wdt->timer_alive))
return -EBUSY; return -EBUSY;
...@@ -298,9 +301,9 @@ static long mpcore_wdt_ioctl(struct file *file, unsigned int cmd, ...@@ -298,9 +301,9 @@ static long mpcore_wdt_ioctl(struct file *file, unsigned int cmd,
* System shutdown handler. Turn off the watchdog if we're * System shutdown handler. Turn off the watchdog if we're
* restarting or halting the system. * restarting or halting the system.
*/ */
static void mpcore_wdt_shutdown(struct platform_device *dev) static void mpcore_wdt_shutdown(struct platform_device *pdev)
{ {
struct mpcore_wdt *wdt = platform_get_drvdata(dev); struct mpcore_wdt *wdt = platform_get_drvdata(pdev);
if (system_state == SYSTEM_RESTART || system_state == SYSTEM_HALT) if (system_state == SYSTEM_RESTART || system_state == SYSTEM_HALT)
mpcore_wdt_stop(wdt); mpcore_wdt_stop(wdt);
...@@ -324,99 +327,79 @@ static struct miscdevice mpcore_wdt_miscdev = { ...@@ -324,99 +327,79 @@ static struct miscdevice mpcore_wdt_miscdev = {
.fops = &mpcore_wdt_fops, .fops = &mpcore_wdt_fops,
}; };
static int __devinit mpcore_wdt_probe(struct platform_device *dev) static int __devinit mpcore_wdt_probe(struct platform_device *pdev)
{ {
struct mpcore_wdt *wdt; struct mpcore_wdt *wdt;
struct resource *res; struct resource *res;
int ret; int ret;
/* We only accept one device, and it must have an id of -1 */ /* We only accept one device, and it must have an id of -1 */
if (dev->id != -1) if (pdev->id != -1)
return -ENODEV; return -ENODEV;
res = platform_get_resource(dev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { if (!res)
ret = -ENODEV; return -ENODEV;
goto err_out;
}
wdt = kzalloc(sizeof(struct mpcore_wdt), GFP_KERNEL); wdt = devm_kzalloc(&pdev->dev, sizeof(struct mpcore_wdt), GFP_KERNEL);
if (!wdt) { if (!wdt)
ret = -ENOMEM; return -ENOMEM;
goto err_out;
wdt->dev = &pdev->dev;
wdt->irq = platform_get_irq(pdev, 0);
if (wdt->irq >= 0) {
ret = devm_request_irq(wdt->dev, wdt->irq, mpcore_wdt_fire, 0,
"mpcore_wdt", wdt);
if (ret) {
dev_printk(KERN_ERR, wdt->dev,
"cannot register IRQ%d for watchdog\n",
wdt->irq);
return ret;
}
} }
wdt->dev = &dev->dev; wdt->base = devm_ioremap(wdt->dev, res->start, resource_size(res));
wdt->irq = platform_get_irq(dev, 0); if (!wdt->base)
if (wdt->irq < 0) { return -ENOMEM;
ret = -ENXIO;
goto err_free;
}
wdt->base = ioremap(res->start, resource_size(res));
if (!wdt->base) {
ret = -ENOMEM;
goto err_free;
}
mpcore_wdt_miscdev.parent = &dev->dev; mpcore_wdt_miscdev.parent = &pdev->dev;
ret = misc_register(&mpcore_wdt_miscdev); ret = misc_register(&mpcore_wdt_miscdev);
if (ret) { if (ret) {
dev_printk(KERN_ERR, wdt->dev, dev_printk(KERN_ERR, wdt->dev,
"cannot register miscdev on minor=%d (err=%d)\n", "cannot register miscdev on minor=%d (err=%d)\n",
WATCHDOG_MINOR, ret); WATCHDOG_MINOR, ret);
goto err_misc; return ret;
}
ret = request_irq(wdt->irq, mpcore_wdt_fire, 0, "mpcore_wdt", wdt);
if (ret) {
dev_printk(KERN_ERR, wdt->dev,
"cannot register IRQ%d for watchdog\n", wdt->irq);
goto err_irq;
} }
mpcore_wdt_stop(wdt); mpcore_wdt_stop(wdt);
platform_set_drvdata(dev, wdt); platform_set_drvdata(pdev, wdt);
mpcore_wdt_dev = dev; mpcore_wdt_pdev = pdev;
return 0; return 0;
err_irq:
misc_deregister(&mpcore_wdt_miscdev);
err_misc:
iounmap(wdt->base);
err_free:
kfree(wdt);
err_out:
return ret;
} }
static int __devexit mpcore_wdt_remove(struct platform_device *dev) static int __devexit mpcore_wdt_remove(struct platform_device *pdev)
{ {
struct mpcore_wdt *wdt = platform_get_drvdata(dev); platform_set_drvdata(pdev, NULL);
platform_set_drvdata(dev, NULL);
misc_deregister(&mpcore_wdt_miscdev); misc_deregister(&mpcore_wdt_miscdev);
mpcore_wdt_dev = NULL; mpcore_wdt_pdev = NULL;
free_irq(wdt->irq, wdt);
iounmap(wdt->base);
kfree(wdt);
return 0; return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int mpcore_wdt_suspend(struct platform_device *dev, pm_message_t msg) static int mpcore_wdt_suspend(struct platform_device *pdev, pm_message_t msg)
{ {
struct mpcore_wdt *wdt = platform_get_drvdata(dev); struct mpcore_wdt *wdt = platform_get_drvdata(pdev);
mpcore_wdt_stop(wdt); /* Turn the WDT off */ mpcore_wdt_stop(wdt); /* Turn the WDT off */
return 0; return 0;
} }
static int mpcore_wdt_resume(struct platform_device *dev) static int mpcore_wdt_resume(struct platform_device *pdev)
{ {
struct mpcore_wdt *wdt = platform_get_drvdata(dev); struct mpcore_wdt *wdt = platform_get_drvdata(pdev);
/* re-activate timer */ /* re-activate timer */
if (test_bit(0, &wdt->timer_alive)) if (test_bit(0, &wdt->timer_alive))
mpcore_wdt_start(wdt); mpcore_wdt_start(wdt);
...@@ -442,9 +425,6 @@ static struct platform_driver mpcore_wdt_driver = { ...@@ -442,9 +425,6 @@ static struct platform_driver mpcore_wdt_driver = {
}, },
}; };
static char banner[] __initdata = KERN_INFO "MPcore Watchdog Timer: 0.1. "
"mpcore_noboot=%d mpcore_margin=%d sec (nowayout= %d)\n";
static int __init mpcore_wdt_init(void) static int __init mpcore_wdt_init(void)
{ {
/* /*
...@@ -453,11 +433,12 @@ static int __init mpcore_wdt_init(void) ...@@ -453,11 +433,12 @@ static int __init mpcore_wdt_init(void)
*/ */
if (mpcore_wdt_set_heartbeat(mpcore_margin)) { if (mpcore_wdt_set_heartbeat(mpcore_margin)) {
mpcore_wdt_set_heartbeat(TIMER_MARGIN); mpcore_wdt_set_heartbeat(TIMER_MARGIN);
printk(KERN_INFO "mpcore_margin value must be 0 < mpcore_margin < 65536, using %d\n", pr_info("mpcore_margin value must be 0 < mpcore_margin < 65536, using %d\n",
TIMER_MARGIN); TIMER_MARGIN);
} }
printk(banner, mpcore_noboot, mpcore_margin, nowayout); pr_info("MPcore Watchdog Timer: 0.1. mpcore_noboot=%d mpcore_margin=%d sec (nowayout= %d)\n",
mpcore_noboot, mpcore_margin, nowayout);
return platform_driver_register(&mpcore_wdt_driver); return platform_driver_register(&mpcore_wdt_driver);
} }
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
* or implied. * or implied.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -58,8 +60,8 @@ static unsigned int bus_clk; ...@@ -58,8 +60,8 @@ static unsigned int bus_clk;
static char expect_close; static char expect_close;
static DEFINE_SPINLOCK(mv64x60_wdt_spinlock); static DEFINE_SPINLOCK(mv64x60_wdt_spinlock);
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default=" "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -100,7 +102,7 @@ static void mv64x60_wdt_handler_enable(void) ...@@ -100,7 +102,7 @@ static void mv64x60_wdt_handler_enable(void)
if (mv64x60_wdt_toggle_wdc(MV64x60_WDC_ENABLED_FALSE, if (mv64x60_wdt_toggle_wdc(MV64x60_WDC_ENABLED_FALSE,
MV64x60_WDC_ENABLE_SHIFT)) { MV64x60_WDC_ENABLE_SHIFT)) {
mv64x60_wdt_service(); mv64x60_wdt_service();
printk(KERN_NOTICE "mv64x60_wdt: watchdog activated\n"); pr_notice("watchdog activated\n");
} }
} }
...@@ -108,7 +110,7 @@ static void mv64x60_wdt_handler_disable(void) ...@@ -108,7 +110,7 @@ static void mv64x60_wdt_handler_disable(void)
{ {
if (mv64x60_wdt_toggle_wdc(MV64x60_WDC_ENABLED_TRUE, if (mv64x60_wdt_toggle_wdc(MV64x60_WDC_ENABLED_TRUE,
MV64x60_WDC_ENABLE_SHIFT)) MV64x60_WDC_ENABLE_SHIFT))
printk(KERN_NOTICE "mv64x60_wdt: watchdog deactivated\n"); pr_notice("watchdog deactivated\n");
} }
static void mv64x60_wdt_set_timeout(unsigned int timeout) static void mv64x60_wdt_set_timeout(unsigned int timeout)
...@@ -139,8 +141,7 @@ static int mv64x60_wdt_release(struct inode *inode, struct file *file) ...@@ -139,8 +141,7 @@ static int mv64x60_wdt_release(struct inode *inode, struct file *file)
if (expect_close == 42) if (expect_close == 42)
mv64x60_wdt_handler_disable(); mv64x60_wdt_handler_disable();
else { else {
printk(KERN_CRIT pr_crit("unexpected close, not stopping timer!\n");
"mv64x60_wdt: unexpected close, not stopping timer!\n");
mv64x60_wdt_service(); mv64x60_wdt_service();
} }
expect_close = 0; expect_close = 0;
...@@ -308,7 +309,7 @@ static struct platform_driver mv64x60_wdt_driver = { ...@@ -308,7 +309,7 @@ static struct platform_driver mv64x60_wdt_driver = {
static int __init mv64x60_wdt_init(void) static int __init mv64x60_wdt_init(void)
{ {
printk(KERN_INFO "MV64x60 watchdog driver\n"); pr_info("MV64x60 watchdog driver\n");
return platform_driver_register(&mv64x60_wdt_driver); return platform_driver_register(&mv64x60_wdt_driver);
} }
......
...@@ -55,8 +55,8 @@ module_param(heartbeat, int, 0); ...@@ -55,8 +55,8 @@ module_param(heartbeat, int, 0);
MODULE_PARM_DESC(heartbeat, "Watchdog heartbeats in seconds. " MODULE_PARM_DESC(heartbeat, "Watchdog heartbeats in seconds. "
"(default = " __MODULE_STRING(WDT_HEARTBEAT) ")"); "(default = " __MODULE_STRING(WDT_HEARTBEAT) ")");
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 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) ")"); "(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
* Includes, defines, variables, module parameters, ... * Includes, defines, variables, module parameters, ...
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -41,7 +43,6 @@ ...@@ -41,7 +43,6 @@
#define TCO_VERSION "0.01" #define TCO_VERSION "0.01"
#define TCO_MODULE_NAME "NV_TCO" #define TCO_MODULE_NAME "NV_TCO"
#define TCO_DRIVER_NAME TCO_MODULE_NAME ", v" TCO_VERSION #define TCO_DRIVER_NAME TCO_MODULE_NAME ", v" TCO_VERSION
#define PFX TCO_MODULE_NAME ": "
/* internal variables */ /* internal variables */
static unsigned int tcobase; static unsigned int tcobase;
...@@ -60,8 +61,8 @@ module_param(heartbeat, int, 0); ...@@ -60,8 +61,8 @@ module_param(heartbeat, int, 0);
MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (2<heartbeat<39, " MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (2<heartbeat<39, "
"default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); "default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 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) ")"); " (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -169,8 +170,7 @@ static int nv_tco_release(struct inode *inode, struct file *file) ...@@ -169,8 +170,7 @@ static int nv_tco_release(struct inode *inode, struct file *file)
if (tco_expect_close == 42) { if (tco_expect_close == 42) {
tco_timer_stop(); tco_timer_stop();
} else { } else {
printk(KERN_CRIT PFX "Unexpected close, not stopping " pr_crit("Unexpected close, not stopping watchdog!\n");
"watchdog!\n");
tco_timer_keepalive(); tco_timer_keepalive();
} }
clear_bit(0, &timer_alive); clear_bit(0, &timer_alive);
...@@ -323,15 +323,14 @@ static unsigned char __devinit nv_tco_getdevice(void) ...@@ -323,15 +323,14 @@ static unsigned char __devinit nv_tco_getdevice(void)
val &= 0xffff; val &= 0xffff;
if (val == 0x0001 || val == 0x0000) { if (val == 0x0001 || val == 0x0000) {
/* Something is wrong here, bar isn't setup */ /* Something is wrong here, bar isn't setup */
printk(KERN_ERR PFX "failed to get tcobase address\n"); pr_err("failed to get tcobase address\n");
return 0; return 0;
} }
val &= 0xff00; val &= 0xff00;
tcobase = val + 0x40; tcobase = val + 0x40;
if (!request_region(tcobase, 0x10, "NV TCO")) { if (!request_region(tcobase, 0x10, "NV TCO")) {
printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", pr_err("I/O address 0x%04x already in use\n", tcobase);
tcobase);
return 0; return 0;
} }
...@@ -347,7 +346,7 @@ static unsigned char __devinit nv_tco_getdevice(void) ...@@ -347,7 +346,7 @@ static unsigned char __devinit nv_tco_getdevice(void)
/* Disable SMI caused by TCO */ /* Disable SMI caused by TCO */
if (!request_region(MCP51_SMI_EN(tcobase), 4, "NV TCO")) { if (!request_region(MCP51_SMI_EN(tcobase), 4, "NV TCO")) {
printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", pr_err("I/O address 0x%04x already in use\n",
MCP51_SMI_EN(tcobase)); MCP51_SMI_EN(tcobase));
goto out; goto out;
} }
...@@ -357,7 +356,7 @@ static unsigned char __devinit nv_tco_getdevice(void) ...@@ -357,7 +356,7 @@ static unsigned char __devinit nv_tco_getdevice(void)
val = inl(MCP51_SMI_EN(tcobase)); val = inl(MCP51_SMI_EN(tcobase));
release_region(MCP51_SMI_EN(tcobase), 4); release_region(MCP51_SMI_EN(tcobase), 4);
if (val & MCP51_SMI_EN_TCO) { if (val & MCP51_SMI_EN_TCO) {
printk(KERN_ERR PFX "Could not disable SMI caused by TCO\n"); pr_err("Could not disable SMI caused by TCO\n");
goto out; goto out;
} }
...@@ -367,8 +366,7 @@ static unsigned char __devinit nv_tco_getdevice(void) ...@@ -367,8 +366,7 @@ static unsigned char __devinit nv_tco_getdevice(void)
pci_write_config_dword(tco_pci, MCP51_SMBUS_SETUP_B, val); pci_write_config_dword(tco_pci, MCP51_SMBUS_SETUP_B, val);
pci_read_config_dword(tco_pci, MCP51_SMBUS_SETUP_B, &val); pci_read_config_dword(tco_pci, MCP51_SMBUS_SETUP_B, &val);
if (!(val & MCP51_SMBUS_SETUP_B_TCO_REBOOT)) { if (!(val & MCP51_SMBUS_SETUP_B_TCO_REBOOT)) {
printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, reboot " pr_err("failed to reset NO_REBOOT flag, reboot disabled by hardware\n");
"disabled by hardware\n");
goto out; goto out;
} }
...@@ -387,8 +385,8 @@ static int __devinit nv_tco_init(struct platform_device *dev) ...@@ -387,8 +385,8 @@ static int __devinit nv_tco_init(struct platform_device *dev)
return -ENODEV; return -ENODEV;
/* Check to see if last reboot was due to watchdog timeout */ /* Check to see if last reboot was due to watchdog timeout */
printk(KERN_INFO PFX "Watchdog reboot %sdetected.\n", pr_info("Watchdog reboot %sdetected\n",
inl(TCO_STS(tcobase)) & TCO_STS_TCO2TO_STS ? "" : "not "); inl(TCO_STS(tcobase)) & TCO_STS_TCO2TO_STS ? "" : "not ");
/* Clear out the old status */ /* Clear out the old status */
outl(TCO_STS_RESET, TCO_STS(tcobase)); outl(TCO_STS_RESET, TCO_STS(tcobase));
...@@ -400,14 +398,14 @@ static int __devinit nv_tco_init(struct platform_device *dev) ...@@ -400,14 +398,14 @@ static int __devinit nv_tco_init(struct platform_device *dev)
if (tco_timer_set_heartbeat(heartbeat)) { if (tco_timer_set_heartbeat(heartbeat)) {
heartbeat = WATCHDOG_HEARTBEAT; heartbeat = WATCHDOG_HEARTBEAT;
tco_timer_set_heartbeat(heartbeat); tco_timer_set_heartbeat(heartbeat);
printk(KERN_INFO PFX "heartbeat value must be 2<heartbeat<39, " pr_info("heartbeat value must be 2<heartbeat<39, using %d\n",
"using %d\n", heartbeat); heartbeat);
} }
ret = misc_register(&nv_tco_miscdev); ret = misc_register(&nv_tco_miscdev);
if (ret != 0) { if (ret != 0) {
printk(KERN_ERR PFX "cannot register miscdev on minor=%d " pr_err("cannot register miscdev on minor=%d (err=%d)\n",
"(err=%d)\n", WATCHDOG_MINOR, ret); WATCHDOG_MINOR, ret);
goto unreg_region; goto unreg_region;
} }
...@@ -415,8 +413,8 @@ static int __devinit nv_tco_init(struct platform_device *dev) ...@@ -415,8 +413,8 @@ static int __devinit nv_tco_init(struct platform_device *dev)
tco_timer_stop(); tco_timer_stop();
printk(KERN_INFO PFX "initialized (0x%04x). heartbeat=%d sec " pr_info("initialized (0x%04x). heartbeat=%d sec (nowayout=%d)\n",
"(nowayout=%d)\n", tcobase, heartbeat, nowayout); tcobase, heartbeat, nowayout);
return 0; return 0;
...@@ -439,8 +437,7 @@ static void __devexit nv_tco_cleanup(void) ...@@ -439,8 +437,7 @@ static void __devexit nv_tco_cleanup(void)
pci_write_config_dword(tco_pci, MCP51_SMBUS_SETUP_B, val); pci_write_config_dword(tco_pci, MCP51_SMBUS_SETUP_B, val);
pci_read_config_dword(tco_pci, MCP51_SMBUS_SETUP_B, &val); pci_read_config_dword(tco_pci, MCP51_SMBUS_SETUP_B, &val);
if (val & MCP51_SMBUS_SETUP_B_TCO_REBOOT) { if (val & MCP51_SMBUS_SETUP_B_TCO_REBOOT) {
printk(KERN_CRIT PFX "Couldn't unset REBOOT bit. Machine may " pr_crit("Couldn't unset REBOOT bit. Machine may soon reset\n");
"soon reset\n");
} }
/* Deregister */ /* Deregister */
...@@ -483,8 +480,7 @@ static int __init nv_tco_init_module(void) ...@@ -483,8 +480,7 @@ static int __init nv_tco_init_module(void)
{ {
int err; int err;
printk(KERN_INFO PFX "NV TCO WatchDog Timer Driver v%s\n", pr_info("NV TCO WatchDog Timer Driver v%s\n", TCO_VERSION);
TCO_VERSION);
err = platform_driver_register(&nv_tco_driver); err = platform_driver_register(&nv_tco_driver);
if (err) if (err)
...@@ -508,7 +504,7 @@ static void __exit nv_tco_cleanup_module(void) ...@@ -508,7 +504,7 @@ static void __exit nv_tco_cleanup_module(void)
{ {
platform_device_unregister(nv_tco_platform_device); platform_device_unregister(nv_tco_platform_device);
platform_driver_unregister(&nv_tco_driver); platform_driver_unregister(&nv_tco_driver);
printk(KERN_INFO PFX "NV TCO Watchdog Module Unloaded.\n"); pr_info("NV TCO Watchdog Module Unloaded\n");
} }
module_init(nv_tco_init_module); module_init(nv_tco_init_module);
......
...@@ -52,6 +52,8 @@ ...@@ -52,6 +52,8 @@
* *
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/watchdog.h> #include <linux/watchdog.h>
...@@ -95,8 +97,8 @@ MODULE_PARM_DESC(heartbeat, ...@@ -95,8 +97,8 @@ MODULE_PARM_DESC(heartbeat,
"Watchdog heartbeat in seconds. (0 < heartbeat, default=" "Watchdog heartbeat in seconds. (0 < heartbeat, default="
__MODULE_STRING(WD_TIMO) ")"); __MODULE_STRING(WD_TIMO) ")");
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, S_IRUGO); module_param(nowayout, bool, S_IRUGO);
MODULE_PARM_DESC(nowayout, MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default=" "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
...@@ -201,7 +203,7 @@ static void __init octeon_wdt_build_stage1(void) ...@@ -201,7 +203,7 @@ static void __init octeon_wdt_build_stage1(void)
uasm_resolve_relocs(relocs, labels); uasm_resolve_relocs(relocs, labels);
len = (int)(p - nmi_stage1_insns); len = (int)(p - nmi_stage1_insns);
pr_debug("Synthesized NMI stage 1 handler (%d instructions).\n", len); pr_debug("Synthesized NMI stage 1 handler (%d instructions)\n", len);
pr_debug("\t.set push\n"); pr_debug("\t.set push\n");
pr_debug("\t.set noreorder\n"); pr_debug("\t.set noreorder\n");
...@@ -627,7 +629,7 @@ static int octeon_wdt_release(struct inode *inode, struct file *file) ...@@ -627,7 +629,7 @@ static int octeon_wdt_release(struct inode *inode, struct file *file)
do_coundown = 0; do_coundown = 0;
octeon_wdt_ping(); octeon_wdt_ping();
} else { } else {
pr_crit("octeon_wdt: WDT device closed unexpectedly. WDT will not stop!\n"); pr_crit("WDT device closed unexpectedly. WDT will not stop!\n");
} }
clear_bit(0, &octeon_wdt_is_open); clear_bit(0, &octeon_wdt_is_open);
expect_close = 0; expect_close = 0;
...@@ -684,12 +686,12 @@ static int __init octeon_wdt_init(void) ...@@ -684,12 +686,12 @@ static int __init octeon_wdt_init(void)
octeon_wdt_calc_parameters(heartbeat); octeon_wdt_calc_parameters(heartbeat);
pr_info("octeon_wdt: Initial granularity %d Sec.\n", timeout_sec); pr_info("Initial granularity %d Sec\n", timeout_sec);
ret = misc_register(&octeon_wdt_miscdev); ret = misc_register(&octeon_wdt_miscdev);
if (ret) { if (ret) {
pr_err("octeon_wdt: cannot register miscdev on minor=%d (err=%d)\n", pr_err("cannot register miscdev on minor=%d (err=%d)\n",
WATCHDOG_MINOR, ret); WATCHDOG_MINOR, ret);
goto out; goto out;
} }
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
* know the wdt reset interval * know the wdt reset interval
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -99,7 +101,7 @@ static void xwdt_stop(void) ...@@ -99,7 +101,7 @@ static void xwdt_stop(void)
iowrite32(0, xdev.base + XWT_TWCSR1_OFFSET); iowrite32(0, xdev.base + XWT_TWCSR1_OFFSET);
spin_unlock(&spinlock); spin_unlock(&spinlock);
printk(KERN_INFO PFX "Stopped!\n"); pr_info("Stopped!\n");
} }
static void xwdt_keepalive(void) static void xwdt_keepalive(void)
...@@ -165,7 +167,7 @@ static int xwdt_open(struct inode *inode, struct file *file) ...@@ -165,7 +167,7 @@ static int xwdt_open(struct inode *inode, struct file *file)
__module_get(THIS_MODULE); __module_get(THIS_MODULE);
xwdt_start(); xwdt_start();
printk(KERN_INFO PFX "Started...\n"); pr_info("Started...\n");
return nonseekable_open(inode, file); return nonseekable_open(inode, file);
} }
...@@ -175,8 +177,7 @@ static int xwdt_release(struct inode *inode, struct file *file) ...@@ -175,8 +177,7 @@ static int xwdt_release(struct inode *inode, struct file *file)
if (expect_close == 42) { if (expect_close == 42) {
xwdt_stop(); xwdt_stop();
} else { } else {
printk(KERN_CRIT PFX pr_crit("Unexpected close, not stopping watchdog!\n");
"Unexpected close, not stopping watchdog!\n");
xwdt_keepalive(); xwdt_keepalive();
} }
...@@ -300,22 +301,20 @@ static int __devinit xwdt_probe(struct platform_device *pdev) ...@@ -300,22 +301,20 @@ static int __devinit xwdt_probe(struct platform_device *pdev)
"clock-frequency", NULL); "clock-frequency", NULL);
if (pfreq == NULL) { if (pfreq == NULL) {
printk(KERN_WARNING PFX pr_warn("The watchdog clock frequency cannot be obtained!\n");
"The watchdog clock frequency cannot be obtained!\n");
no_timeout = 1; no_timeout = 1;
} }
rc = of_address_to_resource(pdev->dev.of_node, 0, &xdev.res); rc = of_address_to_resource(pdev->dev.of_node, 0, &xdev.res);
if (rc) { if (rc) {
printk(KERN_WARNING PFX "invalid address!\n"); pr_warn("invalid address!\n");
return rc; return rc;
} }
tmptr = (u32 *)of_get_property(pdev->dev.of_node, tmptr = (u32 *)of_get_property(pdev->dev.of_node,
"xlnx,wdt-interval", NULL); "xlnx,wdt-interval", NULL);
if (tmptr == NULL) { if (tmptr == NULL) {
printk(KERN_WARNING PFX "Parameter \"xlnx,wdt-interval\"" pr_warn("Parameter \"xlnx,wdt-interval\" not found in device tree!\n");
" not found in device tree!\n");
no_timeout = 1; no_timeout = 1;
} else { } else {
xdev.wdt_interval = *tmptr; xdev.wdt_interval = *tmptr;
...@@ -324,8 +323,7 @@ static int __devinit xwdt_probe(struct platform_device *pdev) ...@@ -324,8 +323,7 @@ static int __devinit xwdt_probe(struct platform_device *pdev)
tmptr = (u32 *)of_get_property(pdev->dev.of_node, tmptr = (u32 *)of_get_property(pdev->dev.of_node,
"xlnx,wdt-enable-once", NULL); "xlnx,wdt-enable-once", NULL);
if (tmptr == NULL) { if (tmptr == NULL) {
printk(KERN_WARNING PFX "Parameter \"xlnx,wdt-enable-once\"" pr_warn("Parameter \"xlnx,wdt-enable-once\" not found in device tree!\n");
" not found in device tree!\n");
xdev.nowayout = WATCHDOG_NOWAYOUT; xdev.nowayout = WATCHDOG_NOWAYOUT;
} }
...@@ -339,20 +337,20 @@ static int __devinit xwdt_probe(struct platform_device *pdev) ...@@ -339,20 +337,20 @@ static int __devinit xwdt_probe(struct platform_device *pdev)
if (!request_mem_region(xdev.res.start, if (!request_mem_region(xdev.res.start,
xdev.res.end - xdev.res.start + 1, WATCHDOG_NAME)) { xdev.res.end - xdev.res.start + 1, WATCHDOG_NAME)) {
rc = -ENXIO; rc = -ENXIO;
printk(KERN_ERR PFX "memory request failure!\n"); pr_err("memory request failure!\n");
goto err_out; goto err_out;
} }
xdev.base = ioremap(xdev.res.start, xdev.res.end - xdev.res.start + 1); xdev.base = ioremap(xdev.res.start, xdev.res.end - xdev.res.start + 1);
if (xdev.base == NULL) { if (xdev.base == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
printk(KERN_ERR PFX "ioremap failure!\n"); pr_err("ioremap failure!\n");
goto release_mem; goto release_mem;
} }
rc = xwdt_selftest(); rc = xwdt_selftest();
if (rc == XWT_TIMER_FAILED) { if (rc == XWT_TIMER_FAILED) {
printk(KERN_ERR PFX "SelfTest routine error!\n"); pr_err("SelfTest routine error!\n");
goto unmap_io; goto unmap_io;
} }
...@@ -360,20 +358,17 @@ static int __devinit xwdt_probe(struct platform_device *pdev) ...@@ -360,20 +358,17 @@ static int __devinit xwdt_probe(struct platform_device *pdev)
rc = misc_register(&xwdt_miscdev); rc = misc_register(&xwdt_miscdev);
if (rc) { if (rc) {
printk(KERN_ERR PFX pr_err("cannot register miscdev on minor=%d (err=%d)\n",
"cannot register miscdev on minor=%d (err=%d)\n", xwdt_miscdev.minor, rc);
xwdt_miscdev.minor, rc);
goto unmap_io; goto unmap_io;
} }
if (no_timeout) if (no_timeout)
printk(KERN_INFO PFX pr_info("driver loaded (timeout=? sec, nowayout=%d)\n",
"driver loaded (timeout=? sec, nowayout=%d)\n", xdev.nowayout);
xdev.nowayout);
else else
printk(KERN_INFO PFX pr_info("driver loaded (timeout=%d sec, nowayout=%d)\n",
"driver loaded (timeout=%d sec, nowayout=%d)\n", timeout, xdev.nowayout);
timeout, xdev.nowayout);
expect_close = 0; expect_close = 0;
clear_bit(0, &driver_open); clear_bit(0, &driver_open);
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
* Use the driver model and standard identifiers; handle bigger timeouts. * Use the driver model and standard identifiers; handle bigger timeouts.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -183,7 +185,7 @@ static int omap_wdt_release(struct inode *inode, struct file *file) ...@@ -183,7 +185,7 @@ static int omap_wdt_release(struct inode *inode, struct file *file)
pm_runtime_put_sync(wdev->dev); pm_runtime_put_sync(wdev->dev);
#else #else
printk(KERN_CRIT "omap_wdt: Unexpected close, not stopping!\n"); pr_crit("Unexpected close, not stopping!\n");
#endif #endif
wdev->omap_wdt_users = 0; wdev->omap_wdt_users = 0;
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
* warranty of any kind, whether express or implied. * warranty of any kind, whether express or implied.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -36,7 +38,7 @@ ...@@ -36,7 +38,7 @@
#define WDT_IN_USE 0 #define WDT_IN_USE 0
#define WDT_OK_TO_CLOSE 1 #define WDT_OK_TO_CLOSE 1
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
static int heartbeat = -1; /* module parameter (seconds) */ static int heartbeat = -1; /* module parameter (seconds) */
static unsigned int wdt_max_duration; /* (seconds) */ static unsigned int wdt_max_duration; /* (seconds) */
static unsigned int wdt_tclk; static unsigned int wdt_tclk;
...@@ -210,8 +212,7 @@ static int orion_wdt_release(struct inode *inode, struct file *file) ...@@ -210,8 +212,7 @@ static int orion_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))
orion_wdt_disable(); orion_wdt_disable();
else else
printk(KERN_CRIT "WATCHDOG: Device closed unexpectedly - " pr_crit("Device closed unexpectedly - timer will not stop\n");
"timer will not stop\n");
clear_bit(WDT_IN_USE, &wdt_status); clear_bit(WDT_IN_USE, &wdt_status);
clear_bit(WDT_OK_TO_CLOSE, &wdt_status); clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
...@@ -243,7 +244,7 @@ static int __devinit orion_wdt_probe(struct platform_device *pdev) ...@@ -243,7 +244,7 @@ static int __devinit orion_wdt_probe(struct platform_device *pdev)
if (pdata) { if (pdata) {
wdt_tclk = pdata->tclk; wdt_tclk = pdata->tclk;
} else { } else {
printk(KERN_ERR "Orion Watchdog misses platform data\n"); pr_err("misses platform data\n");
return -ENODEV; return -ENODEV;
} }
...@@ -263,8 +264,8 @@ static int __devinit orion_wdt_probe(struct platform_device *pdev) ...@@ -263,8 +264,8 @@ static int __devinit orion_wdt_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
printk(KERN_INFO "Orion Watchdog Timer: Initial timeout %d sec%s\n", pr_info("Initial timeout %d sec%s\n",
heartbeat, nowayout ? ", nowayout" : ""); heartbeat, nowayout ? ", nowayout" : "");
return 0; return 0;
} }
...@@ -308,7 +309,7 @@ MODULE_DESCRIPTION("Orion Processor Watchdog"); ...@@ -308,7 +309,7 @@ MODULE_DESCRIPTION("Orion Processor Watchdog");
module_param(heartbeat, int, 0); module_param(heartbeat, int, 0);
MODULE_PARM_DESC(heartbeat, "Initial watchdog heartbeat in seconds"); MODULE_PARM_DESC(heartbeat, "Initial watchdog heartbeat in seconds");
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
* Copyright (C) 2001, 2008 David S. Miller (davem@davemloft.net) * Copyright (C) 2001, 2008 David S. Miller (davem@davemloft.net)
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -189,7 +191,7 @@ static int __devinit riowd_probe(struct platform_device *op) ...@@ -189,7 +191,7 @@ static int __devinit riowd_probe(struct platform_device *op)
p->regs = of_ioremap(&op->resource[0], 0, 2, DRIVER_NAME); p->regs = of_ioremap(&op->resource[0], 0, 2, DRIVER_NAME);
if (!p->regs) { if (!p->regs) {
printk(KERN_ERR PFX "Cannot map registers.\n"); pr_err("Cannot map registers\n");
goto out_free; goto out_free;
} }
/* Make miscdev useable right away */ /* Make miscdev useable right away */
...@@ -197,12 +199,12 @@ static int __devinit riowd_probe(struct platform_device *op) ...@@ -197,12 +199,12 @@ static int __devinit riowd_probe(struct platform_device *op)
err = misc_register(&riowd_miscdev); err = misc_register(&riowd_miscdev);
if (err) { if (err) {
printk(KERN_ERR PFX "Cannot register watchdog misc device.\n"); pr_err("Cannot register watchdog misc device\n");
goto out_iounmap; goto out_iounmap;
} }
printk(KERN_INFO PFX "Hardware watchdog [%i minutes], " pr_info("Hardware watchdog [%i minutes], regs at %p\n",
"regs at %p\n", riowd_timeout, p->regs); riowd_timeout, p->regs);
dev_set_drvdata(&op->dev, p); dev_set_drvdata(&op->dev, p);
return 0; return 0;
......
This diff is collapsed.
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
* *
* 27/11/2000 Initial release * 27/11/2000 Initial release
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -66,7 +69,7 @@ static int sa1100dog_open(struct inode *inode, struct file *file) ...@@ -66,7 +69,7 @@ static int sa1100dog_open(struct inode *inode, struct file *file)
*/ */
static int sa1100dog_release(struct inode *inode, struct file *file) static int sa1100dog_release(struct inode *inode, struct file *file)
{ {
printk(KERN_CRIT "WATCHDOG: Device closed - timer will not stop\n"); pr_crit("Device closed - timer will not stop\n");
clear_bit(1, &sa1100wdt_users); clear_bit(1, &sa1100wdt_users);
return 0; return 0;
} }
...@@ -169,9 +172,8 @@ static int __init sa1100dog_init(void) ...@@ -169,9 +172,8 @@ static int __init sa1100dog_init(void)
ret = misc_register(&sa1100dog_miscdev); ret = misc_register(&sa1100dog_miscdev);
if (ret == 0) if (ret == 0)
printk(KERN_INFO pr_info("SA1100/PXA2xx Watchdog Timer: timer margin %d sec\n",
"SA1100/PXA2xx Watchdog Timer: timer margin %d sec\n", margin);
margin);
return ret; return ret;
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -34,8 +34,8 @@ MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. " ...@@ -34,8 +34,8 @@ MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. "
__MODULE_STRING(TS72XX_WDT_DEFAULT_TIMEOUT) __MODULE_STRING(TS72XX_WDT_DEFAULT_TIMEOUT)
")"); ")");
static int nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Disable watchdog shutdown on close"); MODULE_PARM_DESC(nowayout, "Disable watchdog shutdown on close");
/** /**
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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