Commit 87e7d520 authored by Jingoo Han's avatar Jingoo Han Committed by Linus Torvalds

rtc: rtc-bfin: 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 9d42e465
...@@ -352,14 +352,14 @@ static int bfin_rtc_probe(struct platform_device *pdev) ...@@ -352,14 +352,14 @@ static int bfin_rtc_probe(struct platform_device *pdev)
dev_dbg_stamp(dev); dev_dbg_stamp(dev);
/* Allocate memory for our RTC struct */ /* Allocate memory for our RTC struct */
rtc = kzalloc(sizeof(*rtc), GFP_KERNEL); rtc = devm_kzalloc(dev, sizeof(*rtc), GFP_KERNEL);
if (unlikely(!rtc)) if (unlikely(!rtc))
return -ENOMEM; return -ENOMEM;
platform_set_drvdata(pdev, rtc); platform_set_drvdata(pdev, rtc);
device_init_wakeup(dev, 1); device_init_wakeup(dev, 1);
/* Register our RTC with the RTC framework */ /* Register our RTC with the RTC framework */
rtc->rtc_dev = rtc_device_register(pdev->name, dev, &bfin_rtc_ops, rtc->rtc_dev = devm_rtc_device_register(dev, pdev->name, &bfin_rtc_ops,
THIS_MODULE); THIS_MODULE);
if (unlikely(IS_ERR(rtc->rtc_dev))) { if (unlikely(IS_ERR(rtc->rtc_dev))) {
ret = PTR_ERR(rtc->rtc_dev); ret = PTR_ERR(rtc->rtc_dev);
...@@ -367,9 +367,10 @@ static int bfin_rtc_probe(struct platform_device *pdev) ...@@ -367,9 +367,10 @@ static int bfin_rtc_probe(struct platform_device *pdev)
} }
/* Grab the IRQ and init the hardware */ /* Grab the IRQ and init the hardware */
ret = request_irq(IRQ_RTC, bfin_rtc_interrupt, 0, pdev->name, dev); ret = devm_request_irq(dev, IRQ_RTC, bfin_rtc_interrupt, 0,
pdev->name, dev);
if (unlikely(ret)) if (unlikely(ret))
goto err_reg; goto err;
/* sometimes the bootloader touched things, but the write complete was not /* sometimes the bootloader touched things, but the write complete was not
* enabled, so let's just do a quick timeout here since the IRQ will not fire ... * enabled, so let's just do a quick timeout here since the IRQ will not fire ...
*/ */
...@@ -381,23 +382,16 @@ static int bfin_rtc_probe(struct platform_device *pdev) ...@@ -381,23 +382,16 @@ static int bfin_rtc_probe(struct platform_device *pdev)
return 0; return 0;
err_reg:
rtc_device_unregister(rtc->rtc_dev);
err: err:
kfree(rtc);
return ret; return ret;
} }
static int bfin_rtc_remove(struct platform_device *pdev) static int bfin_rtc_remove(struct platform_device *pdev)
{ {
struct bfin_rtc *rtc = platform_get_drvdata(pdev);
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
bfin_rtc_reset(dev, 0); bfin_rtc_reset(dev, 0);
free_irq(IRQ_RTC, dev);
rtc_device_unregister(rtc->rtc_dev);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
kfree(rtc);
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