diff options
author | Jett.Zhou <jtzhou@marvell.com> | 2011-11-29 23:26:22 -0500 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2011-12-28 05:42:33 -0500 |
commit | 42874759d7494648e42e6e0465fc9c4f3752bba4 (patch) | |
tree | 0bc18d7f9c551d13f1919c5d098e4bf4e6cdc093 /drivers | |
parent | 9d2d94385327f98ea69c183bb6c1d27cac49abf0 (diff) |
RTC: sa1100: remove redundant code of setting alarm
In rtc generic interface of setting alarm, it will check the alarm time
value valid or not, so rtc_periodic_alarm is redundant, remove it.
Signed-off-by: Jett.Zhou <jtzhou@marvell.com>
Acked-by: Haojian Zhuang <haojian.zhuang@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/rtc/rtc-sa1100.c | 53 |
1 files changed, 12 insertions, 41 deletions
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index 6f22c1fdff66..d268cf11b367 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c | |||
@@ -45,16 +45,6 @@ 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 | |||
58 | /* | 48 | /* |
59 | * Calculate the next alarm time given the requested alarm time mask | 49 | * Calculate the next alarm time given the requested alarm time mask |
60 | * and the current time. | 50 | * and the current time. |
@@ -82,27 +72,6 @@ static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now, | |||
82 | } | 72 | } |
83 | } | 73 | } |
84 | 74 | ||
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 | |||
106 | static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) | 75 | static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) |
107 | { | 76 | { |
108 | struct platform_device *pdev = to_platform_device(dev_id); | 77 | struct platform_device *pdev = to_platform_device(dev_id); |
@@ -146,9 +115,6 @@ static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) | |||
146 | 115 | ||
147 | rtc_update_irq(rtc, 1, events); | 116 | rtc_update_irq(rtc, 1, events); |
148 | 117 | ||
149 | if (rtsr & RTSR_AL && rtc_periodic_alarm(&rtc_alarm)) | ||
150 | rtc_update_alarm(&rtc_alarm); | ||
151 | |||
152 | spin_unlock(&sa1100_rtc_lock); | 118 | spin_unlock(&sa1100_rtc_lock); |
153 | 119 | ||
154 | return IRQ_HANDLED; | 120 | return IRQ_HANDLED; |
@@ -234,16 +200,21 @@ static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
234 | 200 | ||
235 | static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 201 | static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
236 | { | 202 | { |
203 | struct rtc_time now_tm, alarm_tm; | ||
237 | int ret; | 204 | int ret; |
238 | 205 | ||
239 | spin_lock_irq(&sa1100_rtc_lock); | 206 | spin_lock_irq(&sa1100_rtc_lock); |
240 | ret = rtc_update_alarm(&alrm->time); | 207 | |
241 | if (ret == 0) { | 208 | now = RCNR; |
242 | if (alrm->enabled) | 209 | rtc_time_to_tm(now, &now_tm); |
243 | RTSR |= RTSR_ALE; | 210 | rtc_next_alarm_time(&alarm_tm, &now_tm, alrm->time); |
244 | else | 211 | rtc_tm_to_time(&alarm_tm, &time); |
245 | RTSR &= ~RTSR_ALE; | 212 | RTAR = time; |
246 | } | 213 | if (alrm->enabled) |
214 | RTSR |= RTSR_ALE; | ||
215 | else | ||
216 | RTSR &= ~RTSR_ALE; | ||
217 | |||
247 | spin_unlock_irq(&sa1100_rtc_lock); | 218 | spin_unlock_irq(&sa1100_rtc_lock); |
248 | 219 | ||
249 | return ret; | 220 | return ret; |