From: Alessandro Zummo Date: Tue, 6 Jan 2009 22:42:15 +0000 (-0800) Subject: rtc: pxa27x/pxa3xx driver fixes, revised X-Git-Tag: v2.6.29-rc1~287 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=0417ce2ad81f719c72e948705134c3d502300d4f;p=linux-2.6-omap-h63xx.git 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 Tested-by: Robert Jarzmik Cc: Jonathan Cameron Cc: David Brownell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c index 074f356fd04..cc7eb8767b8 100644 --- a/drivers/rtc/rtc-pxa.c +++ b/drivers/rtc/rtc-pxa.c @@ -19,13 +19,13 @@ * */ +#include #include #include #include #include #include - -#include +#include #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; }