aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2014-01-23 18:55:07 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-23 19:36:59 -0500
commitbf6ce1a102797ceca6d44de991def4e0c1825cb2 (patch)
treef7e96f06de630d1d6d5ed8df47900fcbd61b03a4
parentf53eeb853dfe408737ac6b8c3117bd21a9c60fd4 (diff)
drivers/rtc/rtc-vr41xx.c: use devm_*() functions
Use devm_*() functions to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han <jg1.han@samsung.com> Cc: Yoichi Yuasa <yuasa@linux-mips.org> Cc: Grygorii Strashko <grygorii.strashko@ti.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/rtc/rtc-vr41xx.c50
1 files changed, 12 insertions, 38 deletions
diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c
index aabc22c587fb..88c9c92e89fd 100644
--- a/drivers/rtc/rtc-vr41xx.c
+++ b/drivers/rtc/rtc-vr41xx.c
@@ -293,7 +293,7 @@ static int rtc_probe(struct platform_device *pdev)
293 if (!res) 293 if (!res)
294 return -EBUSY; 294 return -EBUSY;
295 295
296 rtc1_base = ioremap(res->start, resource_size(res)); 296 rtc1_base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
297 if (!rtc1_base) 297 if (!rtc1_base)
298 return -EBUSY; 298 return -EBUSY;
299 299
@@ -303,13 +303,14 @@ static int rtc_probe(struct platform_device *pdev)
303 goto err_rtc1_iounmap; 303 goto err_rtc1_iounmap;
304 } 304 }
305 305
306 rtc2_base = ioremap(res->start, resource_size(res)); 306 rtc2_base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
307 if (!rtc2_base) { 307 if (!rtc2_base) {
308 retval = -EBUSY; 308 retval = -EBUSY;
309 goto err_rtc1_iounmap; 309 goto err_rtc1_iounmap;
310 } 310 }
311 311
312 rtc = rtc_device_register(rtc_name, &pdev->dev, &vr41xx_rtc_ops, THIS_MODULE); 312 rtc = devm_rtc_device_register(&pdev->dev, rtc_name, &vr41xx_rtc_ops,
313 THIS_MODULE);
313 if (IS_ERR(rtc)) { 314 if (IS_ERR(rtc)) {
314 retval = PTR_ERR(rtc); 315 retval = PTR_ERR(rtc);
315 goto err_iounmap_all; 316 goto err_iounmap_all;
@@ -330,24 +331,24 @@ static int rtc_probe(struct platform_device *pdev)
330 aie_irq = platform_get_irq(pdev, 0); 331 aie_irq = platform_get_irq(pdev, 0);
331 if (aie_irq <= 0) { 332 if (aie_irq <= 0) {
332 retval = -EBUSY; 333 retval = -EBUSY;
333 goto err_device_unregister; 334 goto err_iounmap_all;
334 } 335 }
335 336
336 retval = request_irq(aie_irq, elapsedtime_interrupt, 0, 337 retval = devm_request_irq(&pdev->dev, aie_irq, elapsedtime_interrupt, 0,
337 "elapsed_time", pdev); 338 "elapsed_time", pdev);
338 if (retval < 0) 339 if (retval < 0)
339 goto err_device_unregister; 340 goto err_iounmap_all;
340 341
341 pie_irq = platform_get_irq(pdev, 1); 342 pie_irq = platform_get_irq(pdev, 1);
342 if (pie_irq <= 0) { 343 if (pie_irq <= 0) {
343 retval = -EBUSY; 344 retval = -EBUSY;
344 goto err_free_irq; 345 goto err_iounmap_all;
345 } 346 }
346 347
347 retval = request_irq(pie_irq, rtclong1_interrupt, 0, 348 retval = devm_request_irq(&pdev->dev, pie_irq, rtclong1_interrupt, 0,
348 "rtclong1", pdev); 349 "rtclong1", pdev);
349 if (retval < 0) 350 if (retval < 0)
350 goto err_free_irq; 351 goto err_iounmap_all;
351 352
352 platform_set_drvdata(pdev, rtc); 353 platform_set_drvdata(pdev, rtc);
353 354
@@ -358,47 +359,20 @@ static int rtc_probe(struct platform_device *pdev)
358 359
359 return 0; 360 return 0;
360 361
361err_free_irq:
362 free_irq(aie_irq, pdev);
363
364err_device_unregister:
365 rtc_device_unregister(rtc);
366
367err_iounmap_all: 362err_iounmap_all:
368 iounmap(rtc2_base);
369 rtc2_base = NULL; 363 rtc2_base = NULL;
370 364
371err_rtc1_iounmap: 365err_rtc1_iounmap:
372 iounmap(rtc1_base);
373 rtc1_base = NULL; 366 rtc1_base = NULL;
374 367
375 return retval; 368 return retval;
376} 369}
377 370
378static int rtc_remove(struct platform_device *pdev)
379{
380 struct rtc_device *rtc;
381
382 rtc = platform_get_drvdata(pdev);
383 if (rtc)
384 rtc_device_unregister(rtc);
385
386 free_irq(aie_irq, pdev);
387 free_irq(pie_irq, pdev);
388 if (rtc1_base)
389 iounmap(rtc1_base);
390 if (rtc2_base)
391 iounmap(rtc2_base);
392
393 return 0;
394}
395
396/* work with hotplug and coldplug */ 371/* work with hotplug and coldplug */
397MODULE_ALIAS("platform:RTC"); 372MODULE_ALIAS("platform:RTC");
398 373
399static struct platform_driver rtc_platform_driver = { 374static struct platform_driver rtc_platform_driver = {
400 .probe = rtc_probe, 375 .probe = rtc_probe,
401 .remove = rtc_remove,
402 .driver = { 376 .driver = {
403 .name = rtc_name, 377 .name = rtc_name,
404 .owner = THIS_MODULE, 378 .owner = THIS_MODULE,