Commit 2a444cf7 authored by Jingoo Han's avatar Jingoo Han Committed by Linus Torvalds

rtc: rtc-ds2404: use devm_*() functions

Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: default avatarJingoo Han <jg1.han@samsung.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 1ce95ba7
...@@ -228,7 +228,7 @@ static int rtc_probe(struct platform_device *pdev) ...@@ -228,7 +228,7 @@ static int rtc_probe(struct platform_device *pdev)
struct ds2404 *chip; struct ds2404 *chip;
int retval = -EBUSY; int retval = -EBUSY;
chip = kzalloc(sizeof(struct ds2404), GFP_KERNEL); chip = devm_kzalloc(&pdev->dev, sizeof(struct ds2404), GFP_KERNEL);
if (!chip) if (!chip)
return -ENOMEM; return -ENOMEM;
...@@ -244,8 +244,8 @@ static int rtc_probe(struct platform_device *pdev) ...@@ -244,8 +244,8 @@ static int rtc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, chip); platform_set_drvdata(pdev, chip);
chip->rtc = rtc_device_register("ds2404", chip->rtc = devm_rtc_device_register(&pdev->dev, "ds2404",
&pdev->dev, &ds2404_rtc_ops, THIS_MODULE); &ds2404_rtc_ops, THIS_MODULE);
if (IS_ERR(chip->rtc)) { if (IS_ERR(chip->rtc)) {
retval = PTR_ERR(chip->rtc); retval = PTR_ERR(chip->rtc);
goto err_io; goto err_io;
...@@ -257,20 +257,14 @@ static int rtc_probe(struct platform_device *pdev) ...@@ -257,20 +257,14 @@ static int rtc_probe(struct platform_device *pdev)
err_io: err_io:
chip->ops->unmap_io(chip); chip->ops->unmap_io(chip);
err_chip: err_chip:
kfree(chip);
return retval; return retval;
} }
static int rtc_remove(struct platform_device *dev) static int rtc_remove(struct platform_device *dev)
{ {
struct ds2404 *chip = platform_get_drvdata(dev); struct ds2404 *chip = platform_get_drvdata(dev);
struct rtc_device *rtc = chip->rtc;
if (rtc)
rtc_device_unregister(rtc);
chip->ops->unmap_io(chip); chip->ops->unmap_io(chip);
kfree(chip);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment