Skip to contentSkip to conversation

time: Add the common weak version of update_persistent_clock()

PATCH Superseded Xunlei Pang 2 participants 3 messages Jul 26, 2015 Timekeeping, clocksource core, NTP, alarmtimer

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 time: Add the common weak version of update_persistent_clock()

From: Xunlei Pang <[email protected]>

The weak update_persistent_clock64() calls update_persistent_clock(), if the architecture defines a update_persistent_clock64() to replace and remove its update_persistent_clock() version, the compiler will throw an undefined symbol error, that is, any arch that switches to update_persistent_clock64() will have this issue.

So, we should add the common weak update_persistent_clock().

Cc John Stultz <[email protected]>
Cc Arnd Bergmann <[email protected]>
---
 kernel/time/ntp.c | 5 +++++
 1 file changed, 5 insertions(+)
kernel/time/ntp.c +5 -0
index fb4d98c..df68cb8 100644
@@ -487,6 +487,11 @@ out:
 }
 
 #ifdef CONFIG_GENERIC_CMOS_UPDATE
+int __weak update_persistent_clock(struct timespec now)
+{
+	return -ENODEV;
+}
+
 int __weak update_persistent_clock64(struct timespec64 now64)
 {
 	struct timespec now;
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 2/2 mn10300: time: Provide 64-bit persistent clock time

From: Xunlei Pang <[email protected]>

As part of addressing the "y2038 problem" for in-kernel uses, convert update_persistent_clock() to update_persistent_clock64(), read_persistent_clock() to read_persistent_clock64() using timespec64 for MN10300.

Cc John Stultz <[email protected]>
Cc Arnd Bergmann <[email protected]>
---
 arch/mn10300/kernel/rtc.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
arch/mn10300/kernel/rtc.c +6 -7
index 48d7058..038ae16 100644
@@ -23,19 +23,19 @@ EXPORT_SYMBOL(rtc_lock);
 /*
  * Read the current RTC time
  */
-void read_persistent_clock(struct timespec *ts)
+void read_persistent_clock64(struct timespec64 *ts)
 {
 	struct rtc_time tm;
 
 	get_rtc_time(&tm);
 
 	ts->tv_nsec = 0;
-	ts->tv_sec = mktime(tm.tm_year, tm.tm_mon, tm.tm_mday,
+	ts->tv_sec = mktime64(tm.tm_year, tm.tm_mon, tm.tm_mday,
 			    tm.tm_hour, tm.tm_min, tm.tm_sec);
 
 	/* if rtc is way off in the past, set something reasonable */
 	if (ts->tv_sec < 0)
-		ts->tv_sec = mktime(2009, 1, 1, 12, 0, 0);
+		ts->tv_sec = mktime64(2009, 1, 1, 12, 0, 0);
 }
 
 /*
@@ -48,7 +48,7 @@ void read_persistent_clock(struct timespec *ts)
  * BUG: This routine does not handle hour overflow properly; it just
  *      sets the minutes. Usually you'll only notice that after reboot!
  */
-static int set_rtc_mmss(unsigned long nowtime)
+static int set_rtc_mmss(time64_t nowtime)
 {
 	unsigned char save_control, save_freq_select;
 	int retval = 0;
@@ -74,8 +74,7 @@ static int set_rtc_mmss(unsigned long nowtime)
 	 * messing with unknown time zones but requires your
 	 * RTC not to be off by more than 15 minutes
 	 */
-	real_seconds = nowtime % 60;
-	real_minutes = nowtime / 60;
+	real_minutes = div_s64_rem(nowtime, 60, &real_seconds);
 	if (((abs(real_minutes - cmos_minutes) + 15) / 30) & 1)
 		/* correct for half hour time zone */
 		real_minutes += 30;
@@ -109,7 +108,7 @@ static int set_rtc_mmss(unsigned long nowtime)
 	return retval;
 }
 
-int update_persistent_clock(struct timespec now)
+int update_persistent_clock64(struct timespec64 now)
 {
 	return set_rtc_mmss(now.tv_sec);
 }
Signature · 1 line
1.9.1
#2 lore raw
In reply to Xunlei Pang
Quoted 5 lines · Xunlei Pang

From: Xunlei Pang <[email protected]>

The weak update_persistent_clock64() calls update_persistent_clock(), if the architecture defines a update_persistent_clock64() to replace and remove its update_persistent_clock() version, the compiler will

s/compiler/linker/ right?

Quoted 4 lines

throw an undefined symbol error, that is, any arch that switches to update_persistent_clock64() will have this issue.

So, we should add the common weak update_persistent_clock().

Are we adding it or should we add it?

Thanks,

tglx