Commit a924b04ddea9788e09f387fe19ccbede5f09ddd8

Authored by Thomas Gleixner
Committed by Linus Torvalds
1 parent 57a558757b

[PATCH] hrtimer: make clockid_t arguments const

add const arguments to the posix-timers.h API functions

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 3 changed files with 54 additions and 46 deletions Side-by-side Diff

include/linux/posix-timers.h
... ... @@ -72,12 +72,12 @@
72 72 };
73 73 struct k_clock {
74 74 int res; /* in nano seconds */
75   - int (*clock_getres) (clockid_t which_clock, struct timespec *tp);
  75 + int (*clock_getres) (const clockid_t which_clock, struct timespec *tp);
76 76 struct k_clock_abs *abs_struct;
77   - int (*clock_set) (clockid_t which_clock, struct timespec * tp);
78   - int (*clock_get) (clockid_t which_clock, struct timespec * tp);
  77 + int (*clock_set) (const clockid_t which_clock, struct timespec * tp);
  78 + int (*clock_get) (const clockid_t which_clock, struct timespec * tp);
79 79 int (*timer_create) (struct k_itimer *timer);
80   - int (*nsleep) (clockid_t which_clock, int flags, struct timespec *);
  80 + int (*nsleep) (const clockid_t which_clock, int flags, struct timespec *);
81 81 int (*timer_set) (struct k_itimer * timr, int flags,
82 82 struct itimerspec * new_setting,
83 83 struct itimerspec * old_setting);
84 84  
... ... @@ -87,12 +87,12 @@
87 87 struct itimerspec * cur_setting);
88 88 };
89 89  
90   -void register_posix_clock(clockid_t clock_id, struct k_clock *new_clock);
  90 +void register_posix_clock(const clockid_t clock_id, struct k_clock *new_clock);
91 91  
92 92 /* Error handlers for timer_create, nanosleep and settime */
93 93 int do_posix_clock_notimer_create(struct k_itimer *timer);
94   -int do_posix_clock_nonanosleep(clockid_t, int flags, struct timespec *);
95   -int do_posix_clock_nosettime(clockid_t, struct timespec *tp);
  94 +int do_posix_clock_nonanosleep(const clockid_t, int flags, struct timespec *);
  95 +int do_posix_clock_nosettime(const clockid_t, struct timespec *tp);
96 96  
97 97 /* function to call to trigger timer event */
98 98 int posix_timer_event(struct k_itimer *timr, int si_private);
99 99  
... ... @@ -117,11 +117,11 @@
117 117 } \
118 118 }while (0)
119 119  
120   -int posix_cpu_clock_getres(clockid_t which_clock, struct timespec *);
121   -int posix_cpu_clock_get(clockid_t which_clock, struct timespec *);
122   -int posix_cpu_clock_set(clockid_t which_clock, const struct timespec *tp);
  120 +int posix_cpu_clock_getres(const clockid_t which_clock, struct timespec *);
  121 +int posix_cpu_clock_get(const clockid_t which_clock, struct timespec *);
  122 +int posix_cpu_clock_set(const clockid_t which_clock, const struct timespec *tp);
123 123 int posix_cpu_timer_create(struct k_itimer *);
124   -int posix_cpu_nsleep(clockid_t, int, struct timespec *);
  124 +int posix_cpu_nsleep(const clockid_t, int, struct timespec *);
125 125 int posix_cpu_timer_set(struct k_itimer *, int,
126 126 struct itimerspec *, struct itimerspec *);
127 127 int posix_cpu_timer_del(struct k_itimer *);
kernel/posix-cpu-timers.c
... ... @@ -7,7 +7,7 @@
7 7 #include <asm/uaccess.h>
8 8 #include <linux/errno.h>
9 9  
10   -static int check_clock(clockid_t which_clock)
  10 +static int check_clock(const clockid_t which_clock)
11 11 {
12 12 int error = 0;
13 13 struct task_struct *p;
... ... @@ -31,7 +31,7 @@
31 31 }
32 32  
33 33 static inline union cpu_time_count
34   -timespec_to_sample(clockid_t which_clock, const struct timespec *tp)
  34 +timespec_to_sample(const clockid_t which_clock, const struct timespec *tp)
35 35 {
36 36 union cpu_time_count ret;
37 37 ret.sched = 0; /* high half always zero when .cpu used */
... ... @@ -43,7 +43,7 @@
43 43 return ret;
44 44 }
45 45  
46   -static void sample_to_timespec(clockid_t which_clock,
  46 +static void sample_to_timespec(const clockid_t which_clock,
47 47 union cpu_time_count cpu,
48 48 struct timespec *tp)
49 49 {
... ... @@ -55,7 +55,7 @@
55 55 }
56 56 }
57 57  
58   -static inline int cpu_time_before(clockid_t which_clock,
  58 +static inline int cpu_time_before(const clockid_t which_clock,
59 59 union cpu_time_count now,
60 60 union cpu_time_count then)
61 61 {
... ... @@ -65,7 +65,7 @@
65 65 return cputime_lt(now.cpu, then.cpu);
66 66 }
67 67 }
68   -static inline void cpu_time_add(clockid_t which_clock,
  68 +static inline void cpu_time_add(const clockid_t which_clock,
69 69 union cpu_time_count *acc,
70 70 union cpu_time_count val)
71 71 {
... ... @@ -75,7 +75,7 @@
75 75 acc->cpu = cputime_add(acc->cpu, val.cpu);
76 76 }
77 77 }
78   -static inline union cpu_time_count cpu_time_sub(clockid_t which_clock,
  78 +static inline union cpu_time_count cpu_time_sub(const clockid_t which_clock,
79 79 union cpu_time_count a,
80 80 union cpu_time_count b)
81 81 {
... ... @@ -151,7 +151,7 @@
151 151 return (p == current) ? current_sched_time(p) : p->sched_time;
152 152 }
153 153  
154   -int posix_cpu_clock_getres(clockid_t which_clock, struct timespec *tp)
  154 +int posix_cpu_clock_getres(const clockid_t which_clock, struct timespec *tp)
155 155 {
156 156 int error = check_clock(which_clock);
157 157 if (!error) {
... ... @@ -169,7 +169,7 @@
169 169 return error;
170 170 }
171 171  
172   -int posix_cpu_clock_set(clockid_t which_clock, const struct timespec *tp)
  172 +int posix_cpu_clock_set(const clockid_t which_clock, const struct timespec *tp)
173 173 {
174 174 /*
175 175 * You can never reset a CPU clock, but we check for other errors
... ... @@ -186,7 +186,7 @@
186 186 /*
187 187 * Sample a per-thread clock for the given task.
188 188 */
189   -static int cpu_clock_sample(clockid_t which_clock, struct task_struct *p,
  189 +static int cpu_clock_sample(const clockid_t which_clock, struct task_struct *p,
190 190 union cpu_time_count *cpu)
191 191 {
192 192 switch (CPUCLOCK_WHICH(which_clock)) {
... ... @@ -248,7 +248,7 @@
248 248 * Sample a process (thread group) clock for the given group_leader task.
249 249 * Must be called with tasklist_lock held for reading.
250 250 */
251   -static int cpu_clock_sample_group(clockid_t which_clock,
  251 +static int cpu_clock_sample_group(const clockid_t which_clock,
252 252 struct task_struct *p,
253 253 union cpu_time_count *cpu)
254 254 {
... ... @@ -262,7 +262,7 @@
262 262 }
263 263  
264 264  
265   -int posix_cpu_clock_get(clockid_t which_clock, struct timespec *tp)
  265 +int posix_cpu_clock_get(const clockid_t which_clock, struct timespec *tp)
266 266 {
267 267 const pid_t pid = CPUCLOCK_PID(which_clock);
268 268 int error = -EINVAL;
... ... @@ -1399,7 +1399,7 @@
1399 1399  
1400 1400 static long posix_cpu_clock_nanosleep_restart(struct restart_block *);
1401 1401  
1402   -int posix_cpu_nsleep(clockid_t which_clock, int flags,
  1402 +int posix_cpu_nsleep(const clockid_t which_clock, int flags,
1403 1403 struct timespec *rqtp)
1404 1404 {
1405 1405 struct restart_block *restart_block =
1406 1406  
... ... @@ -1503,11 +1503,13 @@
1503 1503 #define PROCESS_CLOCK MAKE_PROCESS_CPUCLOCK(0, CPUCLOCK_SCHED)
1504 1504 #define THREAD_CLOCK MAKE_THREAD_CPUCLOCK(0, CPUCLOCK_SCHED)
1505 1505  
1506   -static int process_cpu_clock_getres(clockid_t which_clock, struct timespec *tp)
  1506 +static int process_cpu_clock_getres(const clockid_t which_clock,
  1507 + struct timespec *tp)
1507 1508 {
1508 1509 return posix_cpu_clock_getres(PROCESS_CLOCK, tp);
1509 1510 }
1510   -static int process_cpu_clock_get(clockid_t which_clock, struct timespec *tp)
  1511 +static int process_cpu_clock_get(const clockid_t which_clock,
  1512 + struct timespec *tp)
1511 1513 {
1512 1514 return posix_cpu_clock_get(PROCESS_CLOCK, tp);
1513 1515 }
1514 1516  
1515 1517  
... ... @@ -1516,16 +1518,18 @@
1516 1518 timer->it_clock = PROCESS_CLOCK;
1517 1519 return posix_cpu_timer_create(timer);
1518 1520 }
1519   -static int process_cpu_nsleep(clockid_t which_clock, int flags,
  1521 +static int process_cpu_nsleep(const clockid_t which_clock, int flags,
1520 1522 struct timespec *rqtp)
1521 1523 {
1522 1524 return posix_cpu_nsleep(PROCESS_CLOCK, flags, rqtp);
1523 1525 }
1524   -static int thread_cpu_clock_getres(clockid_t which_clock, struct timespec *tp)
  1526 +static int thread_cpu_clock_getres(const clockid_t which_clock,
  1527 + struct timespec *tp)
1525 1528 {
1526 1529 return posix_cpu_clock_getres(THREAD_CLOCK, tp);
1527 1530 }
1528   -static int thread_cpu_clock_get(clockid_t which_clock, struct timespec *tp)
  1531 +static int thread_cpu_clock_get(const clockid_t which_clock,
  1532 + struct timespec *tp)
1529 1533 {
1530 1534 return posix_cpu_clock_get(THREAD_CLOCK, tp);
1531 1535 }
... ... @@ -1534,7 +1538,7 @@
1534 1538 timer->it_clock = THREAD_CLOCK;
1535 1539 return posix_cpu_timer_create(timer);
1536 1540 }
1537   -static int thread_cpu_nsleep(clockid_t which_clock, int flags,
  1541 +static int thread_cpu_nsleep(const clockid_t which_clock, int flags,
1538 1542 struct timespec *rqtp)
1539 1543 {
1540 1544 return -EINVAL;
kernel/posix-timers.c
... ... @@ -151,7 +151,7 @@
151 151 static u64 do_posix_clock_monotonic_gettime_parts(
152 152 struct timespec *tp, struct timespec *mo);
153 153 int do_posix_clock_monotonic_gettime(struct timespec *tp);
154   -static int do_posix_clock_monotonic_get(clockid_t, struct timespec *tp);
  154 +static int do_posix_clock_monotonic_get(const clockid_t, struct timespec *tp);
155 155  
156 156 static struct k_itimer *lock_timer(timer_t timer_id, unsigned long *flags);
157 157  
... ... @@ -176,7 +176,7 @@
176 176 * the function pointer CALL in struct k_clock.
177 177 */
178 178  
179   -static inline int common_clock_getres(clockid_t which_clock,
  179 +static inline int common_clock_getres(const clockid_t which_clock,
180 180 struct timespec *tp)
181 181 {
182 182 tp->tv_sec = 0;
183 183  
... ... @@ -184,13 +184,15 @@
184 184 return 0;
185 185 }
186 186  
187   -static inline int common_clock_get(clockid_t which_clock, struct timespec *tp)
  187 +static inline int common_clock_get(const clockid_t which_clock,
  188 + struct timespec *tp)
188 189 {
189 190 getnstimeofday(tp);
190 191 return 0;
191 192 }
192 193  
193   -static inline int common_clock_set(clockid_t which_clock, struct timespec *tp)
  194 +static inline int common_clock_set(const clockid_t which_clock,
  195 + struct timespec *tp)
194 196 {
195 197 return do_sys_settimeofday(tp, NULL);
196 198 }
... ... @@ -207,7 +209,7 @@
207 209 /*
208 210 * These ones are defined below.
209 211 */
210   -static int common_nsleep(clockid_t, int flags, struct timespec *t);
  212 +static int common_nsleep(const clockid_t, int flags, struct timespec *t);
211 213 static void common_timer_get(struct k_itimer *, struct itimerspec *);
212 214 static int common_timer_set(struct k_itimer *, int,
213 215 struct itimerspec *, struct itimerspec *);
... ... @@ -216,7 +218,7 @@
216 218 /*
217 219 * Return nonzero iff we know a priori this clockid_t value is bogus.
218 220 */
219   -static inline int invalid_clockid(clockid_t which_clock)
  221 +static inline int invalid_clockid(const clockid_t which_clock)
220 222 {
221 223 if (which_clock < 0) /* CPU clock, posix_cpu_* will check it */
222 224 return 0;
... ... @@ -522,7 +524,7 @@
522 524 return rtn;
523 525 }
524 526  
525   -void register_posix_clock(clockid_t clock_id, struct k_clock *new_clock)
  527 +void register_posix_clock(const clockid_t clock_id, struct k_clock *new_clock)
526 528 {
527 529 if ((unsigned) clock_id >= MAX_CLOCKS) {
528 530 printk("POSIX clock register failed for clock_id %d\n",
... ... @@ -568,7 +570,7 @@
568 570 /* Create a POSIX.1b interval timer. */
569 571  
570 572 asmlinkage long
571   -sys_timer_create(clockid_t which_clock,
  573 +sys_timer_create(const clockid_t which_clock,
572 574 struct sigevent __user *timer_event_spec,
573 575 timer_t __user * created_timer_id)
574 576 {
... ... @@ -1195,7 +1197,8 @@
1195 1197 return jiff;
1196 1198 }
1197 1199  
1198   -static int do_posix_clock_monotonic_get(clockid_t clock, struct timespec *tp)
  1200 +static int do_posix_clock_monotonic_get(const clockid_t clock,
  1201 + struct timespec *tp)
1199 1202 {
1200 1203 struct timespec wall_to_mono;
1201 1204  
... ... @@ -1212,7 +1215,7 @@
1212 1215 return do_posix_clock_monotonic_get(CLOCK_MONOTONIC, tp);
1213 1216 }
1214 1217  
1215   -int do_posix_clock_nosettime(clockid_t clockid, struct timespec *tp)
  1218 +int do_posix_clock_nosettime(const clockid_t clockid, struct timespec *tp)
1216 1219 {
1217 1220 return -EINVAL;
1218 1221 }
... ... @@ -1224,7 +1227,8 @@
1224 1227 }
1225 1228 EXPORT_SYMBOL_GPL(do_posix_clock_notimer_create);
1226 1229  
1227   -int do_posix_clock_nonanosleep(clockid_t clock, int flags, struct timespec *t)
  1230 +int do_posix_clock_nonanosleep(const clockid_t clock, int flags,
  1231 + struct timespec *t)
1228 1232 {
1229 1233 #ifndef ENOTSUP
1230 1234 return -EOPNOTSUPP; /* aka ENOTSUP in userland for POSIX */
... ... @@ -1234,8 +1238,8 @@
1234 1238 }
1235 1239 EXPORT_SYMBOL_GPL(do_posix_clock_nonanosleep);
1236 1240  
1237   -asmlinkage long
1238   -sys_clock_settime(clockid_t which_clock, const struct timespec __user *tp)
  1241 +asmlinkage long sys_clock_settime(const clockid_t which_clock,
  1242 + const struct timespec __user *tp)
1239 1243 {
1240 1244 struct timespec new_tp;
1241 1245  
... ... @@ -1248,7 +1252,7 @@
1248 1252 }
1249 1253  
1250 1254 asmlinkage long
1251   -sys_clock_gettime(clockid_t which_clock, struct timespec __user *tp)
  1255 +sys_clock_gettime(const clockid_t which_clock, struct timespec __user *tp)
1252 1256 {
1253 1257 struct timespec kernel_tp;
1254 1258 int error;
... ... @@ -1265,7 +1269,7 @@
1265 1269 }
1266 1270  
1267 1271 asmlinkage long
1268   -sys_clock_getres(clockid_t which_clock, struct timespec __user *tp)
  1272 +sys_clock_getres(const clockid_t which_clock, struct timespec __user *tp)
1269 1273 {
1270 1274 struct timespec rtn_tp;
1271 1275 int error;
... ... @@ -1387,7 +1391,7 @@
1387 1391 long clock_nanosleep_restart(struct restart_block *restart_block);
1388 1392  
1389 1393 asmlinkage long
1390   -sys_clock_nanosleep(clockid_t which_clock, int flags,
  1394 +sys_clock_nanosleep(const clockid_t which_clock, int flags,
1391 1395 const struct timespec __user *rqtp,
1392 1396 struct timespec __user *rmtp)
1393 1397 {
... ... @@ -1419,7 +1423,7 @@
1419 1423 }
1420 1424  
1421 1425  
1422   -static int common_nsleep(clockid_t which_clock,
  1426 +static int common_nsleep(const clockid_t which_clock,
1423 1427 int flags, struct timespec *tsave)
1424 1428 {
1425 1429 struct timespec t, dum;