aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2013-04-29 19:20:55 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 21:28:39 -0400
commit87a81420873d031dc387c6d1c8cefa067b539fa2 (patch)
tree3d170ba5648e1adc48569c17ef22f6b0548529f1 /drivers
parent55d735efd0132619b1887c4b5a8dcf2156f35216 (diff)
rtc: rtc-stmp3xxx: use devm_*() functions
Use devm_*() functions to make cleanup paths simpler. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/rtc/rtc-stmp3xxx.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c
index 98f0d3c30738..0930f275b2dd 100644
--- a/drivers/rtc/rtc-stmp3xxx.c
+++ b/drivers/rtc/rtc-stmp3xxx.c
@@ -227,11 +227,7 @@ static int stmp3xxx_rtc_remove(struct platform_device *pdev)
227 227
228 writel(STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, 228 writel(STMP3XXX_RTC_CTRL_ALARM_IRQ_EN,
229 rtc_data->io + STMP3XXX_RTC_CTRL_CLR); 229 rtc_data->io + STMP3XXX_RTC_CTRL_CLR);
230 free_irq(rtc_data->irq_alarm, &pdev->dev);
231 rtc_device_unregister(rtc_data->rtc);
232 platform_set_drvdata(pdev, NULL); 230 platform_set_drvdata(pdev, NULL);
233 iounmap(rtc_data->io);
234 kfree(rtc_data);
235 231
236 return 0; 232 return 0;
237} 233}
@@ -242,22 +238,20 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev)
242 struct resource *r; 238 struct resource *r;
243 int err; 239 int err;
244 240
245 rtc_data = kzalloc(sizeof *rtc_data, GFP_KERNEL); 241 rtc_data = devm_kzalloc(&pdev->dev, sizeof(*rtc_data), GFP_KERNEL);
246 if (!rtc_data) 242 if (!rtc_data)
247 return -ENOMEM; 243 return -ENOMEM;
248 244
249 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 245 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
250 if (!r) { 246 if (!r) {
251 dev_err(&pdev->dev, "failed to get resource\n"); 247 dev_err(&pdev->dev, "failed to get resource\n");
252 err = -ENXIO; 248 return -ENXIO;
253 goto out_free;
254 } 249 }
255 250
256 rtc_data->io = ioremap(r->start, resource_size(r)); 251 rtc_data->io = devm_ioremap(&pdev->dev, r->start, resource_size(r));
257 if (!rtc_data->io) { 252 if (!rtc_data->io) {
258 dev_err(&pdev->dev, "ioremap failed\n"); 253 dev_err(&pdev->dev, "ioremap failed\n");
259 err = -EIO; 254 return -EIO;
260 goto out_free;
261 } 255 }
262 256
263 rtc_data->irq_alarm = platform_get_irq(pdev, 0); 257 rtc_data->irq_alarm = platform_get_irq(pdev, 0);
@@ -265,8 +259,7 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev)
265 if (!(readl(STMP3XXX_RTC_STAT + rtc_data->io) & 259 if (!(readl(STMP3XXX_RTC_STAT + rtc_data->io) &
266 STMP3XXX_RTC_STAT_RTC_PRESENT)) { 260 STMP3XXX_RTC_STAT_RTC_PRESENT)) {
267 dev_err(&pdev->dev, "no device onboard\n"); 261 dev_err(&pdev->dev, "no device onboard\n");
268 err = -ENODEV; 262 return -ENODEV;
269 goto out_remap;
270 } 263 }
271 264
272 platform_set_drvdata(pdev, rtc_data); 265 platform_set_drvdata(pdev, rtc_data);
@@ -281,31 +274,26 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev)
281 STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, 274 STMP3XXX_RTC_CTRL_ALARM_IRQ_EN,
282 rtc_data->io + STMP3XXX_RTC_CTRL_CLR); 275 rtc_data->io + STMP3XXX_RTC_CTRL_CLR);
283 276
284 rtc_data->rtc = rtc_device_register(pdev->name, &pdev->dev, 277 rtc_data->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
285 &stmp3xxx_rtc_ops, THIS_MODULE); 278 &stmp3xxx_rtc_ops, THIS_MODULE);
286 if (IS_ERR(rtc_data->rtc)) { 279 if (IS_ERR(rtc_data->rtc)) {
287 err = PTR_ERR(rtc_data->rtc); 280 err = PTR_ERR(rtc_data->rtc);
288 goto out_remap; 281 goto out;
289 } 282 }
290 283
291 err = request_irq(rtc_data->irq_alarm, stmp3xxx_rtc_interrupt, 0, 284 err = devm_request_irq(&pdev->dev, rtc_data->irq_alarm,
292 "RTC alarm", &pdev->dev); 285 stmp3xxx_rtc_interrupt, 0, "RTC alarm", &pdev->dev);
293 if (err) { 286 if (err) {
294 dev_err(&pdev->dev, "Cannot claim IRQ%d\n", 287 dev_err(&pdev->dev, "Cannot claim IRQ%d\n",
295 rtc_data->irq_alarm); 288 rtc_data->irq_alarm);
296 goto out_irq_alarm; 289 goto out;
297 } 290 }
298 291
299 stmp3xxx_wdt_register(pdev); 292 stmp3xxx_wdt_register(pdev);
300 return 0; 293 return 0;
301 294
302out_irq_alarm: 295out:
303 rtc_device_unregister(rtc_data->rtc);
304out_remap:
305 platform_set_drvdata(pdev, NULL); 296 platform_set_drvdata(pdev, NULL);
306 iounmap(rtc_data->io);
307out_free:
308 kfree(rtc_data);
309 return err; 297 return err;
310} 298}
311 299