aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/sgi-ip22
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/sgi-ip22
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/sgi-ip22')
-rw-r--r--arch/mips/sgi-ip22/ip22-time.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/arch/mips/sgi-ip22/ip22-time.c b/arch/mips/sgi-ip22/ip22-time.c
index df9b5694328a..b7300cc5c5ad 100644
--- a/arch/mips/sgi-ip22/ip22-time.c
+++ b/arch/mips/sgi-ip22/ip22-time.c
@@ -35,7 +35,9 @@ static unsigned long indy_rtc_get_time(void)
35{ 35{
36 unsigned int yrs, mon, day, hrs, min, sec; 36 unsigned int yrs, mon, day, hrs, min, sec;
37 unsigned int save_control; 37 unsigned int save_control;
38 unsigned long flags;
38 39
40 spin_lock_irqsave(&rtc_lock, flags);
39 save_control = hpc3c0->rtcregs[RTC_CMD] & 0xff; 41 save_control = hpc3c0->rtcregs[RTC_CMD] & 0xff;
40 hpc3c0->rtcregs[RTC_CMD] = save_control | RTC_TE; 42 hpc3c0->rtcregs[RTC_CMD] = save_control | RTC_TE;
41 43
@@ -47,6 +49,7 @@ static unsigned long indy_rtc_get_time(void)
47 yrs = BCD2BIN(hpc3c0->rtcregs[RTC_YEAR] & 0xff); 49 yrs = BCD2BIN(hpc3c0->rtcregs[RTC_YEAR] & 0xff);
48 50
49 hpc3c0->rtcregs[RTC_CMD] = save_control; 51 hpc3c0->rtcregs[RTC_CMD] = save_control;
52 spin_unlock_irqrestore(&rtc_lock, flags);
50 53
51 if (yrs < 45) 54 if (yrs < 45)
52 yrs += 30; 55 yrs += 30;
@@ -60,6 +63,7 @@ static int indy_rtc_set_time(unsigned long tim)
60{ 63{
61 struct rtc_time tm; 64 struct rtc_time tm;
62 unsigned int save_control; 65 unsigned int save_control;
66 unsigned long flags;
63 67
64 to_tm(tim, &tm); 68 to_tm(tim, &tm);
65 69
@@ -68,6 +72,7 @@ static int indy_rtc_set_time(unsigned long tim)
68 if (tm.tm_year >= 100) 72 if (tm.tm_year >= 100)
69 tm.tm_year -= 100; 73 tm.tm_year -= 100;
70 74
75 spin_lock_irqsave(&rtc_lock, flags);
71 save_control = hpc3c0->rtcregs[RTC_CMD] & 0xff; 76 save_control = hpc3c0->rtcregs[RTC_CMD] & 0xff;
72 hpc3c0->rtcregs[RTC_CMD] = save_control | RTC_TE; 77 hpc3c0->rtcregs[RTC_CMD] = save_control | RTC_TE;
73 78
@@ -80,6 +85,7 @@ static int indy_rtc_set_time(unsigned long tim)
80 hpc3c0->rtcregs[RTC_HUNDREDTH_SECOND] = 0; 85 hpc3c0->rtcregs[RTC_HUNDREDTH_SECOND] = 0;
81 86
82 hpc3c0->rtcregs[RTC_CMD] = save_control; 87 hpc3c0->rtcregs[RTC_CMD] = save_control;
88 spin_unlock_irqrestore(&rtc_lock, flags);
83 89
84 return 0; 90 return 0;
85} 91}