Skip to contentSkip to conversation

hwclock: use CMOS clock only if available

PATCH New [email protected] 1 participant 1 message Jul 3, 2019 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 hwclock: use CMOS clock only if available

From: Carlos Santos <[email protected]>

- Add --disable-hwclock-cmos configuration argument
- Add USE_HWCLOCK_CMOS (enabled by default for i386/x86_64)
- Add define(USE_HWCLOCK_CMOS)
- Compile hwclock-cmos.c only if USE_HWCLOCK_CMOS is true
- Remove all unnecessary #ifdefs from hwclock-cmos.c
- Add #ifdef USE_HWCLOCK_CMOS around the determine_clock_access_method() call in hwclock.c

---
TODO: find a way to check the architecture in configure.ac and set USE_HWCLOCK_CMOS to true inly if it's i386/x86_64.

---
 configure.ac             | 13 +++++++++++
 sys-utils/Makemodule.am  |  7 ++++--
 sys-utils/hwclock-cmos.c | 47 +++++-----------------------------------
 sys-utils/hwclock.c      |  2 ++
 4 files changed, 26 insertions(+), 43 deletions(-)
configure.ac +13 -0
index a840e20ee..f5b9d4a4e 100644
@@ -1516,6 +1516,19 @@ UL_REQUIRES_HAVE([hwclock], [io, linuxdummy], [ioperm iopl function or Linux])
 AM_CONDITIONAL([BUILD_HWCLOCK], [test "x$build_hwclock" = xyes])
 
 
+AC_ARG_ENABLE([hwclock-cmos],
+  AS_HELP_STRING([--disable-hwclock-cmos], [do not use CMOS clock]),
+  [], [use_hwclock_cmos="$build_hwclock"]
+)
+
+AS_IF([test "x$use_hwclock_cmos" = xyes], [
+  AM_CONDITIONAL([USE_HWCLOCK_CMOS], [true])
+  AC_DEFINE([USE_HWCLOCK_CMOS], [1], [Define to 1 if want to use CMOS clock.])
+],[
+  AM_CONDITIONAL([USE_HWCLOCK_CMOS], [false])
+])
+
+
 UL_BUILD_INIT([mkfs], [yes])
 AM_CONDITIONAL([BUILD_MKFS], [test "x$build_mkfs" = xyes])
 
sys-utils/Makemodule.am +5 -2
index 7c118a6de..98e2cc29b 100644
@@ -451,9 +451,12 @@ dist_man_MANS += \
 PATHFILES += sys-utils/hwclock.8
 hwclock_SOURCES = \
 	sys-utils/hwclock.c \
-	sys-utils/hwclock.h \
-	sys-utils/hwclock-cmos.c
+	sys-utils/hwclock.h
 hwclock_LDADD = $(LDADD) libcommon.la -lm
+if USE_HWCLOCK_CMOS
+hwclock_SOURCES += \
+	sys-utils/hwclock-cmos.c
+endif
 if LINUX
 hwclock_SOURCES += \
 	sys-utils/hwclock-rtc.c \
sys-utils/hwclock-cmos.c +6 -41

71 lines not on this page · raw message

sys-utils/hwclock.c +2 -0
index a2c5cc2a4..c01a86826 100644
@@ -925,8 +925,10 @@ static void determine_clock_access_method(const struct hwclock_control *ctl)
 {
 	ur = NULL;
 
+#ifdef USE_HWCLOCK_CMOS
 	if (ctl->directisa)
 		ur = probe_for_cmos_clock();
+#endif
 #ifdef __linux__
 	if (!ur)
 		ur = probe_for_rtc_clock(ctl);
Signature · 1 line
2.18.1