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