[PATCH] at91_rtc updates
Various bug fixes to the at91rm9200 RTC: - alarm: setalarm() should pay attention to the "enabled" flag - init: cleaner handling of the wakeup flags, which cpu init should really have set up. Doing it here is just a workaround. - linkage: since the at91_rtc driver probe() routine is in the init section, it should use platform_driver_probe() instead of leaving that pointer around in the driver struct after init section removal. - linkage: likewise, remove() belongs in the exit section. Among other things, the init and alarm changes ensure that this driver handles the new sysfs "wakealarm" attribute properly. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Cc: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
32b49da46c
commit
5d4675a811
1 changed files with 13 additions and 6 deletions
|
@ -164,6 +164,7 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
|
||||||
tm.tm_min = alrm->time.tm_min;
|
tm.tm_min = alrm->time.tm_min;
|
||||||
tm.tm_sec = alrm->time.tm_sec;
|
tm.tm_sec = alrm->time.tm_sec;
|
||||||
|
|
||||||
|
at91_sys_write(AT91_RTC_IDR, AT91_RTC_ALARM);
|
||||||
at91_sys_write(AT91_RTC_TIMALR,
|
at91_sys_write(AT91_RTC_TIMALR,
|
||||||
BIN2BCD(tm.tm_sec) << 0
|
BIN2BCD(tm.tm_sec) << 0
|
||||||
| BIN2BCD(tm.tm_min) << 8
|
| BIN2BCD(tm.tm_min) << 8
|
||||||
|
@ -174,6 +175,9 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
|
||||||
| BIN2BCD(tm.tm_mday) << 24
|
| BIN2BCD(tm.tm_mday) << 24
|
||||||
| AT91_RTC_DATEEN | AT91_RTC_MTHEN);
|
| AT91_RTC_DATEEN | AT91_RTC_MTHEN);
|
||||||
|
|
||||||
|
if (alrm->enabled)
|
||||||
|
at91_sys_write(AT91_RTC_IER, AT91_RTC_ALARM);
|
||||||
|
|
||||||
pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__,
|
pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__,
|
||||||
at91_alarm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour,
|
at91_alarm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour,
|
||||||
tm.tm_min, tm.tm_sec);
|
tm.tm_min, tm.tm_sec);
|
||||||
|
@ -303,6 +307,12 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* cpu init code should really have flagged this device as
|
||||||
|
* being wake-capable; if it didn't, do that here.
|
||||||
|
*/
|
||||||
|
if (!device_can_wakeup(&pdev->dev))
|
||||||
|
device_init_wakeup(&pdev->dev, 1);
|
||||||
|
|
||||||
rtc = rtc_device_register(pdev->name, &pdev->dev,
|
rtc = rtc_device_register(pdev->name, &pdev->dev,
|
||||||
&at91_rtc_ops, THIS_MODULE);
|
&at91_rtc_ops, THIS_MODULE);
|
||||||
if (IS_ERR(rtc)) {
|
if (IS_ERR(rtc)) {
|
||||||
|
@ -310,7 +320,6 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
|
||||||
return PTR_ERR(rtc);
|
return PTR_ERR(rtc);
|
||||||
}
|
}
|
||||||
platform_set_drvdata(pdev, rtc);
|
platform_set_drvdata(pdev, rtc);
|
||||||
device_init_wakeup(&pdev->dev, 1);
|
|
||||||
|
|
||||||
printk(KERN_INFO "AT91 Real Time Clock driver.\n");
|
printk(KERN_INFO "AT91 Real Time Clock driver.\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -319,7 +328,7 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
|
||||||
/*
|
/*
|
||||||
* Disable and remove the RTC driver
|
* Disable and remove the RTC driver
|
||||||
*/
|
*/
|
||||||
static int __devexit at91_rtc_remove(struct platform_device *pdev)
|
static int __exit at91_rtc_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct rtc_device *rtc = platform_get_drvdata(pdev);
|
struct rtc_device *rtc = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
|
@ -331,7 +340,6 @@ static int __devexit at91_rtc_remove(struct platform_device *pdev)
|
||||||
|
|
||||||
rtc_device_unregister(rtc);
|
rtc_device_unregister(rtc);
|
||||||
platform_set_drvdata(pdev, NULL);
|
platform_set_drvdata(pdev, NULL);
|
||||||
device_init_wakeup(&pdev->dev, 0);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -404,8 +412,7 @@ static int at91_rtc_resume(struct platform_device *pdev)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct platform_driver at91_rtc_driver = {
|
static struct platform_driver at91_rtc_driver = {
|
||||||
.probe = at91_rtc_probe,
|
.remove = __exit_p(at91_rtc_remove),
|
||||||
.remove = at91_rtc_remove,
|
|
||||||
.suspend = at91_rtc_suspend,
|
.suspend = at91_rtc_suspend,
|
||||||
.resume = at91_rtc_resume,
|
.resume = at91_rtc_resume,
|
||||||
.driver = {
|
.driver = {
|
||||||
|
@ -416,7 +423,7 @@ static struct platform_driver at91_rtc_driver = {
|
||||||
|
|
||||||
static int __init at91_rtc_init(void)
|
static int __init at91_rtc_init(void)
|
||||||
{
|
{
|
||||||
return platform_driver_register(&at91_rtc_driver);
|
return platform_driver_probe(&at91_rtc_driver, at91_rtc_probe);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit at91_rtc_exit(void)
|
static void __exit at91_rtc_exit(void)
|
||||||
|
|
Loading…
Reference in a new issue