[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <001001ce2ebd$6aa359f0$3fea0dd0$%han@samsung.com>
Date: Mon, 01 Apr 2013 18:43:51 +0900
From: Jingoo Han <jg1.han@...sung.com>
To: 'Andrew Morton' <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org,
'Alessandro Zummo' <a.zummo@...ertech.it>,
rtc-linux@...glegroups.com, 'Jingoo Han' <jg1.han@...sung.com>
Subject: [PATCH 05/27] rtc: rtc-ds1216: use devm_*() functions
Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@...sung.com>
---
drivers/rtc/rtc-ds1216.c | 44 +++++++++-----------------------------------
1 files changed, 9 insertions(+), 35 deletions(-)
diff --git a/drivers/rtc/rtc-ds1216.c b/drivers/rtc/rtc-ds1216.c
index 45cd8c9..c7702b7 100644
--- a/drivers/rtc/rtc-ds1216.c
+++ b/drivers/rtc/rtc-ds1216.c
@@ -30,8 +30,6 @@ struct ds1216_regs {
struct ds1216_priv {
struct rtc_device *rtc;
void __iomem *ioaddr;
- size_t size;
- unsigned long baseaddr;
};
static const u8 magic[] = {
@@ -144,57 +142,33 @@ static int __init ds1216_rtc_probe(struct platform_device *pdev)
{
struct resource *res;
struct ds1216_priv *priv;
- int ret = 0;
u8 dummy[8];
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
return -ENODEV;
- priv = kzalloc(sizeof *priv, GFP_KERNEL);
+ priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
platform_set_drvdata(pdev, priv);
- priv->size = resource_size(res);
- if (!request_mem_region(res->start, priv->size, pdev->name)) {
- ret = -EBUSY;
- goto out;
- }
- priv->baseaddr = res->start;
- priv->ioaddr = ioremap(priv->baseaddr, priv->size);
- if (!priv->ioaddr) {
- ret = -ENOMEM;
- goto out;
- }
- priv->rtc = rtc_device_register("ds1216", &pdev->dev,
- &ds1216_rtc_ops, THIS_MODULE);
- if (IS_ERR(priv->rtc)) {
- ret = PTR_ERR(priv->rtc);
- goto out;
- }
+ priv->ioaddr = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(priv->ioaddr))
+ return PTR_ERR(priv->ioaddr);
+
+ priv->rtc = devm_rtc_device_register(&pdev->dev, "ds1216",
+ &ds1216_rtc_ops, THIS_MODULE);
+ if (IS_ERR(priv->rtc))
+ return PTR_ERR(priv->rtc);
/* dummy read to get clock into a known state */
ds1216_read(priv->ioaddr, dummy);
return 0;
-
-out:
- if (priv->ioaddr)
- iounmap(priv->ioaddr);
- if (priv->baseaddr)
- release_mem_region(priv->baseaddr, priv->size);
- kfree(priv);
- return ret;
}
static int __exit ds1216_rtc_remove(struct platform_device *pdev)
{
- struct ds1216_priv *priv = platform_get_drvdata(pdev);
-
- rtc_device_unregister(priv->rtc);
- iounmap(priv->ioaddr);
- release_mem_region(priv->baseaddr, priv->size);
- kfree(priv);
return 0;
}
--
1.7.2.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists