Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[pandora-kernel.git] / drivers / rtc / rtc-bfin.c
index d4fb82d..b4b6087 100644 (file)
@@ -2,7 +2,7 @@
  * Blackfin On-Chip Real Time Clock Driver
  *  Supports BF51x/BF52x/BF53[123]/BF53[467]/BF54x
  *
- * Copyright 2004-2009 Analog Devices Inc.
+ * Copyright 2004-2010 Analog Devices Inc.
  *
  * Enter bugs at http://blackfin.uclinux.org/
  *
@@ -183,29 +183,33 @@ static irqreturn_t bfin_rtc_interrupt(int irq, void *dev_id)
        struct bfin_rtc *rtc = dev_get_drvdata(dev);
        unsigned long events = 0;
        bool write_complete = false;
-       u16 rtc_istat, rtc_ictl;
+       u16 rtc_istat, rtc_istat_clear, rtc_ictl, bits;
 
        dev_dbg_stamp(dev);
 
        rtc_istat = bfin_read_RTC_ISTAT();
        rtc_ictl = bfin_read_RTC_ICTL();
+       rtc_istat_clear = 0;
 
-       if (rtc_istat & RTC_ISTAT_WRITE_COMPLETE) {
-               bfin_write_RTC_ISTAT(RTC_ISTAT_WRITE_COMPLETE);
+       bits = RTC_ISTAT_WRITE_COMPLETE;
+       if (rtc_istat & bits) {
+               rtc_istat_clear |= bits;
                write_complete = true;
                complete(&bfin_write_complete);
        }
 
-       if (rtc_ictl & (RTC_ISTAT_ALARM | RTC_ISTAT_ALARM_DAY)) {
-               if (rtc_istat & (RTC_ISTAT_ALARM | RTC_ISTAT_ALARM_DAY)) {
-                       bfin_write_RTC_ISTAT(RTC_ISTAT_ALARM | RTC_ISTAT_ALARM_DAY);
+       bits = (RTC_ISTAT_ALARM | RTC_ISTAT_ALARM_DAY);
+       if (rtc_ictl & bits) {
+               if (rtc_istat & bits) {
+                       rtc_istat_clear |= bits;
                        events |= RTC_AF | RTC_IRQF;
                }
        }
 
-       if (rtc_ictl & RTC_ISTAT_SEC) {
-               if (rtc_istat & RTC_ISTAT_SEC) {
-                       bfin_write_RTC_ISTAT(RTC_ISTAT_SEC);
+       bits = RTC_ISTAT_SEC;
+       if (rtc_ictl & bits) {
+               if (rtc_istat & bits) {
+                       rtc_istat_clear |= bits;
                        events |= RTC_UF | RTC_IRQF;
                }
        }
@@ -213,9 +217,10 @@ static irqreturn_t bfin_rtc_interrupt(int irq, void *dev_id)
        if (events)
                rtc_update_irq(rtc->rtc_dev, 1, events);
 
-       if (write_complete || events)
+       if (write_complete || events) {
+               bfin_write_RTC_ISTAT(rtc_istat_clear);
                return IRQ_HANDLED;
-       else
+       else
                return IRQ_NONE;
 }
 
@@ -422,9 +427,13 @@ static int __devexit bfin_rtc_remove(struct platform_device *pdev)
 #ifdef CONFIG_PM
 static int bfin_rtc_suspend(struct platform_device *pdev, pm_message_t state)
 {
-       if (device_may_wakeup(&pdev->dev)) {
+       struct device *dev = &pdev->dev;
+
+       dev_dbg_stamp(dev);
+
+       if (device_may_wakeup(dev)) {
                enable_irq_wake(IRQ_RTC);
-               bfin_rtc_sync_pending(&pdev->dev);
+               bfin_rtc_sync_pending(dev);
        } else
                bfin_rtc_int_clear(0);
 
@@ -433,7 +442,11 @@ static int bfin_rtc_suspend(struct platform_device *pdev, pm_message_t state)
 
 static int bfin_rtc_resume(struct platform_device *pdev)
 {
-       if (device_may_wakeup(&pdev->dev))
+       struct device *dev = &pdev->dev;
+
+       dev_dbg_stamp(dev);
+
+       if (device_may_wakeup(dev))
                disable_irq_wake(IRQ_RTC);
 
        /*