Skip to content

Commit 985e695

Browse files
Ondrej Mosnacekjohnstultz-work
authored andcommitted
timekeeping/ntp: Constify some function arguments
Add 'const' to some function arguments and variables to make it easier to read the code. Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@kernel.org> Cc: Miroslav Lichvar <mlichvar@redhat.com> Cc: Richard Cochran <richardcochran@gmail.com> Cc: Prarit Bhargava <prarit@redhat.com> Cc: Stephen Boyd <sboyd@kernel.org> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com> [jstultz: Also fixup pre-existing checkpatch warnings for prototype arguments with no variable name] Signed-off-by: John Stultz <john.stultz@linaro.org>
1 parent 86b2dcd commit 985e695

6 files changed

Lines changed: 23 additions & 22 deletions

File tree

‎include/linux/timekeeping.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static inline time64_t ktime_get_clocktai_seconds(void)
177177
extern bool timekeeping_rtc_skipsuspend(void);
178178
extern bool timekeeping_rtc_skipresume(void);
179179

180-
extern void timekeeping_inject_sleeptime64(struct timespec64 *delta);
180+
extern void timekeeping_inject_sleeptime64(const struct timespec64 *delta);
181181

182182
/*
183183
* struct system_time_snapshot - simultaneous raw/real time capture with

‎kernel/time/ntp.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ void ntp_notify_cmos_timer(void)
642642
/*
643643
* Propagate a new txc->status value into the NTP state:
644644
*/
645-
static inline void process_adj_status(struct timex *txc)
645+
static inline void process_adj_status(const struct timex *txc)
646646
{
647647
if ((time_status & STA_PLL) && !(txc->status & STA_PLL)) {
648648
time_state = TIME_OK;
@@ -665,7 +665,7 @@ static inline void process_adj_status(struct timex *txc)
665665
}
666666

667667

668-
static inline void process_adjtimex_modes(struct timex *txc, s32 *time_tai)
668+
static inline void process_adjtimex_modes(const struct timex *txc, s32 *time_tai)
669669
{
670670
if (txc->modes & ADJ_STATUS)
671671
process_adj_status(txc);
@@ -716,7 +716,7 @@ static inline void process_adjtimex_modes(struct timex *txc, s32 *time_tai)
716716
* adjtimex mainly allows reading (and writing, if superuser) of
717717
* kernel time-keeping variables. used by xntpd.
718718
*/
719-
int __do_adjtimex(struct timex *txc, struct timespec64 *ts, s32 *time_tai)
719+
int __do_adjtimex(struct timex *txc, const struct timespec64 *ts, s32 *time_tai)
720720
{
721721
int result;
722722

‎kernel/time/ntp_internal.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ extern void ntp_clear(void);
88
extern u64 ntp_tick_length(void);
99
extern ktime_t ntp_get_next_leap(void);
1010
extern int second_overflow(time64_t secs);
11-
extern int __do_adjtimex(struct timex *, struct timespec64 *, s32 *);
12-
extern void __hardpps(const struct timespec64 *, const struct timespec64 *);
11+
extern int __do_adjtimex(struct timex *txc, const struct timespec64 *ts, s32 *time_tai);
12+
extern void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_ts);
1313
#endif /* _LINUX_NTP_INTERNAL_H */

‎kernel/time/timekeeping.c‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static inline void tk_normalize_xtime(struct timekeeper *tk)
105105
}
106106
}
107107

108-
static inline struct timespec64 tk_xtime(struct timekeeper *tk)
108+
static inline struct timespec64 tk_xtime(const struct timekeeper *tk)
109109
{
110110
struct timespec64 ts;
111111

@@ -162,7 +162,7 @@ static inline void tk_update_sleep_time(struct timekeeper *tk, ktime_t delta)
162162
* a read of the fast-timekeeper tkrs (which is protected by its own locking
163163
* and update logic).
164164
*/
165-
static inline u64 tk_clock_read(struct tk_read_base *tkr)
165+
static inline u64 tk_clock_read(const struct tk_read_base *tkr)
166166
{
167167
struct clocksource *clock = READ_ONCE(tkr->clock);
168168

@@ -211,7 +211,7 @@ static void timekeeping_check_update(struct timekeeper *tk, u64 offset)
211211
}
212212
}
213213

214-
static inline u64 timekeeping_get_delta(struct tk_read_base *tkr)
214+
static inline u64 timekeeping_get_delta(const struct tk_read_base *tkr)
215215
{
216216
struct timekeeper *tk = &tk_core.timekeeper;
217217
u64 now, last, mask, max, delta;
@@ -255,7 +255,7 @@ static inline u64 timekeeping_get_delta(struct tk_read_base *tkr)
255255
static inline void timekeeping_check_update(struct timekeeper *tk, u64 offset)
256256
{
257257
}
258-
static inline u64 timekeeping_get_delta(struct tk_read_base *tkr)
258+
static inline u64 timekeeping_get_delta(const struct tk_read_base *tkr)
259259
{
260260
u64 cycle_now, delta;
261261

@@ -352,7 +352,7 @@ u32 (*arch_gettimeoffset)(void) = default_arch_gettimeoffset;
352352
static inline u32 arch_gettimeoffset(void) { return 0; }
353353
#endif
354354

355-
static inline u64 timekeeping_delta_to_ns(struct tk_read_base *tkr, u64 delta)
355+
static inline u64 timekeeping_delta_to_ns(const struct tk_read_base *tkr, u64 delta)
356356
{
357357
u64 nsec;
358358

@@ -363,15 +363,15 @@ static inline u64 timekeeping_delta_to_ns(struct tk_read_base *tkr, u64 delta)
363363
return nsec + arch_gettimeoffset();
364364
}
365365

366-
static inline u64 timekeeping_get_ns(struct tk_read_base *tkr)
366+
static inline u64 timekeeping_get_ns(const struct tk_read_base *tkr)
367367
{
368368
u64 delta;
369369

370370
delta = timekeeping_get_delta(tkr);
371371
return timekeeping_delta_to_ns(tkr, delta);
372372
}
373373

374-
static inline u64 timekeeping_cycles_to_ns(struct tk_read_base *tkr, u64 cycles)
374+
static inline u64 timekeeping_cycles_to_ns(const struct tk_read_base *tkr, u64 cycles)
375375
{
376376
u64 delta;
377377

@@ -394,7 +394,8 @@ static inline u64 timekeeping_cycles_to_ns(struct tk_read_base *tkr, u64 cycles)
394394
* slightly wrong timestamp (a few nanoseconds). See
395395
* @ktime_get_mono_fast_ns.
396396
*/
397-
static void update_fast_timekeeper(struct tk_read_base *tkr, struct tk_fast *tkf)
397+
static void update_fast_timekeeper(const struct tk_read_base *tkr,
398+
struct tk_fast *tkf)
398399
{
399400
struct tk_read_base *base = tkf->base;
400401

@@ -549,10 +550,10 @@ EXPORT_SYMBOL_GPL(ktime_get_real_fast_ns);
549550
* number of cycles every time until timekeeping is resumed at which time the
550551
* proper readout base for the fast timekeeper will be restored automatically.
551552
*/
552-
static void halt_fast_timekeeper(struct timekeeper *tk)
553+
static void halt_fast_timekeeper(const struct timekeeper *tk)
553554
{
554555
static struct tk_read_base tkr_dummy;
555-
struct tk_read_base *tkr = &tk->tkr_mono;
556+
const struct tk_read_base *tkr = &tk->tkr_mono;
556557

557558
memcpy(&tkr_dummy, tkr, sizeof(tkr_dummy));
558559
cycles_at_suspend = tk_clock_read(tkr);
@@ -1277,7 +1278,7 @@ EXPORT_SYMBOL(do_settimeofday64);
12771278
*
12781279
* Adds or subtracts an offset value from the current time.
12791280
*/
1280-
static int timekeeping_inject_offset(struct timespec64 *ts)
1281+
static int timekeeping_inject_offset(const struct timespec64 *ts)
12811282
{
12821283
struct timekeeper *tk = &tk_core.timekeeper;
12831284
unsigned long flags;
@@ -1585,7 +1586,7 @@ static struct timespec64 timekeeping_suspend_time;
15851586
* adds the sleep offset to the timekeeping variables.
15861587
*/
15871588
static void __timekeeping_inject_sleeptime(struct timekeeper *tk,
1588-
struct timespec64 *delta)
1589+
const struct timespec64 *delta)
15891590
{
15901591
if (!timespec64_valid_strict(delta)) {
15911592
printk_deferred(KERN_WARNING
@@ -1646,7 +1647,7 @@ bool timekeeping_rtc_skipsuspend(void)
16461647
* This function should only be called by rtc_resume(), and allows
16471648
* a suspend offset to be injected into the timekeeping values.
16481649
*/
1649-
void timekeeping_inject_sleeptime64(struct timespec64 *delta)
1650+
void timekeeping_inject_sleeptime64(const struct timespec64 *delta)
16501651
{
16511652
struct timekeeper *tk = &tk_core.timekeeper;
16521653
unsigned long flags;
@@ -2240,7 +2241,7 @@ ktime_t ktime_get_update_offsets_now(unsigned int *cwsseq, ktime_t *offs_real,
22402241
/**
22412242
* timekeeping_validate_timex - Ensures the timex is ok for use in do_adjtimex
22422243
*/
2243-
static int timekeeping_validate_timex(struct timex *txc)
2244+
static int timekeeping_validate_timex(const struct timex *txc)
22442245
{
22452246
if (txc->modes & ADJ_ADJTIME) {
22462247
/* singleshot must not be used with any other mode bits */

‎kernel/time/timekeeping_debug.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static int __init tk_debug_sleep_time_init(void)
7070
}
7171
late_initcall(tk_debug_sleep_time_init);
7272

73-
void tk_debug_account_sleep_time(struct timespec64 *t)
73+
void tk_debug_account_sleep_time(const struct timespec64 *t)
7474
{
7575
/* Cap bin index so we don't overflow the array */
7676
int bin = min(fls(t->tv_sec), NUM_BINS-1);

‎kernel/time/timekeeping_internal.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <linux/time.h>
99

1010
#ifdef CONFIG_DEBUG_FS
11-
extern void tk_debug_account_sleep_time(struct timespec64 *t);
11+
extern void tk_debug_account_sleep_time(const struct timespec64 *t);
1212
#else
1313
#define tk_debug_account_sleep_time(x)
1414
#endif

0 commit comments

Comments
 (0)