aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/momentum/jaguar_atx
diff options
context:
space:
mode:
authorAtsushi Nemoto <anemo@mba.ocn.ne.jp>2005-11-02 11:01:15 -0500
committerRalf Baechle <ralf@linux-mips.org>2005-11-07 13:05:38 -0500
commit53c2df2f4ebbc1d8231ca7cc13ac5381230888b1 (patch)
treea7446ec56dd877d77ef7318b4bcdc3d38555ff0a /arch/mips/momentum/jaguar_atx
parente329331aedeca0f2a7e15bd26a829ee1619c05e0 (diff)
Use rtc_lock to protect RTC operations
Many RTC routines were not protected against each other, so there are potential races, for example, ntp-update against /dev/rtc. This patch fixes them using rtc_lock. Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/momentum/jaguar_atx')
-rw-r--r--arch/mips/momentum/jaguar_atx/setup.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/arch/mips/momentum/jaguar_atx/setup.c b/arch/mips/momentum/jaguar_atx/setup.c
index 768bf4406452..bab192ddc185 100644
--- a/arch/mips/momentum/jaguar_atx/setup.c
+++ b/arch/mips/momentum/jaguar_atx/setup.c
@@ -149,7 +149,9 @@ arch_initcall(per_cpu_mappings);
149unsigned long m48t37y_get_time(void) 149unsigned long m48t37y_get_time(void)
150{ 150{
151 unsigned int year, month, day, hour, min, sec; 151 unsigned int year, month, day, hour, min, sec;
152 unsigned long flags;
152 153
154 spin_lock_irqsave(&rtc_lock, flags);
153 /* stop the update */ 155 /* stop the update */
154 rtc_base[0x7ff8] = 0x40; 156 rtc_base[0x7ff8] = 0x40;
155 157
@@ -166,6 +168,7 @@ unsigned long m48t37y_get_time(void)
166 168
167 /* start the update */ 169 /* start the update */
168 rtc_base[0x7ff8] = 0x00; 170 rtc_base[0x7ff8] = 0x00;
171 spin_unlock_irqrestore(&rtc_lock, flags);
169 172
170 return mktime(year, month, day, hour, min, sec); 173 return mktime(year, month, day, hour, min, sec);
171} 174}
@@ -173,11 +176,13 @@ unsigned long m48t37y_get_time(void)
173int m48t37y_set_time(unsigned long sec) 176int m48t37y_set_time(unsigned long sec)
174{ 177{
175 struct rtc_time tm; 178 struct rtc_time tm;
179 unsigned long flags;
176 180
177 /* convert to a more useful format -- note months count from 0 */ 181 /* convert to a more useful format -- note months count from 0 */
178 to_tm(sec, &tm); 182 to_tm(sec, &tm);
179 tm.tm_mon += 1; 183 tm.tm_mon += 1;
180 184
185 spin_lock_irqsave(&rtc_lock, flags);
181 /* enable writing */ 186 /* enable writing */
182 rtc_base[0x7ff8] = 0x80; 187 rtc_base[0x7ff8] = 0x80;
183 188
@@ -201,6 +206,7 @@ int m48t37y_set_time(unsigned long sec)
201 206
202 /* disable writing */ 207 /* disable writing */
203 rtc_base[0x7ff8] = 0x00; 208 rtc_base[0x7ff8] = 0x00;
209 spin_unlock_irqrestore(&rtc_lock, flags);
204 210
205 return 0; 211 return 0;
206} 212}