summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-05-26 05:03:11 -0400
committerThomas Gleixner <tglx@linutronix.de>2017-05-27 03:46:35 -0400
commitd3ba5a9a345b1243276f8a982e1bce557c2504fd (patch)
tree1642ba9e97ef835cc51f87fbad312f0af3a8f526 /kernel
parent07903ada96139ced48f2f893fe57a26a8fbc6043 (diff)
posix-timers: Make posix_clocks immutable
There are no more modular users providing a posix clock. The register function is now pointless so the posix clock array can be initialized statically at compile time and the array including the various k_clock structs can be marked 'const'. Inspired by changes in the Grsecurity patch set, but done proper. [ tglx: Massaged changelog and fixed the POSIX_TIMER=n case ] Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Mike Travis <mike.travis@hpe.com> Cc: Dimitri Sivanich <sivanich@hpe.com> Link: http://lkml.kernel.org/r/20170526090311.3377-3-hch@lst.de
Diffstat (limited to 'kernel')
-rw-r--r--kernel/time/alarmtimer.c89
-rw-r--r--kernel/time/posix-clock.c2
-rw-r--r--kernel/time/posix-cpu-timers.c34
-rw-r--r--kernel/time/posix-timers.c191
4 files changed, 146 insertions, 170 deletions
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 5cb5b0008d97..4f4cc3509b30 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -307,38 +307,6 @@ static int alarmtimer_resume(struct device *dev)
307} 307}
308#endif 308#endif
309 309
310static void alarmtimer_freezerset(ktime_t absexp, enum alarmtimer_type type)
311{
312 struct alarm_base *base;
313 unsigned long flags;
314 ktime_t delta;
315
316 switch(type) {
317 case ALARM_REALTIME:
318 base = &alarm_bases[ALARM_REALTIME];
319 type = ALARM_REALTIME_FREEZER;
320 break;
321 case ALARM_BOOTTIME:
322 base = &alarm_bases[ALARM_BOOTTIME];
323 type = ALARM_BOOTTIME_FREEZER;
324 break;
325 default:
326 WARN_ONCE(1, "Invalid alarm type: %d\n", type);
327 return;
328 }
329
330 delta = ktime_sub(absexp, base->gettime());
331
332 spin_lock_irqsave(&freezer_delta_lock, flags);
333 if (!freezer_delta || (delta < freezer_delta)) {
334 freezer_delta = delta;
335 freezer_expires = absexp;
336 freezer_alarmtype = type;
337 }
338 spin_unlock_irqrestore(&freezer_delta_lock, flags);
339}
340
341
342/** 310/**
343 * alarm_init - Initialize an alarm structure 311 * alarm_init - Initialize an alarm structure
344 * @alarm: ptr to alarm to be initialized 312 * @alarm: ptr to alarm to be initialized
@@ -488,6 +456,38 @@ u64 alarm_forward_now(struct alarm *alarm, ktime_t interval)
488} 456}
489EXPORT_SYMBOL_GPL(alarm_forward_now); 457EXPORT_SYMBOL_GPL(alarm_forward_now);
490 458
459#ifdef CONFIG_POSIX_TIMERS
460
461static void alarmtimer_freezerset(ktime_t absexp, enum alarmtimer_type type)
462{
463 struct alarm_base *base;
464 unsigned long flags;
465 ktime_t delta;
466
467 switch(type) {
468 case ALARM_REALTIME:
469 base = &alarm_bases[ALARM_REALTIME];
470 type = ALARM_REALTIME_FREEZER;
471 break;
472 case ALARM_BOOTTIME:
473 base = &alarm_bases[ALARM_BOOTTIME];
474 type = ALARM_BOOTTIME_FREEZER;
475 break;
476 default:
477 WARN_ONCE(1, "Invalid alarm type: %d\n", type);
478 return;
479 }
480
481 delta = ktime_sub(absexp, base->gettime());
482
483 spin_lock_irqsave(&freezer_delta_lock, flags);
484 if (!freezer_delta || (delta < freezer_delta)) {
485 freezer_delta = delta;
486 freezer_expires = absexp;
487 freezer_alarmtype = type;
488 }
489 spin_unlock_irqrestore(&freezer_delta_lock, flags);
490}
491 491
492/** 492/**
493 * clock2alarm - helper that converts from clockid to alarmtypes 493 * clock2alarm - helper that converts from clockid to alarmtypes
@@ -846,6 +846,17 @@ out:
846 return ret; 846 return ret;
847} 847}
848 848
849const struct k_clock alarm_clock = {
850 .clock_getres = alarm_clock_getres,
851 .clock_get = alarm_clock_get,
852 .timer_create = alarm_timer_create,
853 .timer_set = alarm_timer_set,
854 .timer_del = alarm_timer_del,
855 .timer_get = alarm_timer_get,
856 .nsleep = alarm_timer_nsleep,
857};
858#endif /* CONFIG_POSIX_TIMERS */
859
849 860
850/* Suspend hook structures */ 861/* Suspend hook structures */
851static const struct dev_pm_ops alarmtimer_pm_ops = { 862static const struct dev_pm_ops alarmtimer_pm_ops = {
@@ -871,23 +882,9 @@ static int __init alarmtimer_init(void)
871 struct platform_device *pdev; 882 struct platform_device *pdev;
872 int error = 0; 883 int error = 0;
873 int i; 884 int i;
874 struct k_clock alarm_clock = {
875 .clock_getres = alarm_clock_getres,
876 .clock_get = alarm_clock_get,
877 .timer_create = alarm_timer_create,
878 .timer_set = alarm_timer_set,
879 .timer_del = alarm_timer_del,
880 .timer_get = alarm_timer_get,
881 .nsleep = alarm_timer_nsleep,
882 };
883 885
884 alarmtimer_rtc_timer_init(); 886 alarmtimer_rtc_timer_init();
885 887
886 if (IS_ENABLED(CONFIG_POSIX_TIMERS)) {
887 posix_timers_register_clock(CLOCK_REALTIME_ALARM, &alarm_clock);
888 posix_timers_register_clock(CLOCK_BOOTTIME_ALARM, &alarm_clock);
889 }
890
891 /* Initialize alarm bases */ 888 /* Initialize alarm bases */
892 alarm_bases[ALARM_REALTIME].base_clockid = CLOCK_REALTIME; 889 alarm_bases[ALARM_REALTIME].base_clockid = CLOCK_REALTIME;
893 alarm_bases[ALARM_REALTIME].gettime = &ktime_get_real; 890 alarm_bases[ALARM_REALTIME].gettime = &ktime_get_real;
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index 31d588d37a17..7e453005e078 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -434,7 +434,7 @@ static int pc_timer_settime(struct k_itimer *kit, int flags,
434 return err; 434 return err;
435} 435}
436 436
437struct k_clock clock_posix_dynamic = { 437const struct k_clock clock_posix_dynamic = {
438 .clock_getres = pc_clock_getres, 438 .clock_getres = pc_clock_getres,
439 .clock_set = pc_clock_settime, 439 .clock_set = pc_clock_settime,
440 .clock_get = pc_clock_gettime, 440 .clock_get = pc_clock_gettime,
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 1370f067fb51..1a522b39f19d 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -1413,7 +1413,7 @@ static int thread_cpu_timer_create(struct k_itimer *timer)
1413 return posix_cpu_timer_create(timer); 1413 return posix_cpu_timer_create(timer);
1414} 1414}
1415 1415
1416struct k_clock clock_posix_cpu = { 1416const struct k_clock clock_posix_cpu = {
1417 .clock_getres = posix_cpu_clock_getres, 1417 .clock_getres = posix_cpu_clock_getres,
1418 .clock_set = posix_cpu_clock_set, 1418 .clock_set = posix_cpu_clock_set,
1419 .clock_get = posix_cpu_clock_get, 1419 .clock_get = posix_cpu_clock_get,
@@ -1425,24 +1425,16 @@ struct k_clock clock_posix_cpu = {
1425 .timer_get = posix_cpu_timer_get, 1425 .timer_get = posix_cpu_timer_get,
1426}; 1426};
1427 1427
1428static __init int init_posix_cpu_timers(void) 1428const struct k_clock clock_process = {
1429{ 1429 .clock_getres = process_cpu_clock_getres,
1430 struct k_clock process = { 1430 .clock_get = process_cpu_clock_get,
1431 .clock_getres = process_cpu_clock_getres, 1431 .timer_create = process_cpu_timer_create,
1432 .clock_get = process_cpu_clock_get, 1432 .nsleep = process_cpu_nsleep,
1433 .timer_create = process_cpu_timer_create, 1433 .nsleep_restart = process_cpu_nsleep_restart,
1434 .nsleep = process_cpu_nsleep, 1434};
1435 .nsleep_restart = process_cpu_nsleep_restart,
1436 };
1437 struct k_clock thread = {
1438 .clock_getres = thread_cpu_clock_getres,
1439 .clock_get = thread_cpu_clock_get,
1440 .timer_create = thread_cpu_timer_create,
1441 };
1442
1443 posix_timers_register_clock(CLOCK_PROCESS_CPUTIME_ID, &process);
1444 posix_timers_register_clock(CLOCK_THREAD_CPUTIME_ID, &thread);
1445 1435
1446 return 0; 1436const struct k_clock clock_thread = {
1447} 1437 .clock_getres = thread_cpu_clock_getres,
1448__initcall(init_posix_cpu_timers); 1438 .clock_get = thread_cpu_clock_get,
1439 .timer_create = thread_cpu_timer_create,
1440};
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 4d7b2ce09c27..0c0cccfa3586 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -125,8 +125,6 @@ static DEFINE_SPINLOCK(hash_lock);
125 * which we beg off on and pass to do_sys_settimeofday(). 125 * which we beg off on and pass to do_sys_settimeofday().
126 */ 126 */
127 127
128static struct k_clock posix_clocks[MAX_CLOCKS];
129
130/* 128/*
131 * These ones are defined below. 129 * These ones are defined below.
132 */ 130 */
@@ -280,74 +278,87 @@ static int posix_get_hrtimer_res(clockid_t which_clock, struct timespec64 *tp)
280 return 0; 278 return 0;
281} 279}
282 280
281
282static const struct k_clock clock_realtime = {
283 .clock_getres = posix_get_hrtimer_res,
284 .clock_get = posix_clock_realtime_get,
285 .clock_set = posix_clock_realtime_set,
286 .clock_adj = posix_clock_realtime_adj,
287 .nsleep = common_nsleep,
288 .nsleep_restart = hrtimer_nanosleep_restart,
289 .timer_create = common_timer_create,
290 .timer_set = common_timer_set,
291 .timer_get = common_timer_get,
292 .timer_del = common_timer_del,
293};
294
295static const struct k_clock clock_monotonic = {
296 .clock_getres = posix_get_hrtimer_res,
297 .clock_get = posix_ktime_get_ts,
298 .nsleep = common_nsleep,
299 .nsleep_restart = hrtimer_nanosleep_restart,
300 .timer_create = common_timer_create,
301 .timer_set = common_timer_set,
302 .timer_get = common_timer_get,
303 .timer_del = common_timer_del,
304};
305
306static const struct k_clock clock_monotonic_raw = {
307 .clock_getres = posix_get_hrtimer_res,
308 .clock_get = posix_get_monotonic_raw,
309};
310
311static const struct k_clock clock_realtime_coarse = {
312 .clock_getres = posix_get_coarse_res,
313 .clock_get = posix_get_realtime_coarse,
314};
315
316static const struct k_clock clock_monotonic_coarse = {
317 .clock_getres = posix_get_coarse_res,
318 .clock_get = posix_get_monotonic_coarse,
319};
320
321static const struct k_clock clock_tai = {
322 .clock_getres = posix_get_hrtimer_res,
323 .clock_get = posix_get_tai,
324 .nsleep = common_nsleep,
325 .nsleep_restart = hrtimer_nanosleep_restart,
326 .timer_create = common_timer_create,
327 .timer_set = common_timer_set,
328 .timer_get = common_timer_get,
329 .timer_del = common_timer_del,
330};
331
332static const struct k_clock clock_boottime = {
333 .clock_getres = posix_get_hrtimer_res,
334 .clock_get = posix_get_boottime,
335 .nsleep = common_nsleep,
336 .nsleep_restart = hrtimer_nanosleep_restart,
337 .timer_create = common_timer_create,
338 .timer_set = common_timer_set,
339 .timer_get = common_timer_get,
340 .timer_del = common_timer_del,
341};
342
343static const struct k_clock * const posix_clocks[] = {
344 [CLOCK_REALTIME] = &clock_realtime,
345 [CLOCK_MONOTONIC] = &clock_monotonic,
346 [CLOCK_PROCESS_CPUTIME_ID] = &clock_process,
347 [CLOCK_THREAD_CPUTIME_ID] = &clock_thread,
348 [CLOCK_MONOTONIC_RAW] = &clock_monotonic_raw,
349 [CLOCK_REALTIME_COARSE] = &clock_realtime_coarse,
350 [CLOCK_MONOTONIC_COARSE] = &clock_monotonic_coarse,
351 [CLOCK_BOOTTIME] = &clock_boottime,
352 [CLOCK_REALTIME_ALARM] = &alarm_clock,
353 [CLOCK_BOOTTIME_ALARM] = &alarm_clock,
354 [CLOCK_TAI] = &clock_tai,
355};
356
283/* 357/*
284 * Initialize everything, well, just everything in Posix clocks/timers ;) 358 * Initialize everything, well, just everything in Posix clocks/timers ;)
285 */ 359 */
286static __init int init_posix_timers(void) 360static __init int init_posix_timers(void)
287{ 361{
288 struct k_clock clock_realtime = {
289 .clock_getres = posix_get_hrtimer_res,
290 .clock_get = posix_clock_realtime_get,
291 .clock_set = posix_clock_realtime_set,
292 .clock_adj = posix_clock_realtime_adj,
293 .nsleep = common_nsleep,
294 .nsleep_restart = hrtimer_nanosleep_restart,
295 .timer_create = common_timer_create,
296 .timer_set = common_timer_set,
297 .timer_get = common_timer_get,
298 .timer_del = common_timer_del,
299 };
300 struct k_clock clock_monotonic = {
301 .clock_getres = posix_get_hrtimer_res,
302 .clock_get = posix_ktime_get_ts,
303 .nsleep = common_nsleep,
304 .nsleep_restart = hrtimer_nanosleep_restart,
305 .timer_create = common_timer_create,
306 .timer_set = common_timer_set,
307 .timer_get = common_timer_get,
308 .timer_del = common_timer_del,
309 };
310 struct k_clock clock_monotonic_raw = {
311 .clock_getres = posix_get_hrtimer_res,
312 .clock_get = posix_get_monotonic_raw,
313 };
314 struct k_clock clock_realtime_coarse = {
315 .clock_getres = posix_get_coarse_res,
316 .clock_get = posix_get_realtime_coarse,
317 };
318 struct k_clock clock_monotonic_coarse = {
319 .clock_getres = posix_get_coarse_res,
320 .clock_get = posix_get_monotonic_coarse,
321 };
322 struct k_clock clock_tai = {
323 .clock_getres = posix_get_hrtimer_res,
324 .clock_get = posix_get_tai,
325 .nsleep = common_nsleep,
326 .nsleep_restart = hrtimer_nanosleep_restart,
327 .timer_create = common_timer_create,
328 .timer_set = common_timer_set,
329 .timer_get = common_timer_get,
330 .timer_del = common_timer_del,
331 };
332 struct k_clock clock_boottime = {
333 .clock_getres = posix_get_hrtimer_res,
334 .clock_get = posix_get_boottime,
335 .nsleep = common_nsleep,
336 .nsleep_restart = hrtimer_nanosleep_restart,
337 .timer_create = common_timer_create,
338 .timer_set = common_timer_set,
339 .timer_get = common_timer_get,
340 .timer_del = common_timer_del,
341 };
342
343 posix_timers_register_clock(CLOCK_REALTIME, &clock_realtime);
344 posix_timers_register_clock(CLOCK_MONOTONIC, &clock_monotonic);
345 posix_timers_register_clock(CLOCK_MONOTONIC_RAW, &clock_monotonic_raw);
346 posix_timers_register_clock(CLOCK_REALTIME_COARSE, &clock_realtime_coarse);
347 posix_timers_register_clock(CLOCK_MONOTONIC_COARSE, &clock_monotonic_coarse);
348 posix_timers_register_clock(CLOCK_BOOTTIME, &clock_boottime);
349 posix_timers_register_clock(CLOCK_TAI, &clock_tai);
350
351 posix_timers_cache = kmem_cache_create("posix_timers_cache", 362 posix_timers_cache = kmem_cache_create("posix_timers_cache",
352 sizeof (struct k_itimer), 0, SLAB_PANIC, 363 sizeof (struct k_itimer), 0, SLAB_PANIC,
353 NULL); 364 NULL);
@@ -521,30 +532,6 @@ static struct pid *good_sigevent(sigevent_t * event)
521 return task_pid(rtn); 532 return task_pid(rtn);
522} 533}
523 534
524void posix_timers_register_clock(const clockid_t clock_id,
525 struct k_clock *new_clock)
526{
527 if ((unsigned) clock_id >= MAX_CLOCKS) {
528 printk(KERN_WARNING "POSIX clock register failed for clock_id %d\n",
529 clock_id);
530 return;
531 }
532
533 if (!new_clock->clock_get) {
534 printk(KERN_WARNING "POSIX clock id %d lacks clock_get()\n",
535 clock_id);
536 return;
537 }
538 if (!new_clock->clock_getres) {
539 printk(KERN_WARNING "POSIX clock id %d lacks clock_getres()\n",
540 clock_id);
541 return;
542 }
543
544 posix_clocks[clock_id] = *new_clock;
545}
546EXPORT_SYMBOL_GPL(posix_timers_register_clock);
547
548static struct k_itimer * alloc_posix_timer(void) 535static struct k_itimer * alloc_posix_timer(void)
549{ 536{
550 struct k_itimer *tmr; 537 struct k_itimer *tmr;
@@ -581,15 +568,15 @@ static void release_posix_timer(struct k_itimer *tmr, int it_id_set)
581 call_rcu(&tmr->it.rcu, k_itimer_rcu_free); 568 call_rcu(&tmr->it.rcu, k_itimer_rcu_free);
582} 569}
583 570
584static struct k_clock *clockid_to_kclock(const clockid_t id) 571static const struct k_clock *clockid_to_kclock(const clockid_t id)
585{ 572{
586 if (id < 0) 573 if (id < 0)
587 return (id & CLOCKFD_MASK) == CLOCKFD ? 574 return (id & CLOCKFD_MASK) == CLOCKFD ?
588 &clock_posix_dynamic : &clock_posix_cpu; 575 &clock_posix_dynamic : &clock_posix_cpu;
589 576
590 if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres) 577 if (id >= ARRAY_SIZE(posix_clocks) || !posix_clocks[id])
591 return NULL; 578 return NULL;
592 return &posix_clocks[id]; 579 return posix_clocks[id];
593} 580}
594 581
595static int common_timer_create(struct k_itimer *new_timer) 582static int common_timer_create(struct k_itimer *new_timer)
@@ -604,7 +591,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
604 struct sigevent __user *, timer_event_spec, 591 struct sigevent __user *, timer_event_spec,
605 timer_t __user *, created_timer_id) 592 timer_t __user *, created_timer_id)
606{ 593{
607 struct k_clock *kc = clockid_to_kclock(which_clock); 594 const struct k_clock *kc = clockid_to_kclock(which_clock);
608 struct k_itimer *new_timer; 595 struct k_itimer *new_timer;
609 int error, new_timer_id; 596 int error, new_timer_id;
610 sigevent_t event; 597 sigevent_t event;
@@ -781,7 +768,7 @@ SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id,
781 struct itimerspec64 cur_setting64; 768 struct itimerspec64 cur_setting64;
782 struct itimerspec cur_setting; 769 struct itimerspec cur_setting;
783 struct k_itimer *timr; 770 struct k_itimer *timr;
784 struct k_clock *kc; 771 const struct k_clock *kc;
785 unsigned long flags; 772 unsigned long flags;
786 int ret = 0; 773 int ret = 0;
787 774
@@ -890,7 +877,7 @@ SYSCALL_DEFINE4(timer_settime, timer_t, timer_id, int, flags,
890 struct itimerspec new_spec, old_spec; 877 struct itimerspec new_spec, old_spec;
891 struct k_itimer *timr; 878 struct k_itimer *timr;
892 unsigned long flag; 879 unsigned long flag;
893 struct k_clock *kc; 880 const struct k_clock *kc;
894 int error = 0; 881 int error = 0;
895 882
896 if (!new_setting) 883 if (!new_setting)
@@ -939,7 +926,7 @@ static int common_timer_del(struct k_itimer *timer)
939 926
940static inline int timer_delete_hook(struct k_itimer *timer) 927static inline int timer_delete_hook(struct k_itimer *timer)
941{ 928{
942 struct k_clock *kc = clockid_to_kclock(timer->it_clock); 929 const struct k_clock *kc = clockid_to_kclock(timer->it_clock);
943 930
944 if (WARN_ON_ONCE(!kc || !kc->timer_del)) 931 if (WARN_ON_ONCE(!kc || !kc->timer_del))
945 return -EINVAL; 932 return -EINVAL;
@@ -1018,7 +1005,7 @@ void exit_itimers(struct signal_struct *sig)
1018SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock, 1005SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
1019 const struct timespec __user *, tp) 1006 const struct timespec __user *, tp)
1020{ 1007{
1021 struct k_clock *kc = clockid_to_kclock(which_clock); 1008 const struct k_clock *kc = clockid_to_kclock(which_clock);
1022 struct timespec64 new_tp64; 1009 struct timespec64 new_tp64;
1023 struct timespec new_tp; 1010 struct timespec new_tp;
1024 1011
@@ -1035,7 +1022,7 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
1035SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock, 1022SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
1036 struct timespec __user *,tp) 1023 struct timespec __user *,tp)
1037{ 1024{
1038 struct k_clock *kc = clockid_to_kclock(which_clock); 1025 const struct k_clock *kc = clockid_to_kclock(which_clock);
1039 struct timespec64 kernel_tp64; 1026 struct timespec64 kernel_tp64;
1040 struct timespec kernel_tp; 1027 struct timespec kernel_tp;
1041 int error; 1028 int error;
@@ -1055,7 +1042,7 @@ SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
1055SYSCALL_DEFINE2(clock_adjtime, const clockid_t, which_clock, 1042SYSCALL_DEFINE2(clock_adjtime, const clockid_t, which_clock,
1056 struct timex __user *, utx) 1043 struct timex __user *, utx)
1057{ 1044{
1058 struct k_clock *kc = clockid_to_kclock(which_clock); 1045 const struct k_clock *kc = clockid_to_kclock(which_clock);
1059 struct timex ktx; 1046 struct timex ktx;
1060 int err; 1047 int err;
1061 1048
@@ -1078,7 +1065,7 @@ SYSCALL_DEFINE2(clock_adjtime, const clockid_t, which_clock,
1078SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock, 1065SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock,
1079 struct timespec __user *, tp) 1066 struct timespec __user *, tp)
1080{ 1067{
1081 struct k_clock *kc = clockid_to_kclock(which_clock); 1068 const struct k_clock *kc = clockid_to_kclock(which_clock);
1082 struct timespec64 rtn_tp64; 1069 struct timespec64 rtn_tp64;
1083 struct timespec rtn_tp; 1070 struct timespec rtn_tp;
1084 int error; 1071 int error;
@@ -1110,7 +1097,7 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
1110 const struct timespec __user *, rqtp, 1097 const struct timespec __user *, rqtp,
1111 struct timespec __user *, rmtp) 1098 struct timespec __user *, rmtp)
1112{ 1099{
1113 struct k_clock *kc = clockid_to_kclock(which_clock); 1100 const struct k_clock *kc = clockid_to_kclock(which_clock);
1114 struct timespec64 t64; 1101 struct timespec64 t64;
1115 struct timespec t; 1102 struct timespec t;
1116 1103
@@ -1136,7 +1123,7 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
1136long clock_nanosleep_restart(struct restart_block *restart_block) 1123long clock_nanosleep_restart(struct restart_block *restart_block)
1137{ 1124{
1138 clockid_t which_clock = restart_block->nanosleep.clockid; 1125 clockid_t which_clock = restart_block->nanosleep.clockid;
1139 struct k_clock *kc = clockid_to_kclock(which_clock); 1126 const struct k_clock *kc = clockid_to_kclock(which_clock);
1140 1127
1141 if (WARN_ON_ONCE(!kc || !kc->nsleep_restart)) 1128 if (WARN_ON_ONCE(!kc || !kc->nsleep_restart))
1142 return -EINVAL; 1129 return -EINVAL;