aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog/xen_wdt.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/watchdog/xen_wdt.c')
-rw-r--r--drivers/watchdog/xen_wdt.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/drivers/watchdog/xen_wdt.c b/drivers/watchdog/xen_wdt.c
index 49bd9d395562..e4a25b51165c 100644
--- a/drivers/watchdog/xen_wdt.c
+++ b/drivers/watchdog/xen_wdt.c
@@ -9,9 +9,10 @@
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10 */ 10 */
11 11
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13
12#define DRV_NAME "wdt" 14#define DRV_NAME "wdt"
13#define DRV_VERSION "0.01" 15#define DRV_VERSION "0.01"
14#define PFX DRV_NAME ": "
15 16
16#include <linux/bug.h> 17#include <linux/bug.h>
17#include <linux/errno.h> 18#include <linux/errno.h>
@@ -131,16 +132,17 @@ static int xen_wdt_open(struct inode *inode, struct file *file)
131 132
132static int xen_wdt_release(struct inode *inode, struct file *file) 133static int xen_wdt_release(struct inode *inode, struct file *file)
133{ 134{
135 int err = 0;
136
134 if (expect_release) 137 if (expect_release)
135 xen_wdt_stop(); 138 err = xen_wdt_stop();
136 else { 139 else {
137 printk(KERN_CRIT PFX 140 pr_crit("unexpected close, not stopping watchdog!\n");
138 "unexpected close, not stopping watchdog!\n");
139 xen_wdt_kick(); 141 xen_wdt_kick();
140 } 142 }
141 is_active = false; 143 is_active = err;
142 expect_release = false; 144 expect_release = false;
143 return 0; 145 return err;
144} 146}
145 147
146static ssize_t xen_wdt_write(struct file *file, const char __user *data, 148static ssize_t xen_wdt_write(struct file *file, const char __user *data,
@@ -251,30 +253,27 @@ static int __devinit xen_wdt_probe(struct platform_device *dev)
251 case -EINVAL: 253 case -EINVAL:
252 if (!timeout) { 254 if (!timeout) {
253 timeout = WATCHDOG_TIMEOUT; 255 timeout = WATCHDOG_TIMEOUT;
254 printk(KERN_INFO PFX 256 pr_info("timeout value invalid, using %d\n", timeout);
255 "timeout value invalid, using %d\n", timeout);
256 } 257 }
257 258
258 ret = misc_register(&xen_wdt_miscdev); 259 ret = misc_register(&xen_wdt_miscdev);
259 if (ret) { 260 if (ret) {
260 printk(KERN_ERR PFX 261 pr_err("cannot register miscdev on minor=%d (%d)\n",
261 "cannot register miscdev on minor=%d (%d)\n",
262 WATCHDOG_MINOR, ret); 262 WATCHDOG_MINOR, ret);
263 break; 263 break;
264 } 264 }
265 265
266 printk(KERN_INFO PFX 266 pr_info("initialized (timeout=%ds, nowayout=%d)\n",
267 "initialized (timeout=%ds, nowayout=%d)\n", 267 timeout, nowayout);
268 timeout, nowayout);
269 break; 268 break;
270 269
271 case -ENOSYS: 270 case -ENOSYS:
272 printk(KERN_INFO PFX "not supported\n"); 271 pr_info("not supported\n");
273 ret = -ENODEV; 272 ret = -ENODEV;
274 break; 273 break;
275 274
276 default: 275 default:
277 printk(KERN_INFO PFX "bogus return value %d\n", ret); 276 pr_info("bogus return value %d\n", ret);
278 break; 277 break;
279 } 278 }
280 279
@@ -299,11 +298,18 @@ static void xen_wdt_shutdown(struct platform_device *dev)
299 298
300static int xen_wdt_suspend(struct platform_device *dev, pm_message_t state) 299static int xen_wdt_suspend(struct platform_device *dev, pm_message_t state)
301{ 300{
302 return xen_wdt_stop(); 301 typeof(wdt.id) id = wdt.id;
302 int rc = xen_wdt_stop();
303
304 wdt.id = id;
305 return rc;
303} 306}
304 307
305static int xen_wdt_resume(struct platform_device *dev) 308static int xen_wdt_resume(struct platform_device *dev)
306{ 309{
310 if (!wdt.id)
311 return 0;
312 wdt.id = 0;
307 return xen_wdt_start(); 313 return xen_wdt_start();
308} 314}
309 315
@@ -326,7 +332,7 @@ static int __init xen_wdt_init_module(void)
326 if (!xen_domain()) 332 if (!xen_domain())
327 return -ENODEV; 333 return -ENODEV;
328 334
329 printk(KERN_INFO PFX "Xen WatchDog Timer Driver v%s\n", DRV_VERSION); 335 pr_info("Xen WatchDog Timer Driver v%s\n", DRV_VERSION);
330 336
331 err = platform_driver_register(&xen_wdt_driver); 337 err = platform_driver_register(&xen_wdt_driver);
332 if (err) 338 if (err)
@@ -346,7 +352,7 @@ static void __exit xen_wdt_cleanup_module(void)
346{ 352{
347 platform_device_unregister(platform_device); 353 platform_device_unregister(platform_device);
348 platform_driver_unregister(&xen_wdt_driver); 354 platform_driver_unregister(&xen_wdt_driver);
349 printk(KERN_INFO PFX "module unloaded\n"); 355 pr_info("module unloaded\n");
350} 356}
351 357
352module_init(xen_wdt_init_module); 358module_init(xen_wdt_init_module);