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>
This commit is contained in:
Alessandro Zummo 2009-01-06 14:42:15 -08:00 committed by Linus Torvalds
parent dc9443688e
commit 0417ce2ad8
1 changed files with 23 additions and 27 deletions

View File

@ -19,13 +19,13 @@
*
*/
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/rtc.h>
#include <linux/seq_file.h>
#include <linux/interrupt.h>
#include <asm/io.h>
#include <linux/io.h>
#define TIMER_FREQ CLOCK_TICK_RATE
#define RTC_DEF_DIVIDER (32768 - 1)
@ -347,17 +347,19 @@ static const struct rtc_class_ops pxa_rtc_ops = {
.irq_set_freq = pxa_periodic_irq_set_freq,
};
static int __devinit pxa_rtc_probe(struct platform_device *pdev)
static int __init pxa_rtc_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct pxa_rtc *pxa_rtc;
int ret;
u32 rttr;
ret = -ENOMEM;
pxa_rtc = kzalloc(sizeof(struct pxa_rtc), GFP_KERNEL);
if (!pxa_rtc)
goto err_alloc;
return -ENOMEM;
spin_lock_init(&pxa_rtc->lock);
platform_set_drvdata(pdev, pxa_rtc);
ret = -ENXIO;
pxa_rtc->ress = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@ -377,20 +379,9 @@ static int __devinit pxa_rtc_probe(struct platform_device *pdev)
goto err_ress;
}
pxa_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, &pxa_rtc_ops,
THIS_MODULE);
ret = PTR_ERR(pxa_rtc->rtc);
if (IS_ERR(pxa_rtc->rtc)) {
dev_err(dev, "Failed to register RTC device -> %d\n", ret);
goto err_rtc_reg;
}
spin_lock_init(&pxa_rtc->lock);
platform_set_drvdata(pdev, pxa_rtc);
ret = -ENOMEM;
pxa_rtc->base = ioremap(pxa_rtc->ress->start,
pxa_rtc->ress->end - pxa_rtc->ress->start + 1);
resource_size(pxa_rtc->ress));
if (!pxa_rtc->base) {
dev_err(&pdev->dev, "Unable to map pxa RTC I/O memory\n");
goto err_map;
@ -408,31 +399,37 @@ static int __devinit pxa_rtc_probe(struct platform_device *pdev)
}
rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE);
pxa_rtc->rtc = rtc_device_register("pxa-rtc", &pdev->dev, &pxa_rtc_ops,
THIS_MODULE);
ret = PTR_ERR(pxa_rtc->rtc);
if (IS_ERR(pxa_rtc->rtc)) {
dev_err(dev, "Failed to register RTC device -> %d\n", ret);
goto err_rtc_reg;
}
device_init_wakeup(dev, 1);
return 0;
err_map:
platform_set_drvdata(pdev, NULL);
rtc_device_unregister(pxa_rtc->rtc);
err_rtc_reg:
iounmap(pxa_rtc->base);
err_ress:
err_map:
kfree(pxa_rtc);
err_alloc:
return ret;
}
static int __devexit pxa_rtc_remove(struct platform_device *pdev)
static int __exit pxa_rtc_remove(struct platform_device *pdev)
{
struct pxa_rtc *pxa_rtc = platform_get_drvdata(pdev);
rtc_device_unregister(pxa_rtc->rtc);
spin_lock_irq(&pxa_rtc->lock);
iounmap(pxa_rtc->base);
pxa_rtc->base = NULL;
platform_set_drvdata(pdev, NULL);
spin_unlock_irq(&pxa_rtc->lock);
rtc_device_unregister(pxa_rtc->rtc);
kfree(pxa_rtc);
return 0;
@ -462,7 +459,6 @@ static int pxa_rtc_resume(struct platform_device *pdev)
#endif
static struct platform_driver pxa_rtc_driver = {
.probe = pxa_rtc_probe,
.remove = __exit_p(pxa_rtc_remove),
.suspend = pxa_rtc_suspend,
.resume = pxa_rtc_resume,
@ -474,7 +470,7 @@ static struct platform_driver pxa_rtc_driver = {
static int __init pxa_rtc_init(void)
{
if (cpu_is_pxa27x() || cpu_is_pxa3xx())
return platform_driver_register(&pxa_rtc_driver);
return platform_driver_probe(&pxa_rtc_driver, pxa_rtc_probe);
return -ENODEV;
}