diff options
author | Atsushi Nemoto <anemo@mba.ocn.ne.jp> | 2005-11-03 01:01:15 +0900 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2005-11-07 18:05:38 +0000 |
commit | 53c2df2f4ebbc1d8231ca7cc13ac5381230888b1 (patch) | |
tree | a7446ec56dd877d77ef7318b4bcdc3d38555ff0a /arch/mips/pmc-sierra | |
parent | e329331aedeca0f2a7e15bd26a829ee1619c05e0 (diff) | |
download | talos-obmc-linux-53c2df2f4ebbc1d8231ca7cc13ac5381230888b1.tar.gz talos-obmc-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/pmc-sierra')
-rw-r--r-- | arch/mips/pmc-sierra/yosemite/setup.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/arch/mips/pmc-sierra/yosemite/setup.c b/arch/mips/pmc-sierra/yosemite/setup.c index bdc2ab55bed6..059755b5ed57 100644 --- a/arch/mips/pmc-sierra/yosemite/setup.c +++ b/arch/mips/pmc-sierra/yosemite/setup.c @@ -73,7 +73,9 @@ void __init bus_error_init(void) unsigned long m48t37y_get_time(void) { unsigned int year, month, day, hour, min, sec; + unsigned long flags; + spin_lock_irqsave(&rtc_lock, flags); /* Stop the update to the time */ m48t37_base->control = 0x40; @@ -88,6 +90,7 @@ unsigned long m48t37y_get_time(void) /* Start the update to the time again */ m48t37_base->control = 0x00; + spin_unlock_irqrestore(&rtc_lock, flags); return mktime(year, month, day, hour, min, sec); } @@ -95,11 +98,13 @@ unsigned long m48t37y_get_time(void) int m48t37y_set_time(unsigned long sec) { struct rtc_time tm; + unsigned long flags; /* convert to a more useful format -- note months count from 0 */ to_tm(sec, &tm); tm.tm_mon += 1; + spin_lock_irqsave(&rtc_lock, flags); /* enable writing */ m48t37_base->control = 0x80; @@ -123,6 +128,7 @@ int m48t37y_set_time(unsigned long sec) /* disable writing */ m48t37_base->control = 0x00; + spin_unlock_irqrestore(&rtc_lock, flags); return 0; } |