diff options
author | Jingoo Han <jg1.han@samsung.com> | 2013-01-09 21:06:33 -0500 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2013-03-01 06:45:34 -0500 |
commit | 04ecc7dc8ee62580d7c2f039bfb6eab41e8b2a7d (patch) | |
tree | 9516c5bf62978a9619e9e193b3f8153610d2f9dd /drivers/watchdog/s3c2410_wdt.c | |
parent | e4504daba1d9391968df4698406bb81318b340a0 (diff) |
watchdog: s3c2410_wdt: Use devm_* functions
Use devm_* functions to make cleanup paths more simple.
Signed-off-by: Jingoo Han <jg1.han@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 | 42 |
1 files changed, 9 insertions, 33 deletions
diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index 27bcd4e2c4a4..6419c61594fd 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c | |||
@@ -309,7 +309,6 @@ static int s3c2410wdt_probe(struct platform_device *pdev) | |||
309 | unsigned int wtcon; | 309 | unsigned int wtcon; |
310 | int started = 0; | 310 | int started = 0; |
311 | int ret; | 311 | int ret; |
312 | int size; | ||
313 | 312 | ||
314 | DBG("%s: probe=%p\n", __func__, pdev); | 313 | DBG("%s: probe=%p\n", __func__, pdev); |
315 | 314 | ||
@@ -330,28 +329,20 @@ static int s3c2410wdt_probe(struct platform_device *pdev) | |||
330 | } | 329 | } |
331 | 330 | ||
332 | /* get the memory region for the watchdog timer */ | 331 | /* get the memory region for the watchdog timer */ |
333 | 332 | wdt_base = devm_request_and_ioremap(dev, wdt_mem); | |
334 | size = resource_size(wdt_mem); | ||
335 | if (!request_mem_region(wdt_mem->start, size, pdev->name)) { | ||
336 | dev_err(dev, "failed to get memory region\n"); | ||
337 | ret = -EBUSY; | ||
338 | goto err; | ||
339 | } | ||
340 | |||
341 | wdt_base = ioremap(wdt_mem->start, size); | ||
342 | if (wdt_base == NULL) { | 333 | if (wdt_base == NULL) { |
343 | dev_err(dev, "failed to ioremap() region\n"); | 334 | dev_err(dev, "failed to devm_request_and_ioremap() region\n"); |
344 | ret = -EINVAL; | 335 | ret = -ENOMEM; |
345 | goto err_req; | 336 | goto err; |
346 | } | 337 | } |
347 | 338 | ||
348 | DBG("probe: mapped wdt_base=%p\n", wdt_base); | 339 | DBG("probe: mapped wdt_base=%p\n", wdt_base); |
349 | 340 | ||
350 | wdt_clock = clk_get(&pdev->dev, "watchdog"); | 341 | wdt_clock = devm_clk_get(dev, "watchdog"); |
351 | if (IS_ERR(wdt_clock)) { | 342 | if (IS_ERR(wdt_clock)) { |
352 | dev_err(dev, "failed to find watchdog clock source\n"); | 343 | dev_err(dev, "failed to find watchdog clock source\n"); |
353 | ret = PTR_ERR(wdt_clock); | 344 | ret = PTR_ERR(wdt_clock); |
354 | goto err_map; | 345 | goto err; |
355 | } | 346 | } |
356 | 347 | ||
357 | clk_prepare_enable(wdt_clock); | 348 | clk_prepare_enable(wdt_clock); |
@@ -378,7 +369,8 @@ static int s3c2410wdt_probe(struct platform_device *pdev) | |||
378 | "cannot start\n"); | 369 | "cannot start\n"); |
379 | } | 370 | } |
380 | 371 | ||
381 | ret = request_irq(wdt_irq->start, s3c2410wdt_irq, 0, pdev->name, pdev); | 372 | ret = devm_request_irq(dev, wdt_irq->start, s3c2410wdt_irq, 0, |
373 | pdev->name, pdev); | ||
382 | if (ret != 0) { | 374 | if (ret != 0) { |
383 | dev_err(dev, "failed to install irq (%d)\n", ret); | 375 | dev_err(dev, "failed to install irq (%d)\n", ret); |
384 | goto err_cpufreq; | 376 | goto err_cpufreq; |
@@ -389,7 +381,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev) | |||
389 | ret = watchdog_register_device(&s3c2410_wdd); | 381 | ret = watchdog_register_device(&s3c2410_wdd); |
390 | if (ret) { | 382 | if (ret) { |
391 | dev_err(dev, "cannot register watchdog (%d)\n", ret); | 383 | dev_err(dev, "cannot register watchdog (%d)\n", ret); |
392 | goto err_irq; | 384 | goto err_cpufreq; |
393 | } | 385 | } |
394 | 386 | ||
395 | if (tmr_atboot && started == 0) { | 387 | if (tmr_atboot && started == 0) { |
@@ -414,23 +406,13 @@ static int s3c2410wdt_probe(struct platform_device *pdev) | |||
414 | 406 | ||
415 | return 0; | 407 | return 0; |
416 | 408 | ||
417 | err_irq: | ||
418 | free_irq(wdt_irq->start, pdev); | ||
419 | |||
420 | err_cpufreq: | 409 | err_cpufreq: |
421 | s3c2410wdt_cpufreq_deregister(); | 410 | s3c2410wdt_cpufreq_deregister(); |
422 | 411 | ||
423 | err_clk: | 412 | err_clk: |
424 | clk_disable_unprepare(wdt_clock); | 413 | clk_disable_unprepare(wdt_clock); |
425 | clk_put(wdt_clock); | ||
426 | wdt_clock = NULL; | 414 | wdt_clock = NULL; |
427 | 415 | ||
428 | err_map: | ||
429 | iounmap(wdt_base); | ||
430 | |||
431 | err_req: | ||
432 | release_mem_region(wdt_mem->start, size); | ||
433 | |||
434 | err: | 416 | err: |
435 | wdt_irq = NULL; | 417 | wdt_irq = NULL; |
436 | wdt_mem = NULL; | 418 | wdt_mem = NULL; |
@@ -441,17 +423,11 @@ static int s3c2410wdt_remove(struct platform_device *dev) | |||
441 | { | 423 | { |
442 | watchdog_unregister_device(&s3c2410_wdd); | 424 | watchdog_unregister_device(&s3c2410_wdd); |
443 | 425 | ||
444 | free_irq(wdt_irq->start, dev); | ||
445 | |||
446 | s3c2410wdt_cpufreq_deregister(); | 426 | s3c2410wdt_cpufreq_deregister(); |
447 | 427 | ||
448 | clk_disable_unprepare(wdt_clock); | 428 | clk_disable_unprepare(wdt_clock); |
449 | clk_put(wdt_clock); | ||
450 | wdt_clock = NULL; | 429 | wdt_clock = NULL; |
451 | 430 | ||
452 | iounmap(wdt_base); | ||
453 | |||
454 | release_mem_region(wdt_mem->start, resource_size(wdt_mem)); | ||
455 | wdt_irq = NULL; | 431 | wdt_irq = NULL; |
456 | wdt_mem = NULL; | 432 | wdt_mem = NULL; |
457 | return 0; | 433 | return 0; |