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 15/27] rtc: rtc-nuc900: use devm_*() functions
Date: Mon, 01 Apr 2013 18:47:06 +0900 [thread overview]
Message-ID: <001a01ce2ebd$df133e40$9d39bac0$%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-nuc900.c | 53 +++++++++------------------------------------
1 files changed, 11 insertions(+), 42 deletions(-)
diff --git a/drivers/rtc/rtc-nuc900.c b/drivers/rtc/rtc-nuc900.c
index 4d9525c..f5dfb6e 100644
--- a/drivers/rtc/rtc-nuc900.c
+++ b/drivers/rtc/rtc-nuc900.c
@@ -226,9 +226,9 @@ static int __init nuc900_rtc_probe(struct platform_device *pdev)
{
struct resource *res;
struct nuc900_rtc *nuc900_rtc;
- int err = 0;
- nuc900_rtc = kzalloc(sizeof(struct nuc900_rtc), GFP_KERNEL);
+ nuc900_rtc = devm_kzalloc(&pdev->dev, sizeof(struct nuc900_rtc),
+ GFP_KERNEL);
if (!nuc900_rtc) {
dev_err(&pdev->dev, "kzalloc nuc900_rtc failed\n");
return -ENOMEM;
@@ -236,68 +236,37 @@ static int __init nuc900_rtc_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(&pdev->dev, "platform_get_resource failed\n");
- err = -ENXIO;
- goto fail1;
+ return -ENXIO;
}
- if (!request_mem_region(res->start, resource_size(res),
- pdev->name)) {
- dev_err(&pdev->dev, "request_mem_region failed\n");
- err = -EBUSY;
- goto fail1;
- }
-
- nuc900_rtc->rtc_reg = ioremap(res->start, resource_size(res));
- if (!nuc900_rtc->rtc_reg) {
- dev_err(&pdev->dev, "ioremap rtc_reg failed\n");
- err = -ENOMEM;
- goto fail2;
- }
+ nuc900_rtc->rtc_reg = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(nuc900_rtc->rtc_reg))
+ return PTR_ERR(nuc900_rtc->rtc_reg);
platform_set_drvdata(pdev, nuc900_rtc);
- nuc900_rtc->rtcdev = rtc_device_register(pdev->name, &pdev->dev,
+ nuc900_rtc->rtcdev = devm_rtc_device_register(&pdev->dev, pdev->name,
&nuc900_rtc_ops, THIS_MODULE);
if (IS_ERR(nuc900_rtc->rtcdev)) {
dev_err(&pdev->dev, "rtc device register failed\n");
- err = PTR_ERR(nuc900_rtc->rtcdev);
- goto fail3;
+ return PTR_ERR(nuc900_rtc->rtcdev);
}
__raw_writel(__raw_readl(nuc900_rtc->rtc_reg + REG_RTC_TSSR) | MODE24,
nuc900_rtc->rtc_reg + REG_RTC_TSSR);
nuc900_rtc->irq_num = platform_get_irq(pdev, 0);
- if (request_irq(nuc900_rtc->irq_num, nuc900_rtc_interrupt,
- 0, "nuc900rtc", nuc900_rtc)) {
+ if (devm_request_irq(&pdev->dev, nuc900_rtc->irq_num,
+ nuc900_rtc_interrupt, 0, "nuc900rtc", nuc900_rtc)) {
dev_err(&pdev->dev, "NUC900 RTC request irq failed\n");
- err = -EBUSY;
- goto fail4;
+ return -EBUSY;
}
return 0;
-
-fail4: rtc_device_unregister(nuc900_rtc->rtcdev);
-fail3: iounmap(nuc900_rtc->rtc_reg);
-fail2: release_mem_region(res->start, resource_size(res));
-fail1: kfree(nuc900_rtc);
- return err;
}
static int __exit nuc900_rtc_remove(struct platform_device *pdev)
{
- struct nuc900_rtc *nuc900_rtc = platform_get_drvdata(pdev);
- struct resource *res;
-
- free_irq(nuc900_rtc->irq_num, nuc900_rtc);
- rtc_device_unregister(nuc900_rtc->rtcdev);
- iounmap(nuc900_rtc->rtc_reg);
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- release_mem_region(res->start, resource_size(res));
-
- kfree(nuc900_rtc);
-
platform_set_drvdata(pdev, NULL);
return 0;
--
1.7.2.5
next prev parent reply other threads:[~2013-04-01 9:47 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 ` Jingoo Han [this message]
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 ` [PATCH 21/27] rtc: rtc-rp5c01: " Jingoo Han
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='001a01ce2ebd$df133e40$9d39bac0$%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