Commit 0417ce2ad81f719c72e948705134c3d502300d4f

Authored by Alessandro Zummo
Committed by Linus Torvalds
1 parent dc9443688e

rtc: pxa27x/pxa3xx driver fixes, revised

Small fixes for the pxa27x/pxa3xx driver

- use platform_driver_probe
- fixed exit paths
- fixed probe sequence
- added missing include
- using linux/io.h instead of asm/io.h

Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
Tested-by: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: Jonathan Cameron <jic23@cam.ac.uk>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 23 additions and 27 deletions Side-by-side Diff

drivers/rtc/rtc-pxa.c
... ... @@ -19,14 +19,14 @@
19 19 *
20 20 */
21 21  
  22 +#include <linux/init.h>
22 23 #include <linux/platform_device.h>
23 24 #include <linux/module.h>
24 25 #include <linux/rtc.h>
25 26 #include <linux/seq_file.h>
26 27 #include <linux/interrupt.h>
  28 +#include <linux/io.h>
27 29  
28   -#include <asm/io.h>
29   -
30 30 #define TIMER_FREQ CLOCK_TICK_RATE
31 31 #define RTC_DEF_DIVIDER (32768 - 1)
32 32 #define RTC_DEF_TRIM 0
33 33  
34 34  
35 35  
... ... @@ -347,18 +347,20 @@
347 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 352 struct device *dev = &pdev->dev;
353 353 struct pxa_rtc *pxa_rtc;
354 354 int ret;
355 355 u32 rttr;
356 356  
357   - ret = -ENOMEM;
358 357 pxa_rtc = kzalloc(sizeof(struct pxa_rtc), GFP_KERNEL);
359 358 if (!pxa_rtc)
360   - goto err_alloc;
  359 + return -ENOMEM;
361 360  
  361 + spin_lock_init(&pxa_rtc->lock);
  362 + platform_set_drvdata(pdev, pxa_rtc);
  363 +
362 364 ret = -ENXIO;
363 365 pxa_rtc->ress = platform_get_resource(pdev, IORESOURCE_MEM, 0);
364 366 if (!pxa_rtc->ress) {
365 367  
... ... @@ -377,20 +379,9 @@
377 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 382 ret = -ENOMEM;
392 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 385 if (!pxa_rtc->base) {
395 386 dev_err(&pdev->dev, "Unable to map pxa RTC I/O memory\n");
396 387 goto err_map;
397 388  
398 389  
399 390  
400 391  
401 392  
402 393  
403 394  
404 395  
... ... @@ -408,31 +399,37 @@
408 399 }
409 400  
410 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 411 device_init_wakeup(dev, 1);
412 412  
413 413 return 0;
414 414  
415   -err_map:
416   - platform_set_drvdata(pdev, NULL);
417   - rtc_device_unregister(pxa_rtc->rtc);
418 415 err_rtc_reg:
  416 + iounmap(pxa_rtc->base);
419 417 err_ress:
  418 +err_map:
420 419 kfree(pxa_rtc);
421   -err_alloc:
422 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 425 struct pxa_rtc *pxa_rtc = platform_get_drvdata(pdev);
428 426  
  427 + rtc_device_unregister(pxa_rtc->rtc);
  428 +
429 429 spin_lock_irq(&pxa_rtc->lock);
430 430 iounmap(pxa_rtc->base);
431   - pxa_rtc->base = NULL;
432   - platform_set_drvdata(pdev, NULL);
433 431 spin_unlock_irq(&pxa_rtc->lock);
434 432  
435   - rtc_device_unregister(pxa_rtc->rtc);
436 433 kfree(pxa_rtc);
437 434  
438 435 return 0;
... ... @@ -462,7 +459,6 @@
462 459 #endif
463 460  
464 461 static struct platform_driver pxa_rtc_driver = {
465   - .probe = pxa_rtc_probe,
466 462 .remove = __exit_p(pxa_rtc_remove),
467 463 .suspend = pxa_rtc_suspend,
468 464 .resume = pxa_rtc_resume,
... ... @@ -474,7 +470,7 @@
474 470 static int __init pxa_rtc_init(void)
475 471 {
476 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 475 return -ENODEV;
480 476 }