diff options
author | Atsushi Nemoto <anemo@mba.ocn.ne.jp> | 2005-11-02 11:01:15 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2005-11-07 13:05:38 -0500 |
commit | 53c2df2f4ebbc1d8231ca7cc13ac5381230888b1 (patch) | |
tree | a7446ec56dd877d77ef7318b4bcdc3d38555ff0a /arch/mips/ddb5xxx | |
parent | e329331aedeca0f2a7e15bd26a829ee1619c05e0 (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/ddb5xxx')
-rw-r--r-- | arch/mips/ddb5xxx/common/rtc_ds1386.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/arch/mips/ddb5xxx/common/rtc_ds1386.c b/arch/mips/ddb5xxx/common/rtc_ds1386.c index f5b11508ff2f..995896ac0e39 100644 --- a/arch/mips/ddb5xxx/common/rtc_ds1386.c +++ b/arch/mips/ddb5xxx/common/rtc_ds1386.c | |||
@@ -41,7 +41,9 @@ rtc_ds1386_get_time(void) | |||
41 | u8 byte; | 41 | u8 byte; |
42 | u8 temp; | 42 | u8 temp; |
43 | unsigned int year, month, day, hour, minute, second; | 43 | unsigned int year, month, day, hour, minute, second; |
44 | unsigned long flags; | ||
44 | 45 | ||
46 | spin_lock_irqsave(&rtc_lock, flags); | ||
45 | /* let us freeze external registers */ | 47 | /* let us freeze external registers */ |
46 | byte = READ_RTC(0xB); | 48 | byte = READ_RTC(0xB); |
47 | byte &= 0x3f; | 49 | byte &= 0x3f; |
@@ -60,6 +62,7 @@ rtc_ds1386_get_time(void) | |||
60 | /* enable time transfer */ | 62 | /* enable time transfer */ |
61 | byte |= 0x80; | 63 | byte |= 0x80; |
62 | WRITE_RTC(0xB, byte); | 64 | WRITE_RTC(0xB, byte); |
65 | spin_unlock_irqrestore(&rtc_lock, flags); | ||
63 | 66 | ||
64 | /* calc hour */ | 67 | /* calc hour */ |
65 | if (temp & 0x40) { | 68 | if (temp & 0x40) { |
@@ -81,7 +84,9 @@ rtc_ds1386_set_time(unsigned long t) | |||
81 | u8 byte; | 84 | u8 byte; |
82 | u8 temp; | 85 | u8 temp; |
83 | u8 year, month, day, hour, minute, second; | 86 | u8 year, month, day, hour, minute, second; |
87 | unsigned long flags; | ||
84 | 88 | ||
89 | spin_lock_irqsave(&rtc_lock, flags); | ||
85 | /* let us freeze external registers */ | 90 | /* let us freeze external registers */ |
86 | byte = READ_RTC(0xB); | 91 | byte = READ_RTC(0xB); |
87 | byte &= 0x3f; | 92 | byte &= 0x3f; |
@@ -133,6 +138,7 @@ rtc_ds1386_set_time(unsigned long t) | |||
133 | if (second != READ_RTC(0x1)) { | 138 | if (second != READ_RTC(0x1)) { |
134 | WRITE_RTC(0x1, second); | 139 | WRITE_RTC(0x1, second); |
135 | } | 140 | } |
141 | spin_unlock_irqrestore(&rtc_lock, flags); | ||
136 | 142 | ||
137 | return 0; | 143 | return 0; |
138 | } | 144 | } |