diff options
author | MyungJoo Ham <myungjoo.ham@samsung.com> | 2012-01-13 00:14:23 -0500 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2012-02-28 11:08:42 -0500 |
commit | 78d3e00bb0bcfb11596b14f5d5472922b4c7e429 (patch) | |
tree | 77383ee603f6cbe195475cfc43279faade8b431e /drivers/watchdog/s3c2410_wdt.c | |
parent | 97d2a10d5804d585ab0b58efbd710948401b886a (diff) |
watchdog: fix error in probe() of s3c2410_wdt (reset at booting)
Probe function of s3c2410 watchdog calls request_irq before initializing
required value (wdt_count). This incurs resetting watchdog counter value
and watchdog-reboot during booting up.
This patch addresses such an issue by calling request_irq later.
Error handling in probe function and calling oder in remove function are
also revised accordingly.
Reported-by: Chanwoo Park <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog/s3c2410_wdt.c')
-rw-r--r-- | drivers/watchdog/s3c2410_wdt.c | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index 4bc3744e14e4..404172f02c9b 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c | |||
@@ -312,18 +312,26 @@ static int __devinit s3c2410wdt_probe(struct platform_device *pdev) | |||
312 | dev = &pdev->dev; | 312 | dev = &pdev->dev; |
313 | wdt_dev = &pdev->dev; | 313 | wdt_dev = &pdev->dev; |
314 | 314 | ||
315 | /* get the memory region for the watchdog timer */ | ||
316 | |||
317 | wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 315 | wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
318 | if (wdt_mem == NULL) { | 316 | if (wdt_mem == NULL) { |
319 | dev_err(dev, "no memory resource specified\n"); | 317 | dev_err(dev, "no memory resource specified\n"); |
320 | return -ENOENT; | 318 | return -ENOENT; |
321 | } | 319 | } |
322 | 320 | ||
321 | wdt_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
322 | if (wdt_irq == NULL) { | ||
323 | dev_err(dev, "no irq resource specified\n"); | ||
324 | ret = -ENOENT; | ||
325 | goto err; | ||
326 | } | ||
327 | |||
328 | /* get the memory region for the watchdog timer */ | ||
329 | |||
323 | size = resource_size(wdt_mem); | 330 | size = resource_size(wdt_mem); |
324 | if (!request_mem_region(wdt_mem->start, size, pdev->name)) { | 331 | if (!request_mem_region(wdt_mem->start, size, pdev->name)) { |
325 | dev_err(dev, "failed to get memory region\n"); | 332 | dev_err(dev, "failed to get memory region\n"); |
326 | return -EBUSY; | 333 | ret = -EBUSY; |
334 | goto err; | ||
327 | } | 335 | } |
328 | 336 | ||
329 | wdt_base = ioremap(wdt_mem->start, size); | 337 | wdt_base = ioremap(wdt_mem->start, size); |
@@ -335,29 +343,17 @@ static int __devinit s3c2410wdt_probe(struct platform_device *pdev) | |||
335 | 343 | ||
336 | DBG("probe: mapped wdt_base=%p\n", wdt_base); | 344 | DBG("probe: mapped wdt_base=%p\n", wdt_base); |
337 | 345 | ||
338 | wdt_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
339 | if (wdt_irq == NULL) { | ||
340 | dev_err(dev, "no irq resource specified\n"); | ||
341 | ret = -ENOENT; | ||
342 | goto err_map; | ||
343 | } | ||
344 | |||
345 | ret = request_irq(wdt_irq->start, s3c2410wdt_irq, 0, pdev->name, pdev); | ||
346 | if (ret != 0) { | ||
347 | dev_err(dev, "failed to install irq (%d)\n", ret); | ||
348 | goto err_map; | ||
349 | } | ||
350 | |||
351 | wdt_clock = clk_get(&pdev->dev, "watchdog"); | 346 | wdt_clock = clk_get(&pdev->dev, "watchdog"); |
352 | if (IS_ERR(wdt_clock)) { | 347 | if (IS_ERR(wdt_clock)) { |
353 | dev_err(dev, "failed to find watchdog clock source\n"); | 348 | dev_err(dev, "failed to find watchdog clock source\n"); |
354 | ret = PTR_ERR(wdt_clock); | 349 | ret = PTR_ERR(wdt_clock); |
355 | goto err_irq; | 350 | goto err_map; |
356 | } | 351 | } |
357 | 352 | ||
358 | clk_enable(wdt_clock); | 353 | clk_enable(wdt_clock); |
359 | 354 | ||
360 | if (s3c2410wdt_cpufreq_register() < 0) { | 355 | ret = s3c2410wdt_cpufreq_register(); |
356 | if (ret < 0) { | ||
361 | printk(KERN_ERR PFX "failed to register cpufreq\n"); | 357 | printk(KERN_ERR PFX "failed to register cpufreq\n"); |
362 | goto err_clk; | 358 | goto err_clk; |
363 | } | 359 | } |
@@ -378,12 +374,18 @@ static int __devinit s3c2410wdt_probe(struct platform_device *pdev) | |||
378 | "cannot start\n"); | 374 | "cannot start\n"); |
379 | } | 375 | } |
380 | 376 | ||
377 | ret = request_irq(wdt_irq->start, s3c2410wdt_irq, 0, pdev->name, pdev); | ||
378 | if (ret != 0) { | ||
379 | dev_err(dev, "failed to install irq (%d)\n", ret); | ||
380 | goto err_cpufreq; | ||
381 | } | ||
382 | |||
381 | watchdog_set_nowayout(&s3c2410_wdd, nowayout); | 383 | watchdog_set_nowayout(&s3c2410_wdd, nowayout); |
382 | 384 | ||
383 | ret = watchdog_register_device(&s3c2410_wdd); | 385 | ret = watchdog_register_device(&s3c2410_wdd); |
384 | if (ret) { | 386 | if (ret) { |
385 | dev_err(dev, "cannot register watchdog (%d)\n", ret); | 387 | dev_err(dev, "cannot register watchdog (%d)\n", ret); |
386 | goto err_cpufreq; | 388 | goto err_irq; |
387 | } | 389 | } |
388 | 390 | ||
389 | if (tmr_atboot && started == 0) { | 391 | if (tmr_atboot && started == 0) { |
@@ -408,23 +410,26 @@ static int __devinit s3c2410wdt_probe(struct platform_device *pdev) | |||
408 | 410 | ||
409 | return 0; | 411 | return 0; |
410 | 412 | ||
413 | err_irq: | ||
414 | free_irq(wdt_irq->start, pdev); | ||
415 | |||
411 | err_cpufreq: | 416 | err_cpufreq: |
412 | s3c2410wdt_cpufreq_deregister(); | 417 | s3c2410wdt_cpufreq_deregister(); |
413 | 418 | ||
414 | err_clk: | 419 | err_clk: |
415 | clk_disable(wdt_clock); | 420 | clk_disable(wdt_clock); |
416 | clk_put(wdt_clock); | 421 | clk_put(wdt_clock); |
417 | 422 | wdt_clock = NULL; | |
418 | err_irq: | ||
419 | free_irq(wdt_irq->start, pdev); | ||
420 | 423 | ||
421 | err_map: | 424 | err_map: |
422 | iounmap(wdt_base); | 425 | iounmap(wdt_base); |
423 | 426 | ||
424 | err_req: | 427 | err_req: |
425 | release_mem_region(wdt_mem->start, size); | 428 | release_mem_region(wdt_mem->start, size); |
426 | wdt_mem = NULL; | ||
427 | 429 | ||
430 | err: | ||
431 | wdt_irq = NULL; | ||
432 | wdt_mem = NULL; | ||
428 | return ret; | 433 | return ret; |
429 | } | 434 | } |
430 | 435 | ||
@@ -432,18 +437,18 @@ static int __devexit s3c2410wdt_remove(struct platform_device *dev) | |||
432 | { | 437 | { |
433 | watchdog_unregister_device(&s3c2410_wdd); | 438 | watchdog_unregister_device(&s3c2410_wdd); |
434 | 439 | ||
440 | free_irq(wdt_irq->start, dev); | ||
441 | |||
435 | s3c2410wdt_cpufreq_deregister(); | 442 | s3c2410wdt_cpufreq_deregister(); |
436 | 443 | ||
437 | clk_disable(wdt_clock); | 444 | clk_disable(wdt_clock); |
438 | clk_put(wdt_clock); | 445 | clk_put(wdt_clock); |
439 | wdt_clock = NULL; | 446 | wdt_clock = NULL; |
440 | 447 | ||
441 | free_irq(wdt_irq->start, dev); | ||
442 | wdt_irq = NULL; | ||
443 | |||
444 | iounmap(wdt_base); | 448 | iounmap(wdt_base); |
445 | 449 | ||
446 | release_mem_region(wdt_mem->start, resource_size(wdt_mem)); | 450 | release_mem_region(wdt_mem->start, resource_size(wdt_mem)); |
451 | wdt_irq = NULL; | ||
447 | wdt_mem = NULL; | 452 | wdt_mem = NULL; |
448 | return 0; | 453 | return 0; |
449 | } | 454 | } |