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