Skip to content

Commit

Permalink
rtc: rtc-sa1100: use devm_*() functions
Browse files Browse the repository at this point in the history
Use devm_*() functions to make cleanup paths simpler.

Signed-off-by: Jingoo Han <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Jingoo Han authored and torvalds committed Apr 30, 2013
1 parent b4cd3d6 commit 55d735e
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions drivers/rtc/rtc-sa1100.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,13 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
if (irq_1hz < 0 || irq_alarm < 0)
return -ENODEV;

info = kzalloc(sizeof(struct sa1100_rtc), GFP_KERNEL);
info = devm_kzalloc(&pdev->dev, sizeof(struct sa1100_rtc), GFP_KERNEL);
if (!info)
return -ENOMEM;
info->clk = clk_get(&pdev->dev, NULL);
info->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(info->clk)) {
dev_err(&pdev->dev, "failed to find rtc clock source\n");
ret = PTR_ERR(info->clk);
goto err_clk;
return PTR_ERR(info->clk);
}
info->irq_1hz = irq_1hz;
info->irq_alarm = irq_alarm;
Expand All @@ -268,8 +267,8 @@ static int sa1100_rtc_probe(struct platform_device *pdev)

device_init_wakeup(&pdev->dev, 1);

rtc = rtc_device_register(pdev->name, &pdev->dev, &sa1100_rtc_ops,
THIS_MODULE);
rtc = devm_rtc_device_register(&pdev->dev, pdev->name, &sa1100_rtc_ops,
THIS_MODULE);

if (IS_ERR(rtc)) {
ret = PTR_ERR(rtc);
Expand Down Expand Up @@ -306,9 +305,6 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
clk_disable_unprepare(info->clk);
err_enable_clk:
platform_set_drvdata(pdev, NULL);
clk_put(info->clk);
err_clk:
kfree(info);
return ret;
}

Expand All @@ -317,11 +313,8 @@ static int sa1100_rtc_remove(struct platform_device *pdev)
struct sa1100_rtc *info = platform_get_drvdata(pdev);

if (info) {
rtc_device_unregister(info->rtc);
clk_disable_unprepare(info->clk);
clk_put(info->clk);
platform_set_drvdata(pdev, NULL);
kfree(info);
}

return 0;
Expand Down

0 comments on commit 55d735e

Please sign in to comment.