aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-bfin.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-bfin.c')
-rw-r--r--drivers/rtc/rtc-bfin.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c
index 4ec614b0954d..ad44ec5dc29a 100644
--- a/drivers/rtc/rtc-bfin.c
+++ b/drivers/rtc/rtc-bfin.c
@@ -352,14 +352,14 @@ static int bfin_rtc_probe(struct platform_device *pdev)
352 dev_dbg_stamp(dev); 352 dev_dbg_stamp(dev);
353 353
354 /* Allocate memory for our RTC struct */ 354 /* Allocate memory for our RTC struct */
355 rtc = kzalloc(sizeof(*rtc), GFP_KERNEL); 355 rtc = devm_kzalloc(dev, sizeof(*rtc), GFP_KERNEL);
356 if (unlikely(!rtc)) 356 if (unlikely(!rtc))
357 return -ENOMEM; 357 return -ENOMEM;
358 platform_set_drvdata(pdev, rtc); 358 platform_set_drvdata(pdev, rtc);
359 device_init_wakeup(dev, 1); 359 device_init_wakeup(dev, 1);
360 360
361 /* Register our RTC with the RTC framework */ 361 /* Register our RTC with the RTC framework */
362 rtc->rtc_dev = rtc_device_register(pdev->name, dev, &bfin_rtc_ops, 362 rtc->rtc_dev = devm_rtc_device_register(dev, pdev->name, &bfin_rtc_ops,
363 THIS_MODULE); 363 THIS_MODULE);
364 if (unlikely(IS_ERR(rtc->rtc_dev))) { 364 if (unlikely(IS_ERR(rtc->rtc_dev))) {
365 ret = PTR_ERR(rtc->rtc_dev); 365 ret = PTR_ERR(rtc->rtc_dev);
@@ -367,9 +367,10 @@ static int bfin_rtc_probe(struct platform_device *pdev)
367 } 367 }
368 368
369 /* Grab the IRQ and init the hardware */ 369 /* Grab the IRQ and init the hardware */
370 ret = request_irq(IRQ_RTC, bfin_rtc_interrupt, 0, pdev->name, dev); 370 ret = devm_request_irq(dev, IRQ_RTC, bfin_rtc_interrupt, 0,
371 pdev->name, dev);
371 if (unlikely(ret)) 372 if (unlikely(ret))
372 goto err_reg; 373 goto err;
373 /* sometimes the bootloader touched things, but the write complete was not 374 /* sometimes the bootloader touched things, but the write complete was not
374 * enabled, so let's just do a quick timeout here since the IRQ will not fire ... 375 * enabled, so let's just do a quick timeout here since the IRQ will not fire ...
375 */ 376 */
@@ -381,32 +382,23 @@ static int bfin_rtc_probe(struct platform_device *pdev)
381 382
382 return 0; 383 return 0;
383 384
384err_reg:
385 rtc_device_unregister(rtc->rtc_dev);
386err: 385err:
387 kfree(rtc);
388 return ret; 386 return ret;
389} 387}
390 388
391static int bfin_rtc_remove(struct platform_device *pdev) 389static int bfin_rtc_remove(struct platform_device *pdev)
392{ 390{
393 struct bfin_rtc *rtc = platform_get_drvdata(pdev);
394 struct device *dev = &pdev->dev; 391 struct device *dev = &pdev->dev;
395 392
396 bfin_rtc_reset(dev, 0); 393 bfin_rtc_reset(dev, 0);
397 free_irq(IRQ_RTC, dev);
398 rtc_device_unregister(rtc->rtc_dev);
399 platform_set_drvdata(pdev, NULL); 394 platform_set_drvdata(pdev, NULL);
400 kfree(rtc);
401 395
402 return 0; 396 return 0;
403} 397}
404 398
405#ifdef CONFIG_PM 399#ifdef CONFIG_PM_SLEEP
406static int bfin_rtc_suspend(struct platform_device *pdev, pm_message_t state) 400static int bfin_rtc_suspend(struct device *dev)
407{ 401{
408 struct device *dev = &pdev->dev;
409
410 dev_dbg_stamp(dev); 402 dev_dbg_stamp(dev);
411 403
412 if (device_may_wakeup(dev)) { 404 if (device_may_wakeup(dev)) {
@@ -418,10 +410,8 @@ static int bfin_rtc_suspend(struct platform_device *pdev, pm_message_t state)
418 return 0; 410 return 0;
419} 411}
420 412
421static int bfin_rtc_resume(struct platform_device *pdev) 413static int bfin_rtc_resume(struct device *dev)
422{ 414{
423 struct device *dev = &pdev->dev;
424
425 dev_dbg_stamp(dev); 415 dev_dbg_stamp(dev);
426 416
427 if (device_may_wakeup(dev)) 417 if (device_may_wakeup(dev))
@@ -440,20 +430,18 @@ static int bfin_rtc_resume(struct platform_device *pdev)
440 430
441 return 0; 431 return 0;
442} 432}
443#else
444# define bfin_rtc_suspend NULL
445# define bfin_rtc_resume NULL
446#endif 433#endif
447 434
435static SIMPLE_DEV_PM_OPS(bfin_rtc_pm_ops, bfin_rtc_suspend, bfin_rtc_resume);
436
448static struct platform_driver bfin_rtc_driver = { 437static struct platform_driver bfin_rtc_driver = {
449 .driver = { 438 .driver = {
450 .name = "rtc-bfin", 439 .name = "rtc-bfin",
451 .owner = THIS_MODULE, 440 .owner = THIS_MODULE,
441 .pm = &bfin_rtc_pm_ops,
452 }, 442 },
453 .probe = bfin_rtc_probe, 443 .probe = bfin_rtc_probe,
454 .remove = bfin_rtc_remove, 444 .remove = bfin_rtc_remove,
455 .suspend = bfin_rtc_suspend,
456 .resume = bfin_rtc_resume,
457}; 445};
458 446
459module_platform_driver(bfin_rtc_driver); 447module_platform_driver(bfin_rtc_driver);