Commit dcf257e9 authored by Thomas Gleixner's avatar Thomas Gleixner

rtc: mc146818: Reduce spinlock section in mc146818_set_time()

No need to hold the lock and disable interrupts for doing math.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Acked-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201206220541.709243630@linutronix.de
parent 05a0302c
...@@ -135,7 +135,6 @@ int mc146818_set_time(struct rtc_time *time) ...@@ -135,7 +135,6 @@ int mc146818_set_time(struct rtc_time *time)
if (yrs > 255) /* They are unsigned */ if (yrs > 255) /* They are unsigned */
return -EINVAL; return -EINVAL;
spin_lock_irqsave(&rtc_lock, flags);
#ifdef CONFIG_MACH_DECSTATION #ifdef CONFIG_MACH_DECSTATION
real_yrs = yrs; real_yrs = yrs;
leap_yr = ((!((yrs + 1900) % 4) && ((yrs + 1900) % 100)) || leap_yr = ((!((yrs + 1900) % 4) && ((yrs + 1900) % 100)) ||
...@@ -164,10 +163,8 @@ int mc146818_set_time(struct rtc_time *time) ...@@ -164,10 +163,8 @@ int mc146818_set_time(struct rtc_time *time)
/* These limits and adjustments are independent of /* These limits and adjustments are independent of
* whether the chip is in binary mode or not. * whether the chip is in binary mode or not.
*/ */
if (yrs > 169) { if (yrs > 169)
spin_unlock_irqrestore(&rtc_lock, flags);
return -EINVAL; return -EINVAL;
}
if (yrs >= 100) if (yrs >= 100)
yrs -= 100; yrs -= 100;
...@@ -183,6 +180,7 @@ int mc146818_set_time(struct rtc_time *time) ...@@ -183,6 +180,7 @@ int mc146818_set_time(struct rtc_time *time)
century = bin2bcd(century); century = bin2bcd(century);
} }
spin_lock_irqsave(&rtc_lock, flags);
save_control = CMOS_READ(RTC_CONTROL); save_control = CMOS_READ(RTC_CONTROL);
CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL); CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
save_freq_select = CMOS_READ(RTC_FREQ_SELECT); save_freq_select = CMOS_READ(RTC_FREQ_SELECT);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment