[PATCH 2/7] Function to retrieve main clock state

From: Erez Geva
Date: Thu Oct 01 2020 - 17:01:47 EST


Add kernel function to retrieve main clock oscillator state.
As calibration is done from user space daemon,
the kernel access function permit read only.

Signed-off-by: Erez Geva <erez.geva.ext@xxxxxxxxxxx>
---
include/linux/timex.h | 1 +
kernel/time/timekeeping.c | 9 +++++++++
2 files changed, 10 insertions(+)

diff --git a/include/linux/timex.h b/include/linux/timex.h
index ce0859763670..03bc63bf3073 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -153,6 +153,7 @@ extern unsigned long tick_nsec; /* SHIFTED_HZ period (nsec) */

extern int do_adjtimex(struct __kernel_timex *);
extern int do_clock_adjtime(const clockid_t which_clock, struct __kernel_timex * ktx);
+extern int adjtimex(struct __kernel_timex *txc);

extern void hardpps(const struct timespec64 *, const struct timespec64 *);

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 4c47f388a83f..2248fa257ff8 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -2372,6 +2372,15 @@ int do_adjtimex(struct __kernel_timex *txc)
return ret;
}

+int adjtimex(struct __kernel_timex *txc)
+{
+ if (txc->modes != 0)
+ return -EINVAL;
+
+ return do_adjtimex(txc);
+}
+EXPORT_SYMBOL_GPL(adjtimex);
+
#ifdef CONFIG_NTP_PPS
/**
* hardpps() - Accessor function to NTP __hardpps function
--
2.20.1