[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201206220541.709243630@linutronix.de>
Date: Sun, 06 Dec 2020 22:46:15 +0100
From: Thomas Gleixner <tglx@...utronix.de>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Alexandre Belloni <alexandre.belloni@...tlin.com>,
Jason Gunthorpe <jgg@...pe.ca>,
Miroslav Lichvar <mlichvar@...hat.com>,
John Stultz <john.stultz@...aro.org>,
Prarit Bhargava <prarit@...hat.com>,
Alessandro Zummo <a.zummo@...ertech.it>,
linux-rtc@...r.kernel.org, Peter Zijlstra <peterz@...radead.org>
Subject: [patch 2/8] 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@...utronix.de>
---
drivers/rtc/rtc-mc146818-lib.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
--- a/drivers/rtc/rtc-mc146818-lib.c
+++ b/drivers/rtc/rtc-mc146818-lib.c
@@ -135,7 +135,6 @@ int mc146818_set_time(struct rtc_time *t
if (yrs > 255) /* They are unsigned */
return -EINVAL;
- spin_lock_irqsave(&rtc_lock, flags);
#ifdef CONFIG_MACH_DECSTATION
real_yrs = yrs;
leap_yr = ((!((yrs + 1900) % 4) && ((yrs + 1900) % 100)) ||
@@ -164,10 +163,8 @@ int mc146818_set_time(struct rtc_time *t
/* These limits and adjustments are independent of
* whether the chip is in binary mode or not.
*/
- if (yrs > 169) {
- spin_unlock_irqrestore(&rtc_lock, flags);
+ if (yrs > 169)
return -EINVAL;
- }
if (yrs >= 100)
yrs -= 100;
@@ -183,6 +180,7 @@ int mc146818_set_time(struct rtc_time *t
century = bin2bcd(century);
}
+ spin_lock_irqsave(&rtc_lock, flags);
save_control = CMOS_READ(RTC_CONTROL);
CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
save_freq_select = CMOS_READ(RTC_FREQ_SELECT);
Powered by blists - more mailing lists