diff mbox series

[2/7] Function to retrieve main clock state

Message ID 20201001205141.8885-3-erez.geva.ext@siemens.com
State New
Headers show
Series TC-ETF support PTP clocks series | expand

Commit Message

Geva, Erez Oct. 1, 2020, 8:51 p.m. UTC
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@siemens.com>
---
 include/linux/timex.h     | 1 +
 kernel/time/timekeeping.c | 9 +++++++++
 2 files changed, 10 insertions(+)

Comments

Thomas Gleixner Oct. 1, 2020, 10:05 p.m. UTC | #1
Erez,

On Thu, Oct 01 2020 at 22:51, Erez Geva wrote:

same comments as for patch 1 apply.

> Add kernel function to retrieve main clock oscillator state.

The function you are adding is named adjtimex(). adjtimex(2) is a well
known user space interface and naming a read only kernel interface the
same way is misleading.

Thanks,

        tglx
Thomas Gleixner Oct. 2, 2020, 12:19 a.m. UTC | #2
On Fri, Oct 02 2020 at 00:05, Thomas Gleixner wrote:
> On Thu, Oct 01 2020 at 22:51, Erez Geva wrote:
>
> same comments as for patch 1 apply.
>
>> Add kernel function to retrieve main clock oscillator state.
>
> The function you are adding is named adjtimex(). adjtimex(2) is a well
> known user space interface and naming a read only kernel interface the
> same way is misleading.

Aside of that there is no user for this function in this series. We're
not adding interfaces just because we can.

Thanks,

        tglx
diff mbox series

Patch

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