diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/rtc/rtc-pxa.c | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c index 074f356fd049..cc7eb8767b82 100644 --- a/drivers/rtc/rtc-pxa.c +++ b/drivers/rtc/rtc-pxa.c | |||
@@ -19,13 +19,13 @@ | |||
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/init.h> | ||
22 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
23 | #include <linux/module.h> | 24 | #include <linux/module.h> |
24 | #include <linux/rtc.h> | 25 | #include <linux/rtc.h> |
25 | #include <linux/seq_file.h> | 26 | #include <linux/seq_file.h> |
26 | #include <linux/interrupt.h> | 27 | #include <linux/interrupt.h> |
27 | 28 | #include <linux/io.h> | |
28 | #include <asm/io.h> | ||
29 | 29 | ||
30 | #define TIMER_FREQ CLOCK_TICK_RATE | 30 | #define TIMER_FREQ CLOCK_TICK_RATE |
31 | #define RTC_DEF_DIVIDER (32768 - 1) | 31 | #define RTC_DEF_DIVIDER (32768 - 1) |
@@ -347,17 +347,19 @@ static const struct rtc_class_ops pxa_rtc_ops = { | |||
347 | .irq_set_freq = pxa_periodic_irq_set_freq, | 347 | .irq_set_freq = pxa_periodic_irq_set_freq, |
348 | }; | 348 | }; |
349 | 349 | ||
350 | static int __devinit pxa_rtc_probe(struct platform_device *pdev) | 350 | static int __init pxa_rtc_probe(struct platform_device *pdev) |
351 | { | 351 | { |
352 | struct device *dev = &pdev->dev; | 352 | struct device *dev = &pdev->dev; |
353 | struct pxa_rtc *pxa_rtc; | 353 | struct pxa_rtc *pxa_rtc; |
354 | int ret; | 354 | int ret; |
355 | u32 rttr; | 355 | u32 rttr; |
356 | 356 | ||
357 | ret = -ENOMEM; | ||
358 | pxa_rtc = kzalloc(sizeof(struct pxa_rtc), GFP_KERNEL); | 357 | pxa_rtc = kzalloc(sizeof(struct pxa_rtc), GFP_KERNEL); |
359 | if (!pxa_rtc) | 358 | if (!pxa_rtc) |
360 | goto err_alloc; | 359 | return -ENOMEM; |
360 | |||
361 | spin_lock_init(&pxa_rtc->lock); | ||
362 | platform_set_drvdata(pdev, pxa_rtc); | ||
361 | 363 | ||
362 | ret = -ENXIO; | 364 | ret = -ENXIO; |
363 | pxa_rtc->ress = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 365 | pxa_rtc->ress = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
@@ -377,20 +379,9 @@ static int __devinit pxa_rtc_probe(struct platform_device *pdev) | |||
377 | goto err_ress; | 379 | goto err_ress; |
378 | } | 380 | } |
379 | 381 | ||
380 | pxa_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, &pxa_rtc_ops, | ||
381 | THIS_MODULE); | ||
382 | ret = PTR_ERR(pxa_rtc->rtc); | ||
383 | if (IS_ERR(pxa_rtc->rtc)) { | ||
384 | dev_err(dev, "Failed to register RTC device -> %d\n", ret); | ||
385 | goto err_rtc_reg; | ||
386 | } | ||
387 | |||
388 | spin_lock_init(&pxa_rtc->lock); | ||
389 | platform_set_drvdata(pdev, pxa_rtc); | ||
390 | |||
391 | ret = -ENOMEM; | 382 | ret = -ENOMEM; |
392 | pxa_rtc->base = ioremap(pxa_rtc->ress->start, | 383 | pxa_rtc->base = ioremap(pxa_rtc->ress->start, |
393 | pxa_rtc->ress->end - pxa_rtc->ress->start + 1); | 384 | resource_size(pxa_rtc->ress)); |
394 | if (!pxa_rtc->base) { | 385 | if (!pxa_rtc->base) { |
395 | dev_err(&pdev->dev, "Unable to map pxa RTC I/O memory\n"); | 386 | dev_err(&pdev->dev, "Unable to map pxa RTC I/O memory\n"); |
396 | goto err_map; | 387 | goto err_map; |
@@ -408,31 +399,37 @@ static int __devinit pxa_rtc_probe(struct platform_device *pdev) | |||
408 | } | 399 | } |
409 | 400 | ||
410 | rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE); | 401 | rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE); |
402 | |||
403 | pxa_rtc->rtc = rtc_device_register("pxa-rtc", &pdev->dev, &pxa_rtc_ops, | ||
404 | THIS_MODULE); | ||
405 | ret = PTR_ERR(pxa_rtc->rtc); | ||
406 | if (IS_ERR(pxa_rtc->rtc)) { | ||
407 | dev_err(dev, "Failed to register RTC device -> %d\n", ret); | ||
408 | goto err_rtc_reg; | ||
409 | } | ||
410 | |||
411 | device_init_wakeup(dev, 1); | 411 | device_init_wakeup(dev, 1); |
412 | 412 | ||
413 | return 0; | 413 | return 0; |
414 | 414 | ||
415 | err_map: | ||
416 | platform_set_drvdata(pdev, NULL); | ||
417 | rtc_device_unregister(pxa_rtc->rtc); | ||
418 | err_rtc_reg: | 415 | err_rtc_reg: |
416 | iounmap(pxa_rtc->base); | ||
419 | err_ress: | 417 | err_ress: |
418 | err_map: | ||
420 | kfree(pxa_rtc); | 419 | kfree(pxa_rtc); |
421 | err_alloc: | ||
422 | return ret; | 420 | return ret; |
423 | } | 421 | } |
424 | 422 | ||
425 | static int __devexit pxa_rtc_remove(struct platform_device *pdev) | 423 | static int __exit pxa_rtc_remove(struct platform_device *pdev) |
426 | { | 424 | { |
427 | struct pxa_rtc *pxa_rtc = platform_get_drvdata(pdev); | 425 | struct pxa_rtc *pxa_rtc = platform_get_drvdata(pdev); |
428 | 426 | ||
427 | rtc_device_unregister(pxa_rtc->rtc); | ||
428 | |||
429 | spin_lock_irq(&pxa_rtc->lock); | 429 | spin_lock_irq(&pxa_rtc->lock); |
430 | iounmap(pxa_rtc->base); | 430 | iounmap(pxa_rtc->base); |
431 | pxa_rtc->base = NULL; | ||
432 | platform_set_drvdata(pdev, NULL); | ||
433 | spin_unlock_irq(&pxa_rtc->lock); | 431 | spin_unlock_irq(&pxa_rtc->lock); |
434 | 432 | ||
435 | rtc_device_unregister(pxa_rtc->rtc); | ||
436 | kfree(pxa_rtc); | 433 | kfree(pxa_rtc); |
437 | 434 | ||
438 | return 0; | 435 | return 0; |
@@ -462,7 +459,6 @@ static int pxa_rtc_resume(struct platform_device *pdev) | |||
462 | #endif | 459 | #endif |
463 | 460 | ||
464 | static struct platform_driver pxa_rtc_driver = { | 461 | static struct platform_driver pxa_rtc_driver = { |
465 | .probe = pxa_rtc_probe, | ||
466 | .remove = __exit_p(pxa_rtc_remove), | 462 | .remove = __exit_p(pxa_rtc_remove), |
467 | .suspend = pxa_rtc_suspend, | 463 | .suspend = pxa_rtc_suspend, |
468 | .resume = pxa_rtc_resume, | 464 | .resume = pxa_rtc_resume, |
@@ -474,7 +470,7 @@ static struct platform_driver pxa_rtc_driver = { | |||
474 | static int __init pxa_rtc_init(void) | 470 | static int __init pxa_rtc_init(void) |
475 | { | 471 | { |
476 | if (cpu_is_pxa27x() || cpu_is_pxa3xx()) | 472 | if (cpu_is_pxa27x() || cpu_is_pxa3xx()) |
477 | return platform_driver_register(&pxa_rtc_driver); | 473 | return platform_driver_probe(&pxa_rtc_driver, pxa_rtc_probe); |
478 | 474 | ||
479 | return -ENODEV; | 475 | return -ENODEV; |
480 | } | 476 | } |