diff options
author | Haavard Skinnemoen <haavard.skinnemoen@atmel.com> | 2008-06-12 15:21:38 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-06-12 18:05:40 -0700 |
commit | 529a4f4ec90ffd9394fdfc22bea7a858ae343171 (patch) | |
tree | b73ef0d578f67a63113e57871e465b9e4bae17e3 /drivers/rtc/rtc-at32ap700x.c | |
parent | 6c38d8578545482fe45d6e6ea37be02a2e1bb289 (diff) | |
download | blackbird-op-linux-529a4f4ec90ffd9394fdfc22bea7a858ae343171.tar.gz blackbird-op-linux-529a4f4ec90ffd9394fdfc22bea7a858ae343171.zip |
rtc-at32ap700x: fix bug in at32_rtc_readalarm()
alarm->pending indicates whether there's an alarm that has actually been
triggered, not whether we're waiting for it. alarm->enabled indicates
that.
Also add missing locking around reading the RTC registers.
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
Cc: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
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>
Diffstat (limited to 'drivers/rtc/rtc-at32ap700x.c')
-rw-r--r-- | drivers/rtc/rtc-at32ap700x.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/rtc/rtc-at32ap700x.c b/drivers/rtc/rtc-at32ap700x.c index 42244f14b41c..2ef8cdfda4a7 100644 --- a/drivers/rtc/rtc-at32ap700x.c +++ b/drivers/rtc/rtc-at32ap700x.c @@ -94,8 +94,11 @@ static int at32_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm) { struct rtc_at32ap700x *rtc = dev_get_drvdata(dev); + spin_lock_irq(&rtc->lock); rtc_time_to_tm(rtc->alarm_time, &alrm->time); - alrm->pending = rtc_readl(rtc, IMR) & RTC_BIT(IMR_TOPI) ? 1 : 0; + alrm->enabled = rtc_readl(rtc, IMR) & RTC_BIT(IMR_TOPI) ? 1 : 0; + alrm->pending = rtc_readl(rtc, ISR) & RTC_BIT(ISR_TOPI) ? 1 : 0; + spin_unlock_irq(&rtc->lock); return 0; } @@ -119,7 +122,7 @@ static int at32_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) spin_lock_irq(&rtc->lock); rtc->alarm_time = alarm_unix_time; rtc_writel(rtc, TOP, rtc->alarm_time); - if (alrm->pending) + if (alrm->enabled) rtc_writel(rtc, CTRL, rtc_readl(rtc, CTRL) | RTC_BIT(CTRL_TOPEN)); else |