aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishwanathrao Badarkhe, Manish <manishv.b@ti.com>2013-04-29 19:20:04 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 21:28:33 -0400
commit3765e8f18cb95f6582035710197d24488e164728 (patch)
treeeadc8d523d52f57ccc37d5227e4791f58911243e
parent7d1376d80228b4ca6e1a0d1e8b88efc23a013f2c (diff)
drivers/rtc/rtc-omap.c: update to devm_* API
Update the code to use devm_* API so that driver core will manage resources. Signed-off-by: Vishwanathrao Badarkhe, Manish <manishv.b@ti.com> Tested-by: Sekhar Nori <nsekhar@ti.com> Cc: Jingoo Han <jg1.han@samsung.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-omap.c45
1 files changed, 9 insertions, 36 deletions
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 172cc5ca7489..a1f9d30e162b 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -324,7 +324,7 @@ MODULE_DEVICE_TABLE(of, omap_rtc_of_match);
324 324
325static int __init omap_rtc_probe(struct platform_device *pdev) 325static int __init omap_rtc_probe(struct platform_device *pdev)
326{ 326{
327 struct resource *res, *mem; 327 struct resource *res;
328 struct rtc_device *rtc; 328 struct rtc_device *rtc;
329 u8 reg, new_ctrl; 329 u8 reg, new_ctrl;
330 const struct platform_device_id *id_entry; 330 const struct platform_device_id *id_entry;
@@ -352,18 +352,9 @@ static int __init omap_rtc_probe(struct platform_device *pdev)
352 return -ENOENT; 352 return -ENOENT;
353 } 353 }
354 354
355 mem = request_mem_region(res->start, resource_size(res), pdev->name); 355 rtc_base = devm_ioremap_resource(&pdev->dev, res);
356 if (!mem) { 356 if (IS_ERR(rtc_base))
357 pr_debug("%s: RTC registers at %08x are not free\n", 357 return PTR_ERR(rtc_base);
358 pdev->name, res->start);
359 return -EBUSY;
360 }
361
362 rtc_base = ioremap(res->start, resource_size(res));
363 if (!rtc_base) {
364 pr_debug("%s: RTC registers can't be mapped\n", pdev->name);
365 goto fail;
366 }
367 358
368 /* Enable the clock/module so that we can access the registers */ 359 /* Enable the clock/module so that we can access the registers */
369 pm_runtime_enable(&pdev->dev); 360 pm_runtime_enable(&pdev->dev);
@@ -375,7 +366,7 @@ static int __init omap_rtc_probe(struct platform_device *pdev)
375 rtc_writel(KICK1_VALUE, OMAP_RTC_KICK1_REG); 366 rtc_writel(KICK1_VALUE, OMAP_RTC_KICK1_REG);
376 } 367 }
377 368
378 rtc = rtc_device_register(pdev->name, &pdev->dev, 369 rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
379 &omap_rtc_ops, THIS_MODULE); 370 &omap_rtc_ops, THIS_MODULE);
380 if (IS_ERR(rtc)) { 371 if (IS_ERR(rtc)) {
381 pr_debug("%s: can't register RTC device, err %ld\n", 372 pr_debug("%s: can't register RTC device, err %ld\n",
@@ -383,7 +374,6 @@ static int __init omap_rtc_probe(struct platform_device *pdev)
383 goto fail0; 374 goto fail0;
384 } 375 }
385 platform_set_drvdata(pdev, rtc); 376 platform_set_drvdata(pdev, rtc);
386 dev_set_drvdata(&rtc->dev, mem);
387 377
388 /* clear pending irqs, and set 1/second periodic, 378 /* clear pending irqs, and set 1/second periodic,
389 * which we'll use instead of update irqs 379 * which we'll use instead of update irqs
@@ -401,18 +391,18 @@ static int __init omap_rtc_probe(struct platform_device *pdev)
401 rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG); 391 rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG);
402 392
403 /* handle periodic and alarm irqs */ 393 /* handle periodic and alarm irqs */
404 if (request_irq(omap_rtc_timer, rtc_irq, 0, 394 if (devm_request_irq(&pdev->dev, omap_rtc_timer, rtc_irq, 0,
405 dev_name(&rtc->dev), rtc)) { 395 dev_name(&rtc->dev), rtc)) {
406 pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n", 396 pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n",
407 pdev->name, omap_rtc_timer); 397 pdev->name, omap_rtc_timer);
408 goto fail1; 398 goto fail0;
409 } 399 }
410 if ((omap_rtc_timer != omap_rtc_alarm) && 400 if ((omap_rtc_timer != omap_rtc_alarm) &&
411 (request_irq(omap_rtc_alarm, rtc_irq, 0, 401 (devm_request_irq(&pdev->dev, omap_rtc_alarm, rtc_irq, 0,
412 dev_name(&rtc->dev), rtc))) { 402 dev_name(&rtc->dev), rtc))) {
413 pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n", 403 pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n",
414 pdev->name, omap_rtc_alarm); 404 pdev->name, omap_rtc_alarm);
415 goto fail2; 405 goto fail0;
416 } 406 }
417 407
418 /* On boards with split power, RTC_ON_NOFF won't reset the RTC */ 408 /* On boards with split power, RTC_ON_NOFF won't reset the RTC */
@@ -446,25 +436,16 @@ static int __init omap_rtc_probe(struct platform_device *pdev)
446 436
447 return 0; 437 return 0;
448 438
449fail2:
450 free_irq(omap_rtc_timer, rtc);
451fail1:
452 rtc_device_unregister(rtc);
453fail0: 439fail0:
454 if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) 440 if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER))
455 rtc_writel(0, OMAP_RTC_KICK0_REG); 441 rtc_writel(0, OMAP_RTC_KICK0_REG);
456 pm_runtime_put_sync(&pdev->dev); 442 pm_runtime_put_sync(&pdev->dev);
457 pm_runtime_disable(&pdev->dev); 443 pm_runtime_disable(&pdev->dev);
458 iounmap(rtc_base);
459fail:
460 release_mem_region(mem->start, resource_size(mem));
461 return -EIO; 444 return -EIO;
462} 445}
463 446
464static int __exit omap_rtc_remove(struct platform_device *pdev) 447static int __exit omap_rtc_remove(struct platform_device *pdev)
465{ 448{
466 struct rtc_device *rtc = platform_get_drvdata(pdev);
467 struct resource *mem = dev_get_drvdata(&rtc->dev);
468 const struct platform_device_id *id_entry = 449 const struct platform_device_id *id_entry =
469 platform_get_device_id(pdev); 450 platform_get_device_id(pdev);
470 451
@@ -473,12 +454,6 @@ static int __exit omap_rtc_remove(struct platform_device *pdev)
473 /* leave rtc running, but disable irqs */ 454 /* leave rtc running, but disable irqs */
474 rtc_write(0, OMAP_RTC_INTERRUPTS_REG); 455 rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
475 456
476 free_irq(omap_rtc_timer, rtc);
477
478 if (omap_rtc_timer != omap_rtc_alarm)
479 free_irq(omap_rtc_alarm, rtc);
480
481 rtc_device_unregister(rtc);
482 if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) 457 if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER))
483 rtc_writel(0, OMAP_RTC_KICK0_REG); 458 rtc_writel(0, OMAP_RTC_KICK0_REG);
484 459
@@ -486,8 +461,6 @@ static int __exit omap_rtc_remove(struct platform_device *pdev)
486 pm_runtime_put_sync(&pdev->dev); 461 pm_runtime_put_sync(&pdev->dev);
487 pm_runtime_disable(&pdev->dev); 462 pm_runtime_disable(&pdev->dev);
488 463
489 iounmap(rtc_base);
490 release_mem_region(mem->start, resource_size(mem));
491 return 0; 464 return 0;
492} 465}
493 466