aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog/sbc7240_wdt.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/watchdog/sbc7240_wdt.c')
-rw-r--r--drivers/watchdog/sbc7240_wdt.c45
1 files changed, 17 insertions, 28 deletions
diff --git a/drivers/watchdog/sbc7240_wdt.c b/drivers/watchdog/sbc7240_wdt.c
index 93ac58953122..719edc8fdeb3 100644
--- a/drivers/watchdog/sbc7240_wdt.c
+++ b/drivers/watchdog/sbc7240_wdt.c
@@ -16,6 +16,8 @@
16 * 16 *
17 */ 17 */
18 18
19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20
19#include <linux/fs.h> 21#include <linux/fs.h>
20#include <linux/init.h> 22#include <linux/init.h>
21#include <linux/ioport.h> 23#include <linux/ioport.h>
@@ -30,9 +32,6 @@
30#include <linux/io.h> 32#include <linux/io.h>
31#include <linux/uaccess.h> 33#include <linux/uaccess.h>
32#include <linux/atomic.h> 34#include <linux/atomic.h>
33#include <asm/system.h>
34
35#define SBC7240_PREFIX "sbc7240_wdt: "
36 35
37#define SBC7240_ENABLE_PORT 0x443 36#define SBC7240_ENABLE_PORT 0x443
38#define SBC7240_DISABLE_PORT 0x043 37#define SBC7240_DISABLE_PORT 0x043
@@ -47,8 +46,8 @@ MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. (1<=timeout<="
47 __MODULE_STRING(SBC7240_MAX_TIMEOUT) ", default=" 46 __MODULE_STRING(SBC7240_MAX_TIMEOUT) ", default="
48 __MODULE_STRING(SBC7240_TIMEOUT) ")"); 47 __MODULE_STRING(SBC7240_TIMEOUT) ")");
49 48
50static int nowayout = WATCHDOG_NOWAYOUT; 49static bool nowayout = WATCHDOG_NOWAYOUT;
51module_param(nowayout, int, 0); 50module_param(nowayout, bool, 0);
52MODULE_PARM_DESC(nowayout, "Disable watchdog when closing device file"); 51MODULE_PARM_DESC(nowayout, "Disable watchdog when closing device file");
53 52
54#define SBC7240_OPEN_STATUS_BIT 0 53#define SBC7240_OPEN_STATUS_BIT 0
@@ -65,8 +64,7 @@ static void wdt_disable(void)
65 /* disable the watchdog */ 64 /* disable the watchdog */
66 if (test_and_clear_bit(SBC7240_ENABLED_STATUS_BIT, &wdt_status)) { 65 if (test_and_clear_bit(SBC7240_ENABLED_STATUS_BIT, &wdt_status)) {
67 inb_p(SBC7240_DISABLE_PORT); 66 inb_p(SBC7240_DISABLE_PORT);
68 printk(KERN_INFO SBC7240_PREFIX 67 pr_info("Watchdog timer is now disabled\n");
69 "Watchdog timer is now disabled.\n");
70 } 68 }
71} 69}
72 70
@@ -75,23 +73,20 @@ static void wdt_enable(void)
75 /* enable the watchdog */ 73 /* enable the watchdog */
76 if (!test_and_set_bit(SBC7240_ENABLED_STATUS_BIT, &wdt_status)) { 74 if (!test_and_set_bit(SBC7240_ENABLED_STATUS_BIT, &wdt_status)) {
77 inb_p(SBC7240_ENABLE_PORT); 75 inb_p(SBC7240_ENABLE_PORT);
78 printk(KERN_INFO SBC7240_PREFIX 76 pr_info("Watchdog timer is now enabled\n");
79 "Watchdog timer is now enabled.\n");
80 } 77 }
81} 78}
82 79
83static int wdt_set_timeout(int t) 80static int wdt_set_timeout(int t)
84{ 81{
85 if (t < 1 || t > SBC7240_MAX_TIMEOUT) { 82 if (t < 1 || t > SBC7240_MAX_TIMEOUT) {
86 printk(KERN_ERR SBC7240_PREFIX 83 pr_err("timeout value must be 1<=x<=%d\n", SBC7240_MAX_TIMEOUT);
87 "timeout value must be 1<=x<=%d\n",
88 SBC7240_MAX_TIMEOUT);
89 return -1; 84 return -1;
90 } 85 }
91 /* set the timeout */ 86 /* set the timeout */
92 outb_p((unsigned)t, SBC7240_SET_TIMEOUT_PORT); 87 outb_p((unsigned)t, SBC7240_SET_TIMEOUT_PORT);
93 timeout = t; 88 timeout = t;
94 printk(KERN_INFO SBC7240_PREFIX "timeout set to %d seconds\n", t); 89 pr_info("timeout set to %d seconds\n", t);
95 return 0; 90 return 0;
96} 91}
97 92
@@ -150,8 +145,7 @@ static int fop_close(struct inode *inode, struct file *file)
150 || !nowayout) { 145 || !nowayout) {
151 wdt_disable(); 146 wdt_disable();
152 } else { 147 } else {
153 printk(KERN_CRIT SBC7240_PREFIX 148 pr_crit("Unexpected close, not stopping watchdog!\n");
154 "Unexpected close, not stopping watchdog!\n");
155 wdt_keepalive(); 149 wdt_keepalive();
156 } 150 }
157 151
@@ -252,7 +246,7 @@ static struct notifier_block wdt_notifier = {
252 246
253static void __exit sbc7240_wdt_unload(void) 247static void __exit sbc7240_wdt_unload(void)
254{ 248{
255 printk(KERN_INFO SBC7240_PREFIX "Removing watchdog\n"); 249 pr_info("Removing watchdog\n");
256 misc_deregister(&wdt_miscdev); 250 misc_deregister(&wdt_miscdev);
257 251
258 unregister_reboot_notifier(&wdt_notifier); 252 unregister_reboot_notifier(&wdt_notifier);
@@ -264,8 +258,7 @@ static int __init sbc7240_wdt_init(void)
264 int rc = -EBUSY; 258 int rc = -EBUSY;
265 259
266 if (!request_region(SBC7240_ENABLE_PORT, 1, "SBC7240 WDT")) { 260 if (!request_region(SBC7240_ENABLE_PORT, 1, "SBC7240 WDT")) {
267 printk(KERN_ERR SBC7240_PREFIX 261 pr_err("I/O address 0x%04x already in use\n",
268 "I/O address 0x%04x already in use\n",
269 SBC7240_ENABLE_PORT); 262 SBC7240_ENABLE_PORT);
270 rc = -EIO; 263 rc = -EIO;
271 goto err_out; 264 goto err_out;
@@ -277,31 +270,27 @@ static int __init sbc7240_wdt_init(void)
277 270
278 if (timeout < 1 || timeout > SBC7240_MAX_TIMEOUT) { 271 if (timeout < 1 || timeout > SBC7240_MAX_TIMEOUT) {
279 timeout = SBC7240_TIMEOUT; 272 timeout = SBC7240_TIMEOUT;
280 printk(KERN_INFO SBC7240_PREFIX 273 pr_info("timeout value must be 1<=x<=%d, using %d\n",
281 "timeout value must be 1<=x<=%d, using %d\n", 274 SBC7240_MAX_TIMEOUT, timeout);
282 SBC7240_MAX_TIMEOUT, timeout);
283 } 275 }
284 wdt_set_timeout(timeout); 276 wdt_set_timeout(timeout);
285 wdt_disable(); 277 wdt_disable();
286 278
287 rc = register_reboot_notifier(&wdt_notifier); 279 rc = register_reboot_notifier(&wdt_notifier);
288 if (rc) { 280 if (rc) {
289 printk(KERN_ERR SBC7240_PREFIX 281 pr_err("cannot register reboot notifier (err=%d)\n", rc);
290 "cannot register reboot notifier (err=%d)\n", rc);
291 goto err_out_region; 282 goto err_out_region;
292 } 283 }
293 284
294 rc = misc_register(&wdt_miscdev); 285 rc = misc_register(&wdt_miscdev);
295 if (rc) { 286 if (rc) {
296 printk(KERN_ERR SBC7240_PREFIX 287 pr_err("cannot register miscdev on minor=%d (err=%d)\n",
297 "cannot register miscdev on minor=%d (err=%d)\n",
298 wdt_miscdev.minor, rc); 288 wdt_miscdev.minor, rc);
299 goto err_out_reboot_notifier; 289 goto err_out_reboot_notifier;
300 } 290 }
301 291
302 printk(KERN_INFO SBC7240_PREFIX 292 pr_info("Watchdog driver for SBC7240 initialised (nowayout=%d)\n",
303 "Watchdog driver for SBC7240 initialised (nowayout=%d)\n", 293 nowayout);
304 nowayout);
305 294
306 return 0; 295 return 0;
307 296