diff options
author | Haojian Zhuang <haojian.zhuang@marvell.com> | 2012-02-20 06:49:30 -0500 |
---|---|---|
committer | Haojian Zhuang <haojian.zhuang@marvell.com> | 2012-02-27 21:07:22 -0500 |
commit | 1d8c38c3d1b48eeb9cfaa42a8be13a1423569eb2 (patch) | |
tree | 60761409704fcfbf626ab861c29cb61fa2b621ef /drivers/rtc/rtc-sa1100.c | |
parent | 61ee93cd18c7f99236c17829d8fe65f56e8dd392 (diff) |
rtc: sa1100: remove verification code of alarm
Since next alarm time is already calculated in rtc common interface, we
needn't keep this logic in rtc-sa1100.c any more.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Diffstat (limited to 'drivers/rtc/rtc-sa1100.c')
-rw-r--r-- | drivers/rtc/rtc-sa1100.c | 66 |
1 files changed, 11 insertions, 55 deletions
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index fef52c801a13..91d58bdc7f88 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c | |||
@@ -44,54 +44,6 @@ | |||
44 | static const unsigned long RTC_FREQ = 1024; | 44 | static const unsigned long RTC_FREQ = 1024; |
45 | static DEFINE_SPINLOCK(sa1100_rtc_lock); | 45 | static DEFINE_SPINLOCK(sa1100_rtc_lock); |
46 | 46 | ||
47 | /* | ||
48 | * Calculate the next alarm time given the requested alarm time mask | ||
49 | * and the current time. | ||
50 | */ | ||
51 | static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now, | ||
52 | struct rtc_time *alrm) | ||
53 | { | ||
54 | unsigned long next_time; | ||
55 | unsigned long now_time; | ||
56 | |||
57 | next->tm_year = now->tm_year; | ||
58 | next->tm_mon = now->tm_mon; | ||
59 | next->tm_mday = now->tm_mday; | ||
60 | next->tm_hour = alrm->tm_hour; | ||
61 | next->tm_min = alrm->tm_min; | ||
62 | next->tm_sec = alrm->tm_sec; | ||
63 | |||
64 | rtc_tm_to_time(now, &now_time); | ||
65 | rtc_tm_to_time(next, &next_time); | ||
66 | |||
67 | if (next_time < now_time) { | ||
68 | /* Advance one day */ | ||
69 | next_time += 60 * 60 * 24; | ||
70 | rtc_time_to_tm(next_time, next); | ||
71 | } | ||
72 | } | ||
73 | |||
74 | static int rtc_update_alarm(struct rtc_time *alrm) | ||
75 | { | ||
76 | struct rtc_time alarm_tm, now_tm; | ||
77 | unsigned long now, time; | ||
78 | int ret; | ||
79 | |||
80 | do { | ||
81 | now = RCNR; | ||
82 | rtc_time_to_tm(now, &now_tm); | ||
83 | rtc_next_alarm_time(&alarm_tm, &now_tm, alrm); | ||
84 | ret = rtc_tm_to_time(&alarm_tm, &time); | ||
85 | if (ret != 0) | ||
86 | break; | ||
87 | |||
88 | RTSR = RTSR & (RTSR_HZE|RTSR_ALE|RTSR_AL); | ||
89 | RTAR = time; | ||
90 | } while (now != RCNR); | ||
91 | |||
92 | return ret; | ||
93 | } | ||
94 | |||
95 | static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) | 47 | static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) |
96 | { | 48 | { |
97 | struct platform_device *pdev = to_platform_device(dev_id); | 49 | struct platform_device *pdev = to_platform_device(dev_id); |
@@ -219,16 +171,20 @@ static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
219 | 171 | ||
220 | static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 172 | static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
221 | { | 173 | { |
174 | unsigned long time; | ||
222 | int ret; | 175 | int ret; |
223 | 176 | ||
224 | spin_lock_irq(&sa1100_rtc_lock); | 177 | spin_lock_irq(&sa1100_rtc_lock); |
225 | ret = rtc_update_alarm(&alrm->time); | 178 | ret = rtc_tm_to_time(&alrm->time, &time); |
226 | if (ret == 0) { | 179 | if (ret != 0) |
227 | if (alrm->enabled) | 180 | goto out; |
228 | RTSR |= RTSR_ALE; | 181 | RTSR = RTSR & (RTSR_HZE|RTSR_ALE|RTSR_AL); |
229 | else | 182 | RTAR = time; |
230 | RTSR &= ~RTSR_ALE; | 183 | if (alrm->enabled) |
231 | } | 184 | RTSR |= RTSR_ALE; |
185 | else | ||
186 | RTSR &= ~RTSR_ALE; | ||
187 | out: | ||
232 | spin_unlock_irq(&sa1100_rtc_lock); | 188 | spin_unlock_irq(&sa1100_rtc_lock); |
233 | 189 | ||
234 | return ret; | 190 | return ret; |