Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jingoo Han and committed by
Linus Torvalds
c417299c 19b8d887

+8 -19
+8 -19
drivers/rtc/rtc-pm8xxx.c
··· 395 395 if (pdata != NULL) 396 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 399 if (rtc_dd == NULL) { 400 400 dev_err(&pdev->dev, "Unable to allocate memory!\n"); 401 401 return -ENOMEM; ··· 407 407 rtc_dd->rtc_alarm_irq = platform_get_irq(pdev, 0); 408 408 if (rtc_dd->rtc_alarm_irq < 0) { 409 409 dev_err(&pdev->dev, "Alarm IRQ resource absent!\n"); 410 - rc = -ENXIO; 411 - goto fail_rtc_enable; 410 + return -ENXIO; 412 411 } 413 412 414 413 rtc_resource = platform_get_resource_byname(pdev, IORESOURCE_IO, 415 414 "pmic_rtc_base"); 416 415 if (!(rtc_resource && rtc_resource->start)) { 417 416 dev_err(&pdev->dev, "RTC IO resource absent!\n"); 418 - rc = -ENXIO; 419 - goto fail_rtc_enable; 417 + return -ENXIO; 420 418 } 421 419 422 420 rtc_dd->rtc_base = rtc_resource->start; ··· 430 432 rc = pm8xxx_read_wrapper(rtc_dd, &ctrl_reg, rtc_dd->rtc_base, 1); 431 433 if (rc < 0) { 432 434 dev_err(&pdev->dev, "RTC control register read failed!\n"); 433 - goto fail_rtc_enable; 435 + return rc; 434 436 } 435 437 436 438 if (!(ctrl_reg & PM8xxx_RTC_ENABLE)) { ··· 440 442 if (rc < 0) { 441 443 dev_err(&pdev->dev, "Write to RTC control register " 442 444 "failed\n"); 443 - goto fail_rtc_enable; 445 + return rc; 444 446 } 445 447 } 446 448 ··· 451 453 platform_set_drvdata(pdev, rtc_dd); 452 454 453 455 /* Register the RTC device */ 454 - rtc_dd->rtc = rtc_device_register("pm8xxx_rtc", &pdev->dev, 456 + rtc_dd->rtc = devm_rtc_device_register(&pdev->dev, "pm8xxx_rtc", 455 457 &pm8xxx_rtc_ops, THIS_MODULE); 456 458 if (IS_ERR(rtc_dd->rtc)) { 457 459 dev_err(&pdev->dev, "%s: RTC registration failed (%ld)\n", 458 460 __func__, PTR_ERR(rtc_dd->rtc)); 459 - rc = PTR_ERR(rtc_dd->rtc); 460 - goto fail_rtc_enable; 461 + return PTR_ERR(rtc_dd->rtc); 461 462 } 462 463 463 464 /* Request the alarm IRQ */ ··· 465 468 "pm8xxx_rtc_alarm", rtc_dd); 466 469 if (rc < 0) { 467 470 dev_err(&pdev->dev, "Request IRQ failed (%d)\n", rc); 468 - goto fail_req_irq; 471 + return rc; 469 472 } 470 473 471 474 device_init_wakeup(&pdev->dev, 1); ··· 473 476 dev_dbg(&pdev->dev, "Probe success !!\n"); 474 477 475 478 return 0; 476 - 477 - fail_req_irq: 478 - rtc_device_unregister(rtc_dd->rtc); 479 - fail_rtc_enable: 480 - kfree(rtc_dd); 481 - return rc; 482 479 } 483 480 484 481 static int pm8xxx_rtc_remove(struct platform_device *pdev) ··· 481 490 482 491 device_init_wakeup(&pdev->dev, 0); 483 492 free_irq(rtc_dd->rtc_alarm_irq, rtc_dd); 484 - rtc_device_unregister(rtc_dd->rtc); 485 - kfree(rtc_dd); 486 493 487 494 return 0; 488 495 }