ntp: Remove redundant arguments
PATCH 1/3 ntp: Remove redundant arguments
The 'ts' argument of process_adj_status() and process_adjtimex_modes() is unused and can be safely removed.
Signed-off-by Ondrej Mosnacek <[email protected]>
--- kernel/time/ntp.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
kernel/time/ntp.c +4 -6
@@ -642,7 +642,7 @@ void ntp_notify_cmos_timer(void)/* * Propagate a new txc->status value into the NTP state: */ -static inline void process_adj_status (struct timex *txc,struct timespec64 *ts) +static inline void process_adj_status (struct timex *txc) {if ((time_status &STA_PLL ) && !(txc->status &STA_PLL )) { time_state =TIME_OK ;
@@ -665,12 +665,10 @@ static inline void process_adj_status(struct timex *txc, struct timespec64 *ts) } -static inline void process_adjtimex_modes (struct timex *txc, -struct timespec64 *ts, -s32 *time_tai) +static inline void process_adjtimex_modes (struct timex *txc,s32 *time_tai) {if (txc->modes &ADJ_STATUS ) -process_adj_status (txc, ts); +process_adj_status (txc);if (txc->modes &ADJ_NANO ) time_status |=STA_NANO ;
@@ -735,7 +733,7 @@ int __do_adjtimex(struct timex *txc, struct timespec64 *ts, s32 *time_tai)/* If there are input parameters, then process them: */ if (txc->modes) -process_adjtimex_modes (txc, ts, time_tai); +process_adjtimex_modes (txc, time_tai); txc->offset =shift_right (time_offset *NTP_INTERVAL_FREQ ,NTP_SCALE_SHIFT );
Signature · 1 line
2.17.1
PATCH 2/3 ntp: Use kstrtos64 for s64 variable
...instead of kstrtol with a dirty cast.
Signed-off-by Ondrej Mosnacek <[email protected]>
--- kernel/time/ntp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
kernel/time/ntp.c +2 -3
@@ -1020,12 +1020,11 @@ void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_tstatic int __init ntp_tick_adj_setup (char *str) { -int rc =kstrtol (str,0 , (long *)&ntp_tick_adj); - +int rc =kstrtos64 (str,0 , &ntp_tick_adj);if (rc)return rc; - ntp_tick_adj <<=NTP_SCALE_SHIFT ; + ntp_tick_adj <<=NTP_SCALE_SHIFT ;return 1 ; }
Signature · 1 line
2.17.1
PATCH 3/3 timekeeping/ntp: Constify some function arguments
In reply to Ondrej MosnacekAdd 'const' to some function arguments and variables to make it easier to read the code.
Signed-off-by Ondrej Mosnacek <[email protected]>
--- include/linux/timekeeping.h | 2 +- kernel/time/ntp.c | 6 +++--- kernel/time/ntp_internal.h | 2 +- kernel/time/timekeeping.c | 29 +++++++++++++++-------------- kernel/time/timekeeping_debug.c | 2 +- kernel/time/timekeeping_internal.h | 2 +- 6 files changed, 22 insertions(+), 21 deletions(-)
include/linux/timekeeping.h +1 -1
@@ -177,7 +177,7 @@ static inline time64_t ktime_get_clocktai_seconds(void)extern bool timekeeping_rtc_skipsuspend (void );extern bool timekeeping_rtc_skipresume (void ); -extern void timekeeping_inject_sleeptime64 (struct timespec64 *delta); +extern void timekeeping_inject_sleeptime64 (const struct timespec64 *delta);/* * struct system_time_snapshot - simultaneous raw/real time capture with
kernel/time/ntp.c +3 -3
@@ -642,7 +642,7 @@ void ntp_notify_cmos_timer(void)/* * Propagate a new txc->status value into the NTP state: */ -static inline void process_adj_status (struct timex *txc) +static inline void process_adj_status (const struct timex *txc) {if ((time_status &STA_PLL ) && !(txc->status &STA_PLL )) { time_state =TIME_OK ;
@@ -665,7 +665,7 @@ static inline void process_adj_status(struct timex *txc) } -static inline void process_adjtimex_modes (struct timex *txc,s32 *time_tai) +static inline void process_adjtimex_modes (const struct timex *txc,s32 *time_tai) {if (txc->modes &ADJ_STATUS )process_adj_status (txc);
@@ -716,7 +716,7 @@ static inline void process_adjtimex_modes(struct timex *txc, s32 *time_tai)* adjtimex mainly allows reading (and writing, if superuser) of * kernel time-keeping variables. used by xntpd. */ -int __do_adjtimex (struct timex *txc,struct timespec64 *ts,s32 *time_tai) +int __do_adjtimex (struct timex *txc,const struct timespec64 *ts,s32 *time_tai) {int result;
kernel/time/ntp_internal.h +1 -1
@@ -8,6 +8,6 @@ extern void ntp_clear(void);extern u64 ntp_tick_length (void );extern ktime_t ntp_get_next_leap (void );extern int second_overflow (time64_t secs); -extern int __do_adjtimex (struct timex *,struct timespec64 *,s32 *); +extern int __do_adjtimex (struct timex *,const struct timespec64 *,s32 *);extern void __hardpps (const struct timespec64 *,const struct timespec64 *);#endif /* _LINUX_NTP_INTERNAL_H */
kernel/time/timekeeping.c +15 -14
@@ -97,7 +97,7 @@ static inline void tk_normalize_xtime(struct timekeeper *tk) } } -static inline struct timespec64 tk_xtime (struct timekeeper *tk) +static inline struct timespec64 tk_xtime (const struct timekeeper *tk) {struct timespec64 ts;
@@ -154,7 +154,7 @@ static inline void tk_update_sleep_time(struct timekeeper *tk, ktime_t delta)* a read of the fast-timekeeper tkrs (which is protected by its own locking * and update logic). */ -static inline u64 tk_clock_read (struct tk_read_base *tkr) +static inline u64 tk_clock_read (const struct tk_read_base *tkr) {struct clocksource *clock =READ_ONCE (tkr->clock);
@@ -203,7 +203,7 @@ static void timekeeping_check_update(struct timekeeper *tk, u64 offset) } } -static inline u64 timekeeping_get_delta (struct tk_read_base *tkr) +static inline u64 timekeeping_get_delta (const struct tk_read_base *tkr) {struct timekeeper *tk = &tk_core.timekeeper;u64 now, last, mask, max, delta;
@@ -247,7 +247,7 @@ static inline u64 timekeeping_get_delta(struct tk_read_base *tkr)static inline void timekeeping_check_update (struct timekeeper *tk,u64 offset) { } -static inline u64 timekeeping_get_delta (struct tk_read_base *tkr) +static inline u64 timekeeping_get_delta (const struct tk_read_base *tkr) {u64 cycle_now, delta;
@@ -344,7 +344,7 @@ u32 (*arch_gettimeoffset)(void) = default_arch_gettimeoffset;static inline u32 arch_gettimeoffset (void ) {return 0 ; }#endif -static inline u64 timekeeping_delta_to_ns (struct tk_read_base *tkr,u64 delta) +static inline u64 timekeeping_delta_to_ns (const struct tk_read_base *tkr,u64 delta) {u64 nsec;
@@ -355,7 +355,7 @@ static inline u64 timekeeping_delta_to_ns(struct tk_read_base *tkr, u64 delta)return nsec +arch_gettimeoffset (); } -static inline u64 timekeeping_get_ns (struct tk_read_base *tkr) +static inline u64 timekeeping_get_ns (const struct tk_read_base *tkr) {u64 delta;
@@ -363,7 +363,7 @@ static inline u64 timekeeping_get_ns(struct tk_read_base *tkr)return timekeeping_delta_to_ns (tkr, delta); } -static inline u64 timekeeping_cycles_to_ns (struct tk_read_base *tkr,u64 cycles) +static inline u64 timekeeping_cycles_to_ns (const struct tk_read_base *tkr,u64 cycles) {u64 delta;
@@ -386,7 +386,8 @@ static inline u64 timekeeping_cycles_to_ns(struct tk_read_base *tkr, u64 cycles)* slightly wrong timestamp (a few nanoseconds). See * @ktime_get_mono_fast_ns. */ -static void update_fast_timekeeper (struct tk_read_base *tkr,struct tk_fast *tkf) +static void update_fast_timekeeper (const struct tk_read_base *tkr, +struct tk_fast *tkf) {struct tk_read_base *base = tkf->base;
@@ -541,10 +542,10 @@ EXPORT_SYMBOL_GPL(ktime_get_real_fast_ns);* number of cycles every time until timekeeping is resumed at which time the * proper readout base for the fast timekeeper will be restored automatically. */ -static void halt_fast_timekeeper (struct timekeeper *tk) +static void halt_fast_timekeeper (const struct timekeeper *tk) {static struct tk_read_base tkr_dummy; -struct tk_read_base *tkr = &tk->tkr_mono; +const struct tk_read_base *tkr = &tk->tkr_mono;memcpy (&tkr_dummy, tkr,sizeof (tkr_dummy)); cycles_at_suspend =tk_clock_read (tkr);
@@ -1269,7 +1270,7 @@ EXPORT_SYMBOL(do_settimeofday64);* * Adds or subtracts an offset value from the current time. */ -static int timekeeping_inject_offset (struct timespec64 *ts) +static int timekeeping_inject_offset (const struct timespec64 *ts) {struct timekeeper *tk = &tk_core.timekeeper;unsigned long flags;
@@ -1577,7 +1578,7 @@ static struct timespec64 timekeeping_suspend_time;* adds the sleep offset to the timekeeping variables. */ static void __timekeeping_inject_sleeptime (struct timekeeper *tk, -struct timespec64 *delta) +const struct timespec64 *delta) {if (!timespec64_valid_strict (delta)) { printk_deferred(KERN_WARNING
@@ -1638,7 +1639,7 @@ bool timekeeping_rtc_skipsuspend(void)* This function should only be called by rtc_resume(), and allows * a suspend offset to be injected into the timekeeping values. */ -void timekeeping_inject_sleeptime64 (struct timespec64 *delta) +void timekeeping_inject_sleeptime64 (const struct timespec64 *delta) {struct timekeeper *tk = &tk_core.timekeeper;unsigned long flags;
@@ -2220,7 +2221,7 @@ ktime_t ktime_get_update_offsets_now(unsigned int *cwsseq, ktime_t *offs_real,/** * timekeeping_validate_timex - Ensures the timex is ok for use in do_adjtimex */ -static int timekeeping_validate_timex (struct timex *txc) +static int timekeeping_validate_timex (const struct timex *txc) {if (txc->modes &ADJ_ADJTIME ) {/* singleshot must not be used with any other mode bits */
kernel/time/timekeeping_debug.c +1 -1
@@ -70,7 +70,7 @@ static int __init tk_debug_sleep_time_init(void) }late_initcall (tk_debug_sleep_time_init); -void tk_debug_account_sleep_time (struct timespec64 *t) +void tk_debug_account_sleep_time (const struct timespec64 *t) {/* Cap bin index so we don't overflow the array */ int bin =min (fls (t->tv_sec),NUM_BINS -1 );
kernel/time/timekeeping_internal.h +1 -1
@@ -8,7 +8,7 @@#include <linux/time.h> #ifdef CONFIG_DEBUG_FS -extern void tk_debug_account_sleep_time (struct timespec64 *t); +extern void tk_debug_account_sleep_time (const struct timespec64 *t);#else #define tk_debug_account_sleep_time (x)#endif
Signature · 1 line
2.17.1
Quoted 4 lines · Ondrej Mosnacek
The 'ts' argument of
process_adj_status()andprocess_adjtimex_modes()is unused and can be safely removed.Signed-off-by Ondrej Mosnacek <[email protected]>
Thanks for sending this set along. I'll queue them up for closer review and testing.
thanks
-john