diff options
author | Atsushi Nemoto <anemo@mba.ocn.ne.jp> | 2005-11-02 17:01:15 +0100 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2005-11-07 19:05:38 +0100 |
commit | 53c2df2f4ebbc1d8231ca7cc13ac5381230888b1 (patch) | |
tree | a7446ec56dd877d77ef7318b4bcdc3d38555ff0a /arch/mips/lasat/ds1603.c | |
parent | Remove mips_rtc_lock (diff) | |
download | linux-53c2df2f4ebbc1d8231ca7cc13ac5381230888b1.tar.xz linux-53c2df2f4ebbc1d8231ca7cc13ac5381230888b1.zip |
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/ds1603.c')
-rw-r--r-- | arch/mips/lasat/ds1603.c | 9 |
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 @@ #include <asm/lasat/lasat.h> #include <linux/delay.h> #include <asm/lasat/ds1603.h> +#include <asm/time.h> #include "ds1603.h" @@ -138,19 +139,27 @@ static void rtc_end_op(void) unsigned long ds1603_read(void) { unsigned long word; + unsigned long flags; + + spin_lock_irqsave(&rtc_lock, flags); rtc_init_op(); rtc_write_byte(READ_TIME_CMD); word = rtc_read_word(); rtc_end_op(); + spin_unlock_irqrestore(&rtc_lock, flags); return word; } int ds1603_set(unsigned long time) { + unsigned long flags; + + spin_lock_irqsave(&rtc_lock, flags); rtc_init_op(); rtc_write_byte(SET_TIME_CMD); rtc_write_word(time); rtc_end_op(); + spin_unlock_irqrestore(&rtc_lock, flags); return 0; } |