aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2011-03-31 02:39:47 -0400
committerPaul Mundt <lethal@linux-sh.org>2011-03-31 02:39:47 -0400
commit7ea5db8efeac8627500e012aa6829ca612c5a700 (patch)
tree90e4de22f60b989dcf0f0d7436978c0b463d5827 /drivers/watchdog
parenteee7631fdf8ae63c4f24daf66981ac1a7b55d7fd (diff)
parent6aba74f2791287ec407e0f92487a725a25908067 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 into sh-latest
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/davinci_wdt.c22
-rw-r--r--drivers/watchdog/max63xx_wdt.c20
-rw-r--r--drivers/watchdog/nv_tco.c2
-rw-r--r--drivers/watchdog/pnx4008_wdt.c28
-rw-r--r--drivers/watchdog/s3c2410_wdt.c19
-rw-r--r--drivers/watchdog/softdog.c16
-rw-r--r--drivers/watchdog/sp5100_tco.c16
7 files changed, 67 insertions, 56 deletions
diff --git a/drivers/watchdog/davinci_wdt.c b/drivers/watchdog/davinci_wdt.c
index 596ba604e78d..51b5551b4e3f 100644
--- a/drivers/watchdog/davinci_wdt.c
+++ b/drivers/watchdog/davinci_wdt.c
@@ -202,7 +202,6 @@ static struct miscdevice davinci_wdt_miscdev = {
202static int __devinit davinci_wdt_probe(struct platform_device *pdev) 202static int __devinit davinci_wdt_probe(struct platform_device *pdev)
203{ 203{
204 int ret = 0, size; 204 int ret = 0, size;
205 struct resource *res;
206 struct device *dev = &pdev->dev; 205 struct device *dev = &pdev->dev;
207 206
208 wdt_clk = clk_get(dev, NULL); 207 wdt_clk = clk_get(dev, NULL);
@@ -216,31 +215,31 @@ static int __devinit davinci_wdt_probe(struct platform_device *pdev)
216 215
217 dev_info(dev, "heartbeat %d sec\n", heartbeat); 216 dev_info(dev, "heartbeat %d sec\n", heartbeat);
218 217
219 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 218 wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
220 if (res == NULL) { 219 if (wdt_mem == NULL) {
221 dev_err(dev, "failed to get memory region resource\n"); 220 dev_err(dev, "failed to get memory region resource\n");
222 return -ENOENT; 221 return -ENOENT;
223 } 222 }
224 223
225 size = resource_size(res); 224 size = resource_size(wdt_mem);
226 wdt_mem = request_mem_region(res->start, size, pdev->name); 225 if (!request_mem_region(wdt_mem->start, size, pdev->name)) {
227
228 if (wdt_mem == NULL) {
229 dev_err(dev, "failed to get memory region\n"); 226 dev_err(dev, "failed to get memory region\n");
230 return -ENOENT; 227 return -ENOENT;
231 } 228 }
232 229
233 wdt_base = ioremap(res->start, size); 230 wdt_base = ioremap(wdt_mem->start, size);
234 if (!wdt_base) { 231 if (!wdt_base) {
235 dev_err(dev, "failed to map memory region\n"); 232 dev_err(dev, "failed to map memory region\n");
233 release_mem_region(wdt_mem->start, size);
234 wdt_mem = NULL;
236 return -ENOMEM; 235 return -ENOMEM;
237 } 236 }
238 237
239 ret = misc_register(&davinci_wdt_miscdev); 238 ret = misc_register(&davinci_wdt_miscdev);
240 if (ret < 0) { 239 if (ret < 0) {
241 dev_err(dev, "cannot register misc device\n"); 240 dev_err(dev, "cannot register misc device\n");
242 release_resource(wdt_mem); 241 release_mem_region(wdt_mem->start, size);
243 kfree(wdt_mem); 242 wdt_mem = NULL;
244 } else { 243 } else {
245 set_bit(WDT_DEVICE_INITED, &wdt_status); 244 set_bit(WDT_DEVICE_INITED, &wdt_status);
246 } 245 }
@@ -253,8 +252,7 @@ static int __devexit davinci_wdt_remove(struct platform_device *pdev)
253{ 252{
254 misc_deregister(&davinci_wdt_miscdev); 253 misc_deregister(&davinci_wdt_miscdev);
255 if (wdt_mem) { 254 if (wdt_mem) {
256 release_resource(wdt_mem); 255 release_mem_region(wdt_mem->start, resource_size(wdt_mem));
257 kfree(wdt_mem);
258 wdt_mem = NULL; 256 wdt_mem = NULL;
259 } 257 }
260 258
diff --git a/drivers/watchdog/max63xx_wdt.c b/drivers/watchdog/max63xx_wdt.c
index 7a82ce5a6337..73ba2fd8e591 100644
--- a/drivers/watchdog/max63xx_wdt.c
+++ b/drivers/watchdog/max63xx_wdt.c
@@ -270,7 +270,6 @@ static int __devinit max63xx_wdt_probe(struct platform_device *pdev)
270{ 270{
271 int ret = 0; 271 int ret = 0;
272 int size; 272 int size;
273 struct resource *res;
274 struct device *dev = &pdev->dev; 273 struct device *dev = &pdev->dev;
275 struct max63xx_timeout *table; 274 struct max63xx_timeout *table;
276 275
@@ -294,21 +293,19 @@ static int __devinit max63xx_wdt_probe(struct platform_device *pdev)
294 293
295 max63xx_pdev = pdev; 294 max63xx_pdev = pdev;
296 295
297 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 296 wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
298 if (res == NULL) { 297 if (wdt_mem == NULL) {
299 dev_err(dev, "failed to get memory region resource\n"); 298 dev_err(dev, "failed to get memory region resource\n");
300 return -ENOENT; 299 return -ENOENT;
301 } 300 }
302 301
303 size = resource_size(res); 302 size = resource_size(wdt_mem);
304 wdt_mem = request_mem_region(res->start, size, pdev->name); 303 if (!request_mem_region(wdt_mem->start, size, pdev->name)) {
305
306 if (wdt_mem == NULL) {
307 dev_err(dev, "failed to get memory region\n"); 304 dev_err(dev, "failed to get memory region\n");
308 return -ENOENT; 305 return -ENOENT;
309 } 306 }
310 307
311 wdt_base = ioremap(res->start, size); 308 wdt_base = ioremap(wdt_mem->start, size);
312 if (!wdt_base) { 309 if (!wdt_base) {
313 dev_err(dev, "failed to map memory region\n"); 310 dev_err(dev, "failed to map memory region\n");
314 ret = -ENOMEM; 311 ret = -ENOMEM;
@@ -326,8 +323,8 @@ static int __devinit max63xx_wdt_probe(struct platform_device *pdev)
326out_unmap: 323out_unmap:
327 iounmap(wdt_base); 324 iounmap(wdt_base);
328out_request: 325out_request:
329 release_resource(wdt_mem); 326 release_mem_region(wdt_mem->start, size);
330 kfree(wdt_mem); 327 wdt_mem = NULL;
331 328
332 return ret; 329 return ret;
333} 330}
@@ -336,8 +333,7 @@ static int __devexit max63xx_wdt_remove(struct platform_device *pdev)
336{ 333{
337 misc_deregister(&max63xx_wdt_miscdev); 334 misc_deregister(&max63xx_wdt_miscdev);
338 if (wdt_mem) { 335 if (wdt_mem) {
339 release_resource(wdt_mem); 336 release_mem_region(wdt_mem->start, resource_size(wdt_mem));
340 kfree(wdt_mem);
341 wdt_mem = NULL; 337 wdt_mem = NULL;
342 } 338 }
343 339
diff --git a/drivers/watchdog/nv_tco.c b/drivers/watchdog/nv_tco.c
index 267377a5a83e..afa78a54711e 100644
--- a/drivers/watchdog/nv_tco.c
+++ b/drivers/watchdog/nv_tco.c
@@ -302,7 +302,7 @@ MODULE_DEVICE_TABLE(pci, tco_pci_tbl);
302 * Init & exit routines 302 * Init & exit routines
303 */ 303 */
304 304
305static unsigned char __init nv_tco_getdevice(void) 305static unsigned char __devinit nv_tco_getdevice(void)
306{ 306{
307 struct pci_dev *dev = NULL; 307 struct pci_dev *dev = NULL;
308 u32 val; 308 u32 val;
diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c
index c7cf4cbf8ab3..614933225560 100644
--- a/drivers/watchdog/pnx4008_wdt.c
+++ b/drivers/watchdog/pnx4008_wdt.c
@@ -254,7 +254,6 @@ static struct miscdevice pnx4008_wdt_miscdev = {
254static int __devinit pnx4008_wdt_probe(struct platform_device *pdev) 254static int __devinit pnx4008_wdt_probe(struct platform_device *pdev)
255{ 255{
256 int ret = 0, size; 256 int ret = 0, size;
257 struct resource *res;
258 257
259 if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT) 258 if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT)
260 heartbeat = DEFAULT_HEARTBEAT; 259 heartbeat = DEFAULT_HEARTBEAT;
@@ -262,42 +261,42 @@ static int __devinit pnx4008_wdt_probe(struct platform_device *pdev)
262 printk(KERN_INFO MODULE_NAME 261 printk(KERN_INFO MODULE_NAME
263 "PNX4008 Watchdog Timer: heartbeat %d sec\n", heartbeat); 262 "PNX4008 Watchdog Timer: heartbeat %d sec\n", heartbeat);
264 263
265 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 264 wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
266 if (res == NULL) { 265 if (wdt_mem == NULL) {
267 printk(KERN_INFO MODULE_NAME 266 printk(KERN_INFO MODULE_NAME
268 "failed to get memory region resouce\n"); 267 "failed to get memory region resouce\n");
269 return -ENOENT; 268 return -ENOENT;
270 } 269 }
271 270
272 size = resource_size(res); 271 size = resource_size(wdt_mem);
273 wdt_mem = request_mem_region(res->start, size, pdev->name);
274 272
275 if (wdt_mem == NULL) { 273 if (!request_mem_region(wdt_mem->start, size, pdev->name)) {
276 printk(KERN_INFO MODULE_NAME "failed to get memory region\n"); 274 printk(KERN_INFO MODULE_NAME "failed to get memory region\n");
277 return -ENOENT; 275 return -ENOENT;
278 } 276 }
279 wdt_base = (void __iomem *)IO_ADDRESS(res->start); 277 wdt_base = (void __iomem *)IO_ADDRESS(wdt_mem->start);
280 278
281 wdt_clk = clk_get(&pdev->dev, NULL); 279 wdt_clk = clk_get(&pdev->dev, NULL);
282 if (IS_ERR(wdt_clk)) { 280 if (IS_ERR(wdt_clk)) {
283 ret = PTR_ERR(wdt_clk); 281 ret = PTR_ERR(wdt_clk);
284 release_resource(wdt_mem); 282 release_mem_region(wdt_mem->start, size);
285 kfree(wdt_mem); 283 wdt_mem = NULL;
286 goto out; 284 goto out;
287 } 285 }
288 286
289 ret = clk_enable(wdt_clk); 287 ret = clk_enable(wdt_clk);
290 if (ret) { 288 if (ret) {
291 release_resource(wdt_mem); 289 release_mem_region(wdt_mem->start, size);
292 kfree(wdt_mem); 290 wdt_mem = NULL;
291 clk_put(wdt_clk);
293 goto out; 292 goto out;
294 } 293 }
295 294
296 ret = misc_register(&pnx4008_wdt_miscdev); 295 ret = misc_register(&pnx4008_wdt_miscdev);
297 if (ret < 0) { 296 if (ret < 0) {
298 printk(KERN_ERR MODULE_NAME "cannot register misc device\n"); 297 printk(KERN_ERR MODULE_NAME "cannot register misc device\n");
299 release_resource(wdt_mem); 298 release_mem_region(wdt_mem->start, size);
300 kfree(wdt_mem); 299 wdt_mem = NULL;
301 clk_disable(wdt_clk); 300 clk_disable(wdt_clk);
302 clk_put(wdt_clk); 301 clk_put(wdt_clk);
303 } else { 302 } else {
@@ -320,8 +319,7 @@ static int __devexit pnx4008_wdt_remove(struct platform_device *pdev)
320 clk_put(wdt_clk); 319 clk_put(wdt_clk);
321 320
322 if (wdt_mem) { 321 if (wdt_mem) {
323 release_resource(wdt_mem); 322 release_mem_region(wdt_mem->start, resource_size(wdt_mem));
324 kfree(wdt_mem);
325 wdt_mem = NULL; 323 wdt_mem = NULL;
326 } 324 }
327 return 0; 325 return 0;
diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c
index 25b39bf35925..f7f5aa00df60 100644
--- a/drivers/watchdog/s3c2410_wdt.c
+++ b/drivers/watchdog/s3c2410_wdt.c
@@ -402,7 +402,6 @@ static inline void s3c2410wdt_cpufreq_deregister(void)
402 402
403static int __devinit s3c2410wdt_probe(struct platform_device *pdev) 403static int __devinit s3c2410wdt_probe(struct platform_device *pdev)
404{ 404{
405 struct resource *res;
406 struct device *dev; 405 struct device *dev;
407 unsigned int wtcon; 406 unsigned int wtcon;
408 int started = 0; 407 int started = 0;
@@ -416,20 +415,19 @@ static int __devinit s3c2410wdt_probe(struct platform_device *pdev)
416 415
417 /* get the memory region for the watchdog timer */ 416 /* get the memory region for the watchdog timer */
418 417
419 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 418 wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
420 if (res == NULL) { 419 if (wdt_mem == NULL) {
421 dev_err(dev, "no memory resource specified\n"); 420 dev_err(dev, "no memory resource specified\n");
422 return -ENOENT; 421 return -ENOENT;
423 } 422 }
424 423
425 size = resource_size(res); 424 size = resource_size(wdt_mem);
426 wdt_mem = request_mem_region(res->start, size, pdev->name); 425 if (!request_mem_region(wdt_mem->start, size, pdev->name)) {
427 if (wdt_mem == NULL) {
428 dev_err(dev, "failed to get memory region\n"); 426 dev_err(dev, "failed to get memory region\n");
429 return -EBUSY; 427 return -EBUSY;
430 } 428 }
431 429
432 wdt_base = ioremap(res->start, size); 430 wdt_base = ioremap(wdt_mem->start, size);
433 if (wdt_base == NULL) { 431 if (wdt_base == NULL) {
434 dev_err(dev, "failed to ioremap() region\n"); 432 dev_err(dev, "failed to ioremap() region\n");
435 ret = -EINVAL; 433 ret = -EINVAL;
@@ -524,8 +522,8 @@ static int __devinit s3c2410wdt_probe(struct platform_device *pdev)
524 iounmap(wdt_base); 522 iounmap(wdt_base);
525 523
526 err_req: 524 err_req:
527 release_resource(wdt_mem); 525 release_mem_region(wdt_mem->start, size);
528 kfree(wdt_mem); 526 wdt_mem = NULL;
529 527
530 return ret; 528 return ret;
531} 529}
@@ -545,8 +543,7 @@ static int __devexit s3c2410wdt_remove(struct platform_device *dev)
545 543
546 iounmap(wdt_base); 544 iounmap(wdt_base);
547 545
548 release_resource(wdt_mem); 546 release_mem_region(wdt_mem->start, resource_size(wdt_mem));
549 kfree(wdt_mem);
550 wdt_mem = NULL; 547 wdt_mem = NULL;
551 return 0; 548 return 0;
552} 549}
diff --git a/drivers/watchdog/softdog.c b/drivers/watchdog/softdog.c
index 100b114e3c3c..bf16ffb4d21e 100644
--- a/drivers/watchdog/softdog.c
+++ b/drivers/watchdog/softdog.c
@@ -48,6 +48,7 @@
48#include <linux/init.h> 48#include <linux/init.h>
49#include <linux/jiffies.h> 49#include <linux/jiffies.h>
50#include <linux/uaccess.h> 50#include <linux/uaccess.h>
51#include <linux/kernel.h>
51 52
52#define PFX "SoftDog: " 53#define PFX "SoftDog: "
53 54
@@ -75,6 +76,11 @@ MODULE_PARM_DESC(soft_noboot,
75 "Softdog action, set to 1 to ignore reboots, 0 to reboot " 76 "Softdog action, set to 1 to ignore reboots, 0 to reboot "
76 "(default depends on ONLY_TESTING)"); 77 "(default depends on ONLY_TESTING)");
77 78
79static int soft_panic;
80module_param(soft_panic, int, 0);
81MODULE_PARM_DESC(soft_panic,
82 "Softdog action, set to 1 to panic, 0 to reboot (default=0)");
83
78/* 84/*
79 * Our timer 85 * Our timer
80 */ 86 */
@@ -98,7 +104,10 @@ static void watchdog_fire(unsigned long data)
98 104
99 if (soft_noboot) 105 if (soft_noboot)
100 printk(KERN_CRIT PFX "Triggered - Reboot ignored.\n"); 106 printk(KERN_CRIT PFX "Triggered - Reboot ignored.\n");
101 else { 107 else if (soft_panic) {
108 printk(KERN_CRIT PFX "Initiating panic.\n");
109 panic("Software Watchdog Timer expired.");
110 } else {
102 printk(KERN_CRIT PFX "Initiating system reboot.\n"); 111 printk(KERN_CRIT PFX "Initiating system reboot.\n");
103 emergency_restart(); 112 emergency_restart();
104 printk(KERN_CRIT PFX "Reboot didn't ?????\n"); 113 printk(KERN_CRIT PFX "Reboot didn't ?????\n");
@@ -267,7 +276,8 @@ static struct notifier_block softdog_notifier = {
267}; 276};
268 277
269static char banner[] __initdata = KERN_INFO "Software Watchdog Timer: 0.07 " 278static char banner[] __initdata = KERN_INFO "Software Watchdog Timer: 0.07 "
270 "initialized. soft_noboot=%d soft_margin=%d sec (nowayout= %d)\n"; 279 "initialized. soft_noboot=%d soft_margin=%d sec soft_panic=%d "
280 "(nowayout= %d)\n";
271 281
272static int __init watchdog_init(void) 282static int __init watchdog_init(void)
273{ 283{
@@ -298,7 +308,7 @@ static int __init watchdog_init(void)
298 return ret; 308 return ret;
299 } 309 }
300 310
301 printk(banner, soft_noboot, soft_margin, nowayout); 311 printk(banner, soft_noboot, soft_margin, soft_panic, nowayout);
302 312
303 return 0; 313 return 0;
304} 314}
diff --git a/drivers/watchdog/sp5100_tco.c b/drivers/watchdog/sp5100_tco.c
index 1bc493848ed4..87e0527669d8 100644
--- a/drivers/watchdog/sp5100_tco.c
+++ b/drivers/watchdog/sp5100_tco.c
@@ -42,6 +42,7 @@
42#define PFX TCO_MODULE_NAME ": " 42#define PFX TCO_MODULE_NAME ": "
43 43
44/* internal variables */ 44/* internal variables */
45static u32 tcobase_phys;
45static void __iomem *tcobase; 46static void __iomem *tcobase;
46static unsigned int pm_iobase; 47static unsigned int pm_iobase;
47static DEFINE_SPINLOCK(tco_lock); /* Guards the hardware */ 48static DEFINE_SPINLOCK(tco_lock); /* Guards the hardware */
@@ -305,10 +306,18 @@ static unsigned char __devinit sp5100_tco_setupdevice(void)
305 /* Low three bits of BASE0 are reserved. */ 306 /* Low three bits of BASE0 are reserved. */
306 val = val << 8 | (inb(SP5100_IO_PM_DATA_REG) & 0xf8); 307 val = val << 8 | (inb(SP5100_IO_PM_DATA_REG) & 0xf8);
307 308
309 if (!request_mem_region_exclusive(val, SP5100_WDT_MEM_MAP_SIZE,
310 "SP5100 TCO")) {
311 printk(KERN_ERR PFX "mmio address 0x%04x already in use\n",
312 val);
313 goto unreg_region;
314 }
315 tcobase_phys = val;
316
308 tcobase = ioremap(val, SP5100_WDT_MEM_MAP_SIZE); 317 tcobase = ioremap(val, SP5100_WDT_MEM_MAP_SIZE);
309 if (tcobase == 0) { 318 if (tcobase == 0) {
310 printk(KERN_ERR PFX "failed to get tcobase address\n"); 319 printk(KERN_ERR PFX "failed to get tcobase address\n");
311 goto unreg_region; 320 goto unreg_mem_region;
312 } 321 }
313 322
314 /* Enable watchdog decode bit */ 323 /* Enable watchdog decode bit */
@@ -346,7 +355,8 @@ static unsigned char __devinit sp5100_tco_setupdevice(void)
346 /* Done */ 355 /* Done */
347 return 1; 356 return 1;
348 357
349 iounmap(tcobase); 358unreg_mem_region:
359 release_mem_region(tcobase_phys, SP5100_WDT_MEM_MAP_SIZE);
350unreg_region: 360unreg_region:
351 release_region(pm_iobase, SP5100_PM_IOPORTS_SIZE); 361 release_region(pm_iobase, SP5100_PM_IOPORTS_SIZE);
352exit: 362exit:
@@ -401,6 +411,7 @@ static int __devinit sp5100_tco_init(struct platform_device *dev)
401 411
402exit: 412exit:
403 iounmap(tcobase); 413 iounmap(tcobase);
414 release_mem_region(tcobase_phys, SP5100_WDT_MEM_MAP_SIZE);
404 release_region(pm_iobase, SP5100_PM_IOPORTS_SIZE); 415 release_region(pm_iobase, SP5100_PM_IOPORTS_SIZE);
405 return ret; 416 return ret;
406} 417}
@@ -414,6 +425,7 @@ static void __devexit sp5100_tco_cleanup(void)
414 /* Deregister */ 425 /* Deregister */
415 misc_deregister(&sp5100_tco_miscdev); 426 misc_deregister(&sp5100_tco_miscdev);
416 iounmap(tcobase); 427 iounmap(tcobase);
428 release_mem_region(tcobase_phys, SP5100_WDT_MEM_MAP_SIZE);
417 release_region(pm_iobase, SP5100_PM_IOPORTS_SIZE); 429 release_region(pm_iobase, SP5100_PM_IOPORTS_SIZE);
418} 430}
419 431