summaryrefslogtreecommitdiff
path: root/drivers/rtc
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2013-01-21 11:22:44 +0530
committerDan Willemsen <dwillemsen@nvidia.com>2013-09-14 12:50:49 -0700
commit79f128b901e9ffec5e2a70df659cc2820d522f17 (patch)
treecb92dfee002798a269b5752c098285fb07d2d411 /drivers/rtc
parent7b782769dcad5c6c02b1cd8ffdb341bbf78c77ed (diff)
rtc: max77660: use devm_* for resource allocation
This reduces the code for freeing the resources as this allocation is managed allocation. Change-Id: I93f6b965467eab5d646f11ab471fd030484bc616 Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-on: http://git-master/r/192834 Reviewed-by: Automatic_Commit_Validation_User
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-max77660.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/rtc/rtc-max77660.c b/drivers/rtc/rtc-max77660.c
index a0150ccbd197..afbebdc9f8b9 100644
--- a/drivers/rtc/rtc-max77660.c
+++ b/drivers/rtc/rtc-max77660.c
@@ -516,18 +516,19 @@ static int max77660_rtc_preinit(struct max77660_rtc *rtc)
return 0;
}
-static int max77660_rtc_probe(struct platform_device *pdev)
+static int __devinit max77660_rtc_probe(struct platform_device *pdev)
{
struct max77660_platform_data *parent_pdata =
pdev->dev.parent->platform_data;
static struct max77660_rtc *rtc;
int ret = 0;
- rtc = kzalloc(sizeof(struct max77660_rtc), GFP_KERNEL);
+ rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL);
if (!rtc) {
- dev_err(&pdev->dev, "probe: kzalloc() failed\n");
+ dev_err(&pdev->dev, "Memory allocation failed for rtc\n");
return -ENOMEM;
}
+
rtc->shutdown_ongoing = false;
dev_set_drvdata(&pdev->dev, rtc);
rtc->dev = &pdev->dev;
@@ -536,7 +537,7 @@ static int max77660_rtc_probe(struct platform_device *pdev)
ret = max77660_rtc_preinit(rtc);
if (ret) {
dev_err(&pdev->dev, "probe: Failed to rtc preinit\n");
- goto out_kfree;
+ goto out;
}
/*
@@ -551,7 +552,7 @@ static int max77660_rtc_probe(struct platform_device *pdev)
if (IS_ERR_OR_NULL(rtc->rtc)) {
dev_err(&pdev->dev, "probe: Failed to register rtc\n");
ret = PTR_ERR(rtc->rtc);
- goto out_kfree;
+ goto out;
}
if (parent_pdata->irq_base < 0)
@@ -571,10 +572,8 @@ static int max77660_rtc_probe(struct platform_device *pdev)
return 0;
-out_kfree:
- mutex_destroy(&rtc->io_lock);
- kfree(rtc->rtc);
out:
+ mutex_destroy(&rtc->io_lock);
return ret;
}
@@ -587,7 +586,6 @@ static int __devexit max77660_rtc_remove(struct platform_device *pdev)
rtc_device_unregister(rtc->rtc);
mutex_destroy(&rtc->io_lock);
- kfree(rtc);
return 0;
}