Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
[safe/jmp/linux-2.6] / drivers / rtc / rtc-omap.c
index eac5fb1..8876605 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/platform_device.h>
 
 #include <asm/io.h>
-#include <asm/mach/time.h>
 
 
 /* The OMAP1 RTC is a year/month/day/hours/minutes/seconds BCD clock
 #define rtc_write(val, addr)   omap_writeb(val, OMAP_RTC_BASE + (addr))
 
 
-/* platform_bus isn't hotpluggable, so for static linkage it'd be safe
- * to get rid of probe() and remove() code ... too bad the driver struct
- * remembers probe(), that's about 25% of the runtime footprint!!
- */
-#ifndef        MODULE
-#undef __devexit
-#undef __devexit_p
-#define        __devexit       __exit
-#define        __devexit_p     __exit_p
-#endif
-
-
 /* we rely on the rtc framework to handle locking (rtc->ops_lock),
  * so the only other requirement is that register accesses which
  * require BUSY to be clear are made with IRQs locally disabled
@@ -124,7 +111,7 @@ static void rtc_wait_not_busy(void)
        /* now we have ~15 usec to read/write various registers */
 }
 
-static irqreturn_t rtc_irq(int irq, void *class_dev)
+static irqreturn_t rtc_irq(int irq, void *rtc)
 {
        unsigned long           events = 0;
        u8                      irq_data;
@@ -141,7 +128,7 @@ static irqreturn_t rtc_irq(int irq, void *class_dev)
        if (irq_data & OMAP_RTC_STATUS_1S_EVENT)
                events |= RTC_IRQF | RTC_UF;
 
-       rtc_update_irq(class_dev, 1, events);
+       rtc_update_irq(rtc, 1, events);
 
        return IRQ_HANDLED;
 }
@@ -279,9 +266,8 @@ static int omap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
        local_irq_enable();
 
        bcd2tm(&alm->time);
-       alm->pending = !!(rtc_read(OMAP_RTC_INTERRUPTS_REG)
+       alm->enabled = !!(rtc_read(OMAP_RTC_INTERRUPTS_REG)
                        & OMAP_RTC_INTERRUPTS_IT_ALARM);
-       alm->enabled = alm->pending && device_may_wakeup(dev);
 
        return 0;
 }
@@ -290,34 +276,6 @@ static int omap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
 {
        u8 reg;
 
-       /* Much userspace code uses RTC_ALM_SET, thus "don't care" for
-        * day/month/year specifies alarms up to 24 hours in the future.
-        * So we need to handle that ... but let's ignore the "don't care"
-        * values for hours/minutes/seconds.
-        */
-       if (alm->time.tm_mday <= 0
-                       && alm->time.tm_mon < 0
-                       && alm->time.tm_year < 0) {
-               struct rtc_time tm;
-               unsigned long now, then;
-
-               omap_rtc_read_time(dev, &tm);
-               rtc_tm_to_time(&tm, &now);
-
-               alm->time.tm_mday = tm.tm_mday;
-               alm->time.tm_mon = tm.tm_mon;
-               alm->time.tm_year = tm.tm_year;
-               rtc_tm_to_time(&alm->time, &then);
-
-               /* sometimes the alarm wraps into tomorrow */
-               if (then < now) {
-                       rtc_time_to_tm(now + 24 * 60 * 60, &tm);
-                       alm->time.tm_mday = tm.tm_mday;
-                       alm->time.tm_mon = tm.tm_mon;
-                       alm->time.tm_year = tm.tm_year;
-               }
-       }
-
        if (tm2bcd(&alm->time) < 0)
                return -EINVAL;
 
@@ -354,7 +312,7 @@ static struct rtc_class_ops omap_rtc_ops = {
 static int omap_rtc_alarm;
 static int omap_rtc_timer;
 
-static int __devinit omap_rtc_probe(struct platform_device *pdev)
+static int __init omap_rtc_probe(struct platform_device *pdev)
 {
        struct resource         *res, *mem;
        struct rtc_device       *rtc;
@@ -400,7 +358,7 @@ static int __devinit omap_rtc_probe(struct platform_device *pdev)
                goto fail;
        }
        platform_set_drvdata(pdev, rtc);
-       class_set_devdata(&rtc->class_dev, mem);
+       dev_set_drvdata(&rtc->dev, mem);
 
        /* clear pending irqs, and set 1/second periodic,
         * which we'll use instead of update irqs
@@ -418,14 +376,14 @@ static int __devinit omap_rtc_probe(struct platform_device *pdev)
                rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG);
 
        /* handle periodic and alarm irqs */
-       if (request_irq(omap_rtc_timer, rtc_irq, SA_INTERRUPT,
-                       rtc->class_dev.class_id, &rtc->class_dev)) {
+       if (request_irq(omap_rtc_timer, rtc_irq, IRQF_DISABLED,
+                       rtc->dev.bus_id, rtc)) {
                pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n",
                        pdev->name, omap_rtc_timer);
                goto fail0;
        }
-       if (request_irq(omap_rtc_alarm, rtc_irq, SA_INTERRUPT,
-                       rtc->class_dev.class_id, &rtc->class_dev)) {
+       if (request_irq(omap_rtc_alarm, rtc_irq, IRQF_DISABLED,
+                       rtc->dev.bus_id, rtc)) {
                pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n",
                        pdev->name, omap_rtc_alarm);
                goto fail1;
@@ -470,7 +428,7 @@ fail:
        return -EIO;
 }
 
-static int __devexit omap_rtc_remove(struct platform_device *pdev)
+static int __exit omap_rtc_remove(struct platform_device *pdev)
 {
        struct rtc_device       *rtc = platform_get_drvdata(pdev);;
 
@@ -482,26 +440,17 @@ static int __devexit omap_rtc_remove(struct platform_device *pdev)
        free_irq(omap_rtc_timer, rtc);
        free_irq(omap_rtc_alarm, rtc);
 
-       release_resource(class_get_devdata(&rtc->class_dev));
+       release_resource(dev_get_drvdata(&rtc->dev));
        rtc_device_unregister(rtc);
        return 0;
 }
 
 #ifdef CONFIG_PM
 
-static struct timespec rtc_delta;
 static u8 irqstat;
 
 static int omap_rtc_suspend(struct platform_device *pdev, pm_message_t state)
 {
-       struct rtc_time rtc_tm;
-       struct timespec time;
-
-       time.tv_nsec = 0;
-       omap_rtc_read_time(NULL, &rtc_tm);
-       rtc_tm_to_time(&rtc_tm, &time.tv_sec);
-
-       save_time_delta(&rtc_delta, &time);
        irqstat = rtc_read(OMAP_RTC_INTERRUPTS_REG);
 
        /* FIXME the RTC alarm is not currently acting as a wakeup event
@@ -518,14 +467,6 @@ static int omap_rtc_suspend(struct platform_device *pdev, pm_message_t state)
 
 static int omap_rtc_resume(struct platform_device *pdev)
 {
-       struct rtc_time rtc_tm;
-       struct timespec time;
-
-       time.tv_nsec = 0;
-       omap_rtc_read_time(NULL, &rtc_tm);
-       rtc_tm_to_time(&rtc_tm, &time.tv_sec);
-
-       restore_time_delta(&rtc_delta, &time);
        if (device_may_wakeup(&pdev->dev))
                disable_irq_wake(omap_rtc_alarm);
        else
@@ -543,10 +484,9 @@ static void omap_rtc_shutdown(struct platform_device *pdev)
        rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
 }
 
-MODULE_ALIAS("omap_rtc");
+MODULE_ALIAS("platform:omap_rtc");
 static struct platform_driver omap_rtc_driver = {
-       .probe          = omap_rtc_probe,
-       .remove         = __devexit_p(omap_rtc_remove),
+       .remove         = __exit_p(omap_rtc_remove),
        .suspend        = omap_rtc_suspend,
        .resume         = omap_rtc_resume,
        .shutdown       = omap_rtc_shutdown,
@@ -558,7 +498,7 @@ static struct platform_driver omap_rtc_driver = {
 
 static int __init rtc_init(void)
 {
-       return platform_driver_register(&omap_rtc_driver);
+       return platform_driver_probe(&omap_rtc_driver, omap_rtc_probe);
 }
 module_init(rtc_init);