From: Jingoo Han <jg1.han@samsung.com>
To: "'Andrew Morton'" <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org,
"'Alessandro Zummo'" <a.zummo@towertech.it>,
rtc-linux@googlegroups.com, "'Jingoo Han'" <jg1.han@samsung.com>
Subject: [PATCH 21/27] rtc: rtc-rp5c01: use devm_*() functions
Date: Mon, 01 Apr 2013 18:48:58 +0900 [thread overview]
Message-ID: <002001ce2ebe$21f102b0$65d30810$%han@samsung.com> (raw)
In-Reply-To: <000c01ce2ebd$2a1307f0$7e3917d0$%han@samsung.com>
Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/rtc/rtc-rp5c01.c | 26 ++++++++------------------
1 files changed, 8 insertions(+), 18 deletions(-)
diff --git a/drivers/rtc/rtc-rp5c01.c b/drivers/rtc/rtc-rp5c01.c
index d25d2f6..873c689 100644
--- a/drivers/rtc/rtc-rp5c01.c
+++ b/drivers/rtc/rtc-rp5c01.c
@@ -230,15 +230,13 @@ static int __init rp5c01_rtc_probe(struct platform_device *dev)
if (!res)
return -ENODEV;
- priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
- priv->regs = ioremap(res->start, resource_size(res));
- if (!priv->regs) {
- error = -ENOMEM;
- goto out_free_priv;
- }
+ priv->regs = devm_ioremap(&dev->dev, res->start, resource_size(res));
+ if (!priv->regs)
+ return -ENOMEM;
sysfs_bin_attr_init(&priv->nvram_attr);
priv->nvram_attr.attr.name = "nvram";
@@ -251,27 +249,22 @@ static int __init rp5c01_rtc_probe(struct platform_device *dev)
platform_set_drvdata(dev, priv);
- rtc = rtc_device_register("rtc-rp5c01", &dev->dev, &rp5c01_rtc_ops,
+ rtc = devm_rtc_device_register(&dev->dev, "rtc-rp5c01", &rp5c01_rtc_ops,
THIS_MODULE);
if (IS_ERR(rtc)) {
error = PTR_ERR(rtc);
- goto out_unmap;
+ goto out;
}
priv->rtc = rtc;
error = sysfs_create_bin_file(&dev->dev.kobj, &priv->nvram_attr);
if (error)
- goto out_unregister;
+ goto out;
return 0;
-out_unregister:
- rtc_device_unregister(rtc);
-out_unmap:
+out:
platform_set_drvdata(dev, NULL);
- iounmap(priv->regs);
-out_free_priv:
- kfree(priv);
return error;
}
@@ -280,9 +273,6 @@ static int __exit rp5c01_rtc_remove(struct platform_device *dev)
struct rp5c01_priv *priv = platform_get_drvdata(dev);
sysfs_remove_bin_file(&dev->dev.kobj, &priv->nvram_attr);
- rtc_device_unregister(priv->rtc);
- iounmap(priv->regs);
- kfree(priv);
return 0;
}
--
1.7.2.5
next prev parent reply other threads:[~2013-04-01 9:49 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-01 9:42 [PATCH 01/27] rtc: rtc-ab8500: " Jingoo Han
2013-04-01 9:42 ` [PATCH 02/27] rtc: rtc-at91sam9: " Jingoo Han
2013-04-01 9:43 ` [PATCH 03/27] rtc: rtc-bfin: " Jingoo Han
2013-04-01 9:43 ` [PATCH 04/27] rtc: rtc-bq4802: " Jingoo Han
2013-04-01 9:43 ` [PATCH 05/27] rtc: rtc-ds1216: " Jingoo Han
2013-04-01 9:44 ` [PATCH 06/27] rtc: rtc-ds1286: " Jingoo Han
2013-04-01 9:44 ` [PATCH 07/27] rtc: rtc-ds1390: " Jingoo Han
2013-04-01 9:44 ` [PATCH 08/27] rtc: rtc-ds2404: " Jingoo Han
2013-04-01 9:45 ` [PATCH 09/27] rtc: rtc-fm3130: " Jingoo Han
2013-04-01 9:45 ` [PATCH 10/27] rtc: rtc-isl12022: " Jingoo Han
2013-04-01 9:45 ` [PATCH 11/27] rtc: rtc-m41t80: " Jingoo Han
2013-04-01 9:46 ` [PATCH 12/27] rtc: rtc-max8998: " Jingoo Han
2013-04-01 9:46 ` [PATCH 13/27] rtc: rtc-mc13xxx: " Jingoo Han
2013-04-01 9:46 ` [PATCH 14/27] rtc: rtc-msm6242: " Jingoo Han
2013-04-01 9:47 ` [PATCH 15/27] rtc: rtc-nuc900: " Jingoo Han
2013-04-01 9:47 ` [PATCH 16/27] rtc: rtc-pcap: " Jingoo Han
2013-04-01 9:47 ` [PATCH 17/27] rtc: rtc-pcf2123: " Jingoo Han
2013-04-01 9:48 ` [PATCH 18/27] rtc: rtc-pcf50633: " Jingoo Han
2013-04-01 9:48 ` [PATCH 19/27] rtc: rtc-pcf8563: " Jingoo Han
2013-04-01 9:48 ` [PATCH 20/27] rtc: rtc-pcf8583: " Jingoo Han
2013-04-01 9:48 ` Jingoo Han [this message]
2013-04-01 9:49 ` [PATCH 22/27] rtc: rtc-rs5c348: " Jingoo Han
2013-04-01 9:49 ` [PATCH 23/27] rtc: rtc-rs5c372: " Jingoo Han
2013-04-01 9:49 ` [PATCH 24/27] rtc: rtc-s35390a: " Jingoo Han
2013-04-01 9:50 ` [PATCH 25/27] rtc: rtc-sa1100: " Jingoo Han
2013-04-01 9:50 ` [PATCH 26/27] rtc: rtc-stmp3xxx: " Jingoo Han
2013-04-01 9:50 ` [PATCH 27/27] rtc: rtc-v3020: " Jingoo Han
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='002001ce2ebe$21f102b0$65d30810$%han@samsung.com' \
--to=jg1.han@samsung.com \
--cc=a.zummo@towertech.it \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rtc-linux@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome