diff options
author | Jingoo Han <jg1.han@samsung.com> | 2013-07-03 18:07:09 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-03 19:07:55 -0400 |
commit | c417299ce7d77521225f2aff471d3f7ee5f34b1e (patch) | |
tree | 6b3248a45e1bd5fd457ed9858a4764929dd2d407 | |
parent | 19b8d8875fd5f231135a55bfe53337859ec73a4a (diff) |
rtc: rtc-pm8xxx: use devm_*() functions
Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/rtc/rtc-pm8xxx.c | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index 14ee860d5a3f..03f8f75d5af2 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c | |||
@@ -395,7 +395,7 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) | |||
395 | if (pdata != NULL) | 395 | if (pdata != NULL) |
396 | rtc_write_enable = pdata->rtc_write_enable; | 396 | rtc_write_enable = pdata->rtc_write_enable; |
397 | 397 | ||
398 | rtc_dd = kzalloc(sizeof(*rtc_dd), GFP_KERNEL); | 398 | rtc_dd = devm_kzalloc(&pdev->dev, sizeof(*rtc_dd), GFP_KERNEL); |
399 | if (rtc_dd == NULL) { | 399 | if (rtc_dd == NULL) { |
400 | dev_err(&pdev->dev, "Unable to allocate memory!\n"); | 400 | dev_err(&pdev->dev, "Unable to allocate memory!\n"); |
401 | return -ENOMEM; | 401 | return -ENOMEM; |
@@ -407,16 +407,14 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) | |||
407 | rtc_dd->rtc_alarm_irq = platform_get_irq(pdev, 0); | 407 | rtc_dd->rtc_alarm_irq = platform_get_irq(pdev, 0); |
408 | if (rtc_dd->rtc_alarm_irq < 0) { | 408 | if (rtc_dd->rtc_alarm_irq < 0) { |
409 | dev_err(&pdev->dev, "Alarm IRQ resource absent!\n"); | 409 | dev_err(&pdev->dev, "Alarm IRQ resource absent!\n"); |
410 | rc = -ENXIO; | 410 | return -ENXIO; |
411 | goto fail_rtc_enable; | ||
412 | } | 411 | } |
413 | 412 | ||
414 | rtc_resource = platform_get_resource_byname(pdev, IORESOURCE_IO, | 413 | rtc_resource = platform_get_resource_byname(pdev, IORESOURCE_IO, |
415 | "pmic_rtc_base"); | 414 | "pmic_rtc_base"); |
416 | if (!(rtc_resource && rtc_resource->start)) { | 415 | if (!(rtc_resource && rtc_resource->start)) { |
417 | dev_err(&pdev->dev, "RTC IO resource absent!\n"); | 416 | dev_err(&pdev->dev, "RTC IO resource absent!\n"); |
418 | rc = -ENXIO; | 417 | return -ENXIO; |
419 | goto fail_rtc_enable; | ||
420 | } | 418 | } |
421 | 419 | ||
422 | rtc_dd->rtc_base = rtc_resource->start; | 420 | rtc_dd->rtc_base = rtc_resource->start; |
@@ -432,7 +430,7 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) | |||
432 | rc = pm8xxx_read_wrapper(rtc_dd, &ctrl_reg, rtc_dd->rtc_base, 1); | 430 | rc = pm8xxx_read_wrapper(rtc_dd, &ctrl_reg, rtc_dd->rtc_base, 1); |
433 | if (rc < 0) { | 431 | if (rc < 0) { |
434 | dev_err(&pdev->dev, "RTC control register read failed!\n"); | 432 | dev_err(&pdev->dev, "RTC control register read failed!\n"); |
435 | goto fail_rtc_enable; | 433 | return rc; |
436 | } | 434 | } |
437 | 435 | ||
438 | if (!(ctrl_reg & PM8xxx_RTC_ENABLE)) { | 436 | if (!(ctrl_reg & PM8xxx_RTC_ENABLE)) { |
@@ -442,7 +440,7 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) | |||
442 | if (rc < 0) { | 440 | if (rc < 0) { |
443 | dev_err(&pdev->dev, "Write to RTC control register " | 441 | dev_err(&pdev->dev, "Write to RTC control register " |
444 | "failed\n"); | 442 | "failed\n"); |
445 | goto fail_rtc_enable; | 443 | return rc; |
446 | } | 444 | } |
447 | } | 445 | } |
448 | 446 | ||
@@ -453,13 +451,12 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) | |||
453 | platform_set_drvdata(pdev, rtc_dd); | 451 | platform_set_drvdata(pdev, rtc_dd); |
454 | 452 | ||
455 | /* Register the RTC device */ | 453 | /* Register the RTC device */ |
456 | rtc_dd->rtc = rtc_device_register("pm8xxx_rtc", &pdev->dev, | 454 | rtc_dd->rtc = devm_rtc_device_register(&pdev->dev, "pm8xxx_rtc", |
457 | &pm8xxx_rtc_ops, THIS_MODULE); | 455 | &pm8xxx_rtc_ops, THIS_MODULE); |
458 | if (IS_ERR(rtc_dd->rtc)) { | 456 | if (IS_ERR(rtc_dd->rtc)) { |
459 | dev_err(&pdev->dev, "%s: RTC registration failed (%ld)\n", | 457 | dev_err(&pdev->dev, "%s: RTC registration failed (%ld)\n", |
460 | __func__, PTR_ERR(rtc_dd->rtc)); | 458 | __func__, PTR_ERR(rtc_dd->rtc)); |
461 | rc = PTR_ERR(rtc_dd->rtc); | 459 | return PTR_ERR(rtc_dd->rtc); |
462 | goto fail_rtc_enable; | ||
463 | } | 460 | } |
464 | 461 | ||
465 | /* Request the alarm IRQ */ | 462 | /* Request the alarm IRQ */ |
@@ -468,7 +465,7 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) | |||
468 | "pm8xxx_rtc_alarm", rtc_dd); | 465 | "pm8xxx_rtc_alarm", rtc_dd); |
469 | if (rc < 0) { | 466 | if (rc < 0) { |
470 | dev_err(&pdev->dev, "Request IRQ failed (%d)\n", rc); | 467 | dev_err(&pdev->dev, "Request IRQ failed (%d)\n", rc); |
471 | goto fail_req_irq; | 468 | return rc; |
472 | } | 469 | } |
473 | 470 | ||
474 | device_init_wakeup(&pdev->dev, 1); | 471 | device_init_wakeup(&pdev->dev, 1); |
@@ -476,12 +473,6 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) | |||
476 | dev_dbg(&pdev->dev, "Probe success !!\n"); | 473 | dev_dbg(&pdev->dev, "Probe success !!\n"); |
477 | 474 | ||
478 | return 0; | 475 | return 0; |
479 | |||
480 | fail_req_irq: | ||
481 | rtc_device_unregister(rtc_dd->rtc); | ||
482 | fail_rtc_enable: | ||
483 | kfree(rtc_dd); | ||
484 | return rc; | ||
485 | } | 476 | } |
486 | 477 | ||
487 | static int pm8xxx_rtc_remove(struct platform_device *pdev) | 478 | static int pm8xxx_rtc_remove(struct platform_device *pdev) |
@@ -490,8 +481,6 @@ static int pm8xxx_rtc_remove(struct platform_device *pdev) | |||
490 | 481 | ||
491 | device_init_wakeup(&pdev->dev, 0); | 482 | device_init_wakeup(&pdev->dev, 0); |
492 | free_irq(rtc_dd->rtc_alarm_irq, rtc_dd); | 483 | free_irq(rtc_dd->rtc_alarm_irq, rtc_dd); |
493 | rtc_device_unregister(rtc_dd->rtc); | ||
494 | kfree(rtc_dd); | ||
495 | 484 | ||
496 | return 0; | 485 | return 0; |
497 | } | 486 | } |