aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/lasat
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/lasat
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/lasat')
-rw-r--r--arch/mips/lasat/ds1603.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/arch/mips/lasat/ds1603.c b/arch/mips/lasat/ds1603.c
index 9d7812e03dcd..7dced67c55eb 100644
--- a/arch/mips/lasat/ds1603.c
+++ b/arch/mips/lasat/ds1603.c
@@ -8,6 +8,7 @@
8#include <asm/lasat/lasat.h> 8#include <asm/lasat/lasat.h>
9#include <linux/delay.h> 9#include <linux/delay.h>
10#include <asm/lasat/ds1603.h> 10#include <asm/lasat/ds1603.h>
11#include <asm/time.h>
11 12
12#include "ds1603.h" 13#include "ds1603.h"
13 14
@@ -138,19 +139,27 @@ static void rtc_end_op(void)
138unsigned long ds1603_read(void) 139unsigned long ds1603_read(void)
139{ 140{
140 unsigned long word; 141 unsigned long word;
142 unsigned long flags;
143
144 spin_lock_irqsave(&rtc_lock, flags);
141 rtc_init_op(); 145 rtc_init_op();
142 rtc_write_byte(READ_TIME_CMD); 146 rtc_write_byte(READ_TIME_CMD);
143 word = rtc_read_word(); 147 word = rtc_read_word();
144 rtc_end_op(); 148 rtc_end_op();
149 spin_unlock_irqrestore(&rtc_lock, flags);
145 return word; 150 return word;
146} 151}
147 152
148int ds1603_set(unsigned long time) 153int ds1603_set(unsigned long time)
149{ 154{
155 unsigned long flags;
156
157 spin_lock_irqsave(&rtc_lock, flags);
150 rtc_init_op(); 158 rtc_init_op();
151 rtc_write_byte(SET_TIME_CMD); 159 rtc_write_byte(SET_TIME_CMD);
152 rtc_write_word(time); 160 rtc_write_word(time);
153 rtc_end_op(); 161 rtc_end_op();
162 spin_unlock_irqrestore(&rtc_lock, flags);
154 163
155 return 0; 164 return 0;
156} 165}