diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2012-01-19 06:50:40 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2012-01-19 12:26:26 -0500 |
commit | 57270fcdc7925def3c80d75344467dff2bec8025 (patch) | |
tree | f8eb7be1d287ccf80c00dc32b115ae6f82f3229f /drivers/rtc/rtc-sa1100.c | |
parent | a0164a574a3f284f438081c53fb864d275e54560 (diff) |
Revert "RTC: sa1100: remove redundant code of setting alarm"
This reverts commit 42874759d7494648e42e6e0465fc9c4f3752bba4.
This wasn't tested as a stand-alone patch, and it has build errors
without the following patches applied:
drivers/rtc/rtc-sa1100.c: In function 'sa1100_rtc_set_alarm':
drivers/rtc/rtc-sa1100.c:208: error: 'now' undeclared (first use in this function)
drivers/rtc/rtc-sa1100.c:208: error: (Each undeclared identifier is reported only once
drivers/rtc/rtc-sa1100.c:208: error: for each function it appears in.)
drivers/rtc/rtc-sa1100.c:210: error: incompatible type for argument 3 of 'rtc_next_alarm_time'
drivers/rtc/rtc-sa1100.c:211: error: 'time' undeclared (first use in this function)
So it too gets reverted to bring us back to a working point.
Diffstat (limited to 'drivers/rtc/rtc-sa1100.c')
-rw-r--r-- | drivers/rtc/rtc-sa1100.c | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index 9683daf56d8e..cb9a585312cc 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c | |||
@@ -45,6 +45,16 @@ static const unsigned long RTC_FREQ = 1024; | |||
45 | static struct rtc_time rtc_alarm; | 45 | static struct rtc_time rtc_alarm; |
46 | static DEFINE_SPINLOCK(sa1100_rtc_lock); | 46 | static DEFINE_SPINLOCK(sa1100_rtc_lock); |
47 | 47 | ||
48 | static inline int rtc_periodic_alarm(struct rtc_time *tm) | ||
49 | { | ||
50 | return (tm->tm_year == -1) || | ||
51 | ((unsigned)tm->tm_mon >= 12) || | ||
52 | ((unsigned)(tm->tm_mday - 1) >= 31) || | ||
53 | ((unsigned)tm->tm_hour > 23) || | ||
54 | ((unsigned)tm->tm_min > 59) || | ||
55 | ((unsigned)tm->tm_sec > 59); | ||
56 | } | ||
57 | |||
48 | /* | 58 | /* |
49 | * Calculate the next alarm time given the requested alarm time mask | 59 | * Calculate the next alarm time given the requested alarm time mask |
50 | * and the current time. | 60 | * and the current time. |
@@ -72,6 +82,27 @@ static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now, | |||
72 | } | 82 | } |
73 | } | 83 | } |
74 | 84 | ||
85 | static int rtc_update_alarm(struct rtc_time *alrm) | ||
86 | { | ||
87 | struct rtc_time alarm_tm, now_tm; | ||
88 | unsigned long now, time; | ||
89 | int ret; | ||
90 | |||
91 | do { | ||
92 | now = RCNR; | ||
93 | rtc_time_to_tm(now, &now_tm); | ||
94 | rtc_next_alarm_time(&alarm_tm, &now_tm, alrm); | ||
95 | ret = rtc_tm_to_time(&alarm_tm, &time); | ||
96 | if (ret != 0) | ||
97 | break; | ||
98 | |||
99 | RTSR = RTSR & (RTSR_HZE|RTSR_ALE|RTSR_AL); | ||
100 | RTAR = time; | ||
101 | } while (now != RCNR); | ||
102 | |||
103 | return ret; | ||
104 | } | ||
105 | |||
75 | static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) | 106 | static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) |
76 | { | 107 | { |
77 | struct platform_device *pdev = to_platform_device(dev_id); | 108 | struct platform_device *pdev = to_platform_device(dev_id); |
@@ -115,6 +146,9 @@ static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) | |||
115 | 146 | ||
116 | rtc_update_irq(rtc, 1, events); | 147 | rtc_update_irq(rtc, 1, events); |
117 | 148 | ||
149 | if (rtsr & RTSR_AL && rtc_periodic_alarm(&rtc_alarm)) | ||
150 | rtc_update_alarm(&rtc_alarm); | ||
151 | |||
118 | spin_unlock(&sa1100_rtc_lock); | 152 | spin_unlock(&sa1100_rtc_lock); |
119 | 153 | ||
120 | return IRQ_HANDLED; | 154 | return IRQ_HANDLED; |
@@ -200,21 +234,16 @@ static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
200 | 234 | ||
201 | static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 235 | static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
202 | { | 236 | { |
203 | struct rtc_time now_tm, alarm_tm; | ||
204 | int ret; | 237 | int ret; |
205 | 238 | ||
206 | spin_lock_irq(&sa1100_rtc_lock); | 239 | spin_lock_irq(&sa1100_rtc_lock); |
207 | 240 | ret = rtc_update_alarm(&alrm->time); | |
208 | now = RCNR; | 241 | if (ret == 0) { |
209 | rtc_time_to_tm(now, &now_tm); | 242 | if (alrm->enabled) |
210 | rtc_next_alarm_time(&alarm_tm, &now_tm, alrm->time); | 243 | RTSR |= RTSR_ALE; |
211 | rtc_tm_to_time(&alarm_tm, &time); | 244 | else |
212 | RTAR = time; | 245 | RTSR &= ~RTSR_ALE; |
213 | if (alrm->enabled) | 246 | } |
214 | RTSR |= RTSR_ALE; | ||
215 | else | ||
216 | RTSR &= ~RTSR_ALE; | ||
217 | |||
218 | spin_unlock_irq(&sa1100_rtc_lock); | 247 | spin_unlock_irq(&sa1100_rtc_lock); |
219 | 248 | ||
220 | return ret; | 249 | return ret; |