]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/mips/momentum/jaguar_atx/setup.c
Use rtc_lock to protect RTC operations
[linux-2.6-omap-h63xx.git] / arch / mips / momentum / jaguar_atx / setup.c
index 768bf4406452ecc0a7855942affee8316c498eda..bab192ddc1850b81957094058d240369523736fc 100644 (file)
@@ -149,7 +149,9 @@ arch_initcall(per_cpu_mappings);
 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 */
        rtc_base[0x7ff8] = 0x40;
 
@@ -166,6 +168,7 @@ unsigned long m48t37y_get_time(void)
 
        /* start the update */
        rtc_base[0x7ff8] = 0x00;
+       spin_unlock_irqrestore(&rtc_lock, flags);
 
        return mktime(year, month, day, hour, min, sec);
 }
@@ -173,11 +176,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 */
        rtc_base[0x7ff8] = 0x80;
 
@@ -201,6 +206,7 @@ int m48t37y_set_time(unsigned long sec)
 
        /* disable writing */
        rtc_base[0x7ff8] = 0x00;
+       spin_unlock_irqrestore(&rtc_lock, flags);
 
        return 0;
 }