Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtc: mc146818: Reduce spinlock section in mc146818_set_time()

No need to hold the lock and disable interrupts for doing math.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201206220541.709243630@linutronix.de

+2 -4
+2 -4
drivers/rtc/rtc-mc146818-lib.c
··· 135 135 if (yrs > 255) /* They are unsigned */ 136 136 return -EINVAL; 137 137 138 - spin_lock_irqsave(&rtc_lock, flags); 139 138 #ifdef CONFIG_MACH_DECSTATION 140 139 real_yrs = yrs; 141 140 leap_yr = ((!((yrs + 1900) % 4) && ((yrs + 1900) % 100)) || ··· 163 164 /* These limits and adjustments are independent of 164 165 * whether the chip is in binary mode or not. 165 166 */ 166 - if (yrs > 169) { 167 - spin_unlock_irqrestore(&rtc_lock, flags); 167 + if (yrs > 169) 168 168 return -EINVAL; 169 - } 170 169 171 170 if (yrs >= 100) 172 171 yrs -= 100; ··· 180 183 century = bin2bcd(century); 181 184 } 182 185 186 + spin_lock_irqsave(&rtc_lock, flags); 183 187 save_control = CMOS_READ(RTC_CONTROL); 184 188 CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL); 185 189 save_freq_select = CMOS_READ(RTC_FREQ_SELECT);