diff options
author | Ondrej Mosnacek <omosnace@redhat.com> | 2018-07-13 08:06:42 -0400 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2018-07-19 20:08:05 -0400 |
commit | 985e695074d35768cb04d65f58bca45f7bf1a99d (patch) | |
tree | 3d473a4a36fe660fd64cdabde116d57ff8434574 | |
parent | 86b2dcd4f02b86f6b5927fc0adcac777825f4030 (diff) |
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>
-rw-r--r-- | include/linux/timekeeping.h | 2 | ||||
-rw-r--r-- | kernel/time/ntp.c | 6 | ||||
-rw-r--r-- | kernel/time/ntp_internal.h | 4 | ||||
-rw-r--r-- | kernel/time/timekeeping.c | 29 | ||||
-rw-r--r-- | kernel/time/timekeeping_debug.c | 2 | ||||
-rw-r--r-- | kernel/time/timekeeping_internal.h | 2 |
6 files changed, 23 insertions, 22 deletions
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 86bc2026efce..edace6b656e9 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h | |||
@@ -177,7 +177,7 @@ static inline time64_t ktime_get_clocktai_seconds(void) | |||
177 | extern bool timekeeping_rtc_skipsuspend(void); | 177 | extern bool timekeeping_rtc_skipsuspend(void); |
178 | extern bool timekeeping_rtc_skipresume(void); | 178 | extern bool timekeeping_rtc_skipresume(void); |
179 | 179 | ||
180 | extern void timekeeping_inject_sleeptime64(struct timespec64 *delta); | 180 | extern void timekeeping_inject_sleeptime64(const struct timespec64 *delta); |
181 | 181 | ||
182 | /* | 182 | /* |
183 | * struct system_time_snapshot - simultaneous raw/real time capture with | 183 | * struct system_time_snapshot - simultaneous raw/real time capture with |
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index a627cae8baab..c5e0cba3b39c 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c | |||
@@ -642,7 +642,7 @@ void ntp_notify_cmos_timer(void) | |||
642 | /* | 642 | /* |
643 | * Propagate a new txc->status value into the NTP state: | 643 | * Propagate a new txc->status value into the NTP state: |
644 | */ | 644 | */ |
645 | static inline void process_adj_status(struct timex *txc) | 645 | static inline void process_adj_status(const struct timex *txc) |
646 | { | 646 | { |
647 | if ((time_status & STA_PLL) && !(txc->status & STA_PLL)) { | 647 | if ((time_status & STA_PLL) && !(txc->status & STA_PLL)) { |
648 | time_state = TIME_OK; | 648 | time_state = TIME_OK; |
@@ -665,7 +665,7 @@ static inline void process_adj_status(struct timex *txc) | |||
665 | } | 665 | } |
666 | 666 | ||
667 | 667 | ||
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) |
669 | { | 669 | { |
670 | if (txc->modes & ADJ_STATUS) | 670 | if (txc->modes & ADJ_STATUS) |
671 | process_adj_status(txc); | 671 | process_adj_status(txc); |
@@ -716,7 +716,7 @@ static inline void process_adjtimex_modes(struct timex *txc, s32 *time_tai) | |||
716 | * adjtimex mainly allows reading (and writing, if superuser) of | 716 | * adjtimex mainly allows reading (and writing, if superuser) of |
717 | * kernel time-keeping variables. used by xntpd. | 717 | * kernel time-keeping variables. used by xntpd. |
718 | */ | 718 | */ |
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) |
720 | { | 720 | { |
721 | int result; | 721 | int result; |
722 | 722 | ||
diff --git a/kernel/time/ntp_internal.h b/kernel/time/ntp_internal.h index 909bd1f1bfb1..c24b0e13f011 100644 --- a/kernel/time/ntp_internal.h +++ b/kernel/time/ntp_internal.h | |||
@@ -8,6 +8,6 @@ extern void ntp_clear(void); | |||
8 | extern u64 ntp_tick_length(void); | 8 | extern u64 ntp_tick_length(void); |
9 | extern ktime_t ntp_get_next_leap(void); | 9 | extern ktime_t ntp_get_next_leap(void); |
10 | extern int second_overflow(time64_t secs); | 10 | extern int second_overflow(time64_t secs); |
11 | extern int __do_adjtimex(struct timex *, struct timespec64 *, s32 *); | 11 | extern int __do_adjtimex(struct timex *txc, const struct timespec64 *ts, s32 *time_tai); |
12 | extern void __hardpps(const struct timespec64 *, const struct timespec64 *); | 12 | extern void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_ts); |
13 | #endif /* _LINUX_NTP_INTERNAL_H */ | 13 | #endif /* _LINUX_NTP_INTERNAL_H */ |
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index ad779c2ec53a..7033ac1fee65 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -105,7 +105,7 @@ static inline void tk_normalize_xtime(struct timekeeper *tk) | |||
105 | } | 105 | } |
106 | } | 106 | } |
107 | 107 | ||
108 | static inline struct timespec64 tk_xtime(struct timekeeper *tk) | 108 | static inline struct timespec64 tk_xtime(const struct timekeeper *tk) |
109 | { | 109 | { |
110 | struct timespec64 ts; | 110 | struct timespec64 ts; |
111 | 111 | ||
@@ -162,7 +162,7 @@ static inline void tk_update_sleep_time(struct timekeeper *tk, ktime_t delta) | |||
162 | * a read of the fast-timekeeper tkrs (which is protected by its own locking | 162 | * a read of the fast-timekeeper tkrs (which is protected by its own locking |
163 | * and update logic). | 163 | * and update logic). |
164 | */ | 164 | */ |
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) |
166 | { | 166 | { |
167 | struct clocksource *clock = READ_ONCE(tkr->clock); | 167 | struct clocksource *clock = READ_ONCE(tkr->clock); |
168 | 168 | ||
@@ -211,7 +211,7 @@ static void timekeeping_check_update(struct timekeeper *tk, u64 offset) | |||
211 | } | 211 | } |
212 | } | 212 | } |
213 | 213 | ||
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) |
215 | { | 215 | { |
216 | struct timekeeper *tk = &tk_core.timekeeper; | 216 | struct timekeeper *tk = &tk_core.timekeeper; |
217 | u64 now, last, mask, max, delta; | 217 | u64 now, last, mask, max, delta; |
@@ -255,7 +255,7 @@ static inline u64 timekeeping_get_delta(struct tk_read_base *tkr) | |||
255 | static inline void timekeeping_check_update(struct timekeeper *tk, u64 offset) | 255 | static inline void timekeeping_check_update(struct timekeeper *tk, u64 offset) |
256 | { | 256 | { |
257 | } | 257 | } |
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) |
259 | { | 259 | { |
260 | u64 cycle_now, delta; | 260 | u64 cycle_now, delta; |
261 | 261 | ||
@@ -352,7 +352,7 @@ u32 (*arch_gettimeoffset)(void) = default_arch_gettimeoffset; | |||
352 | static inline u32 arch_gettimeoffset(void) { return 0; } | 352 | static inline u32 arch_gettimeoffset(void) { return 0; } |
353 | #endif | 353 | #endif |
354 | 354 | ||
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) |
356 | { | 356 | { |
357 | u64 nsec; | 357 | u64 nsec; |
358 | 358 | ||
@@ -363,7 +363,7 @@ static inline u64 timekeeping_delta_to_ns(struct tk_read_base *tkr, u64 delta) | |||
363 | return nsec + arch_gettimeoffset(); | 363 | return nsec + arch_gettimeoffset(); |
364 | } | 364 | } |
365 | 365 | ||
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) |
367 | { | 367 | { |
368 | u64 delta; | 368 | u64 delta; |
369 | 369 | ||
@@ -371,7 +371,7 @@ static inline u64 timekeeping_get_ns(struct tk_read_base *tkr) | |||
371 | return timekeeping_delta_to_ns(tkr, delta); | 371 | return timekeeping_delta_to_ns(tkr, delta); |
372 | } | 372 | } |
373 | 373 | ||
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) |
375 | { | 375 | { |
376 | u64 delta; | 376 | u64 delta; |
377 | 377 | ||
@@ -394,7 +394,8 @@ static inline u64 timekeeping_cycles_to_ns(struct tk_read_base *tkr, u64 cycles) | |||
394 | * slightly wrong timestamp (a few nanoseconds). See | 394 | * slightly wrong timestamp (a few nanoseconds). See |
395 | * @ktime_get_mono_fast_ns. | 395 | * @ktime_get_mono_fast_ns. |
396 | */ | 396 | */ |
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) | ||
398 | { | 399 | { |
399 | struct tk_read_base *base = tkf->base; | 400 | struct tk_read_base *base = tkf->base; |
400 | 401 | ||
@@ -549,10 +550,10 @@ EXPORT_SYMBOL_GPL(ktime_get_real_fast_ns); | |||
549 | * number of cycles every time until timekeeping is resumed at which time the | 550 | * number of cycles every time until timekeeping is resumed at which time the |
550 | * proper readout base for the fast timekeeper will be restored automatically. | 551 | * proper readout base for the fast timekeeper will be restored automatically. |
551 | */ | 552 | */ |
552 | static void halt_fast_timekeeper(struct timekeeper *tk) | 553 | static void halt_fast_timekeeper(const struct timekeeper *tk) |
553 | { | 554 | { |
554 | static struct tk_read_base tkr_dummy; | 555 | 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; |
556 | 557 | ||
557 | memcpy(&tkr_dummy, tkr, sizeof(tkr_dummy)); | 558 | memcpy(&tkr_dummy, tkr, sizeof(tkr_dummy)); |
558 | cycles_at_suspend = tk_clock_read(tkr); | 559 | cycles_at_suspend = tk_clock_read(tkr); |
@@ -1277,7 +1278,7 @@ EXPORT_SYMBOL(do_settimeofday64); | |||
1277 | * | 1278 | * |
1278 | * Adds or subtracts an offset value from the current time. | 1279 | * Adds or subtracts an offset value from the current time. |
1279 | */ | 1280 | */ |
1280 | static int timekeeping_inject_offset(struct timespec64 *ts) | 1281 | static int timekeeping_inject_offset(const struct timespec64 *ts) |
1281 | { | 1282 | { |
1282 | struct timekeeper *tk = &tk_core.timekeeper; | 1283 | struct timekeeper *tk = &tk_core.timekeeper; |
1283 | unsigned long flags; | 1284 | unsigned long flags; |
@@ -1585,7 +1586,7 @@ static struct timespec64 timekeeping_suspend_time; | |||
1585 | * adds the sleep offset to the timekeeping variables. | 1586 | * adds the sleep offset to the timekeeping variables. |
1586 | */ | 1587 | */ |
1587 | static void __timekeeping_inject_sleeptime(struct timekeeper *tk, | 1588 | static void __timekeeping_inject_sleeptime(struct timekeeper *tk, |
1588 | struct timespec64 *delta) | 1589 | const struct timespec64 *delta) |
1589 | { | 1590 | { |
1590 | if (!timespec64_valid_strict(delta)) { | 1591 | if (!timespec64_valid_strict(delta)) { |
1591 | printk_deferred(KERN_WARNING | 1592 | printk_deferred(KERN_WARNING |
@@ -1646,7 +1647,7 @@ bool timekeeping_rtc_skipsuspend(void) | |||
1646 | * This function should only be called by rtc_resume(), and allows | 1647 | * This function should only be called by rtc_resume(), and allows |
1647 | * a suspend offset to be injected into the timekeeping values. | 1648 | * a suspend offset to be injected into the timekeeping values. |
1648 | */ | 1649 | */ |
1649 | void timekeeping_inject_sleeptime64(struct timespec64 *delta) | 1650 | void timekeeping_inject_sleeptime64(const struct timespec64 *delta) |
1650 | { | 1651 | { |
1651 | struct timekeeper *tk = &tk_core.timekeeper; | 1652 | struct timekeeper *tk = &tk_core.timekeeper; |
1652 | unsigned long flags; | 1653 | unsigned long flags; |
@@ -2240,7 +2241,7 @@ ktime_t ktime_get_update_offsets_now(unsigned int *cwsseq, ktime_t *offs_real, | |||
2240 | /** | 2241 | /** |
2241 | * timekeeping_validate_timex - Ensures the timex is ok for use in do_adjtimex | 2242 | * timekeeping_validate_timex - Ensures the timex is ok for use in do_adjtimex |
2242 | */ | 2243 | */ |
2243 | static int timekeeping_validate_timex(struct timex *txc) | 2244 | static int timekeeping_validate_timex(const struct timex *txc) |
2244 | { | 2245 | { |
2245 | if (txc->modes & ADJ_ADJTIME) { | 2246 | if (txc->modes & ADJ_ADJTIME) { |
2246 | /* singleshot must not be used with any other mode bits */ | 2247 | /* singleshot must not be used with any other mode bits */ |
diff --git a/kernel/time/timekeeping_debug.c b/kernel/time/timekeeping_debug.c index 0754cadfa9e6..238e4be60229 100644 --- a/kernel/time/timekeeping_debug.c +++ b/kernel/time/timekeeping_debug.c | |||
@@ -70,7 +70,7 @@ static int __init tk_debug_sleep_time_init(void) | |||
70 | } | 70 | } |
71 | late_initcall(tk_debug_sleep_time_init); | 71 | late_initcall(tk_debug_sleep_time_init); |
72 | 72 | ||
73 | void tk_debug_account_sleep_time(struct timespec64 *t) | 73 | void tk_debug_account_sleep_time(const struct timespec64 *t) |
74 | { | 74 | { |
75 | /* Cap bin index so we don't overflow the array */ | 75 | /* Cap bin index so we don't overflow the array */ |
76 | int bin = min(fls(t->tv_sec), NUM_BINS-1); | 76 | int bin = min(fls(t->tv_sec), NUM_BINS-1); |
diff --git a/kernel/time/timekeeping_internal.h b/kernel/time/timekeeping_internal.h index cf5c0828ee31..bcbb52db2256 100644 --- a/kernel/time/timekeeping_internal.h +++ b/kernel/time/timekeeping_internal.h | |||
@@ -8,7 +8,7 @@ | |||
8 | #include <linux/time.h> | 8 | #include <linux/time.h> |
9 | 9 | ||
10 | #ifdef CONFIG_DEBUG_FS | 10 | #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); |
12 | #else | 12 | #else |
13 | #define tk_debug_account_sleep_time(x) | 13 | #define tk_debug_account_sleep_time(x) |
14 | #endif | 14 | #endif |