diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2006-01-09 23:52:27 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-10 11:01:36 -0500 |
commit | a924b04ddea9788e09f387fe19ccbede5f09ddd8 (patch) | |
tree | aa519a2427b7686d35ceae764d3e37d69a6ae5e8 /kernel | |
parent | 57a558757bdbb877b54ed5ea15bd0892e02a707d (diff) |
[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>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/posix-cpu-timers.c | 40 | ||||
-rw-r--r-- | kernel/posix-timers.c | 38 |
2 files changed, 43 insertions, 35 deletions
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c index 4c68edff900b..abf6990c6eb5 100644 --- a/kernel/posix-cpu-timers.c +++ b/kernel/posix-cpu-timers.c | |||
@@ -7,7 +7,7 @@ | |||
7 | #include <asm/uaccess.h> | 7 | #include <asm/uaccess.h> |
8 | #include <linux/errno.h> | 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 | int error = 0; | 12 | int error = 0; |
13 | struct task_struct *p; | 13 | struct task_struct *p; |
@@ -31,7 +31,7 @@ static int check_clock(clockid_t which_clock) | |||
31 | } | 31 | } |
32 | 32 | ||
33 | static inline union cpu_time_count | 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 | union cpu_time_count ret; | 36 | union cpu_time_count ret; |
37 | ret.sched = 0; /* high half always zero when .cpu used */ | 37 | ret.sched = 0; /* high half always zero when .cpu used */ |
@@ -43,7 +43,7 @@ timespec_to_sample(clockid_t which_clock, const struct timespec *tp) | |||
43 | return ret; | 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 | union cpu_time_count cpu, | 47 | union cpu_time_count cpu, |
48 | struct timespec *tp) | 48 | struct timespec *tp) |
49 | { | 49 | { |
@@ -55,7 +55,7 @@ static void sample_to_timespec(clockid_t which_clock, | |||
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 | union cpu_time_count now, | 59 | union cpu_time_count now, |
60 | union cpu_time_count then) | 60 | union cpu_time_count then) |
61 | { | 61 | { |
@@ -65,7 +65,7 @@ static inline int cpu_time_before(clockid_t which_clock, | |||
65 | return cputime_lt(now.cpu, then.cpu); | 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 | union cpu_time_count *acc, | 69 | union cpu_time_count *acc, |
70 | union cpu_time_count val) | 70 | union cpu_time_count val) |
71 | { | 71 | { |
@@ -75,7 +75,7 @@ static inline void cpu_time_add(clockid_t which_clock, | |||
75 | acc->cpu = cputime_add(acc->cpu, val.cpu); | 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 | union cpu_time_count a, | 79 | union cpu_time_count a, |
80 | union cpu_time_count b) | 80 | union cpu_time_count b) |
81 | { | 81 | { |
@@ -151,7 +151,7 @@ static inline unsigned long long sched_ns(struct task_struct *p) | |||
151 | return (p == current) ? current_sched_time(p) : p->sched_time; | 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 | int error = check_clock(which_clock); | 156 | int error = check_clock(which_clock); |
157 | if (!error) { | 157 | if (!error) { |
@@ -169,7 +169,7 @@ int posix_cpu_clock_getres(clockid_t which_clock, struct timespec *tp) | |||
169 | return error; | 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 | * You can never reset a CPU clock, but we check for other errors | 175 | * You can never reset a CPU clock, but we check for other errors |
@@ -186,7 +186,7 @@ int posix_cpu_clock_set(clockid_t which_clock, const struct timespec *tp) | |||
186 | /* | 186 | /* |
187 | * Sample a per-thread clock for the given task. | 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 | union cpu_time_count *cpu) | 190 | union cpu_time_count *cpu) |
191 | { | 191 | { |
192 | switch (CPUCLOCK_WHICH(which_clock)) { | 192 | switch (CPUCLOCK_WHICH(which_clock)) { |
@@ -248,7 +248,7 @@ static int cpu_clock_sample_group_locked(unsigned int clock_idx, | |||
248 | * Sample a process (thread group) clock for the given group_leader task. | 248 | * Sample a process (thread group) clock for the given group_leader task. |
249 | * Must be called with tasklist_lock held for reading. | 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 | struct task_struct *p, | 252 | struct task_struct *p, |
253 | union cpu_time_count *cpu) | 253 | union cpu_time_count *cpu) |
254 | { | 254 | { |
@@ -262,7 +262,7 @@ static int cpu_clock_sample_group(clockid_t which_clock, | |||
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 | const pid_t pid = CPUCLOCK_PID(which_clock); | 267 | const pid_t pid = CPUCLOCK_PID(which_clock); |
268 | int error = -EINVAL; | 268 | int error = -EINVAL; |
@@ -1399,7 +1399,7 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clock_idx, | |||
1399 | 1399 | ||
1400 | static long posix_cpu_clock_nanosleep_restart(struct restart_block *); | 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 | struct timespec *rqtp) | 1403 | struct timespec *rqtp) |
1404 | { | 1404 | { |
1405 | struct restart_block *restart_block = | 1405 | struct restart_block *restart_block = |
@@ -1503,11 +1503,13 @@ posix_cpu_clock_nanosleep_restart(struct restart_block *restart_block) | |||
1503 | #define PROCESS_CLOCK MAKE_PROCESS_CPUCLOCK(0, CPUCLOCK_SCHED) | 1503 | #define PROCESS_CLOCK MAKE_PROCESS_CPUCLOCK(0, CPUCLOCK_SCHED) |
1504 | #define THREAD_CLOCK MAKE_THREAD_CPUCLOCK(0, CPUCLOCK_SCHED) | 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 | return posix_cpu_clock_getres(PROCESS_CLOCK, tp); | 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 | return posix_cpu_clock_get(PROCESS_CLOCK, tp); | 1514 | return posix_cpu_clock_get(PROCESS_CLOCK, tp); |
1513 | } | 1515 | } |
@@ -1516,16 +1518,18 @@ static int process_cpu_timer_create(struct k_itimer *timer) | |||
1516 | timer->it_clock = PROCESS_CLOCK; | 1518 | timer->it_clock = PROCESS_CLOCK; |
1517 | return posix_cpu_timer_create(timer); | 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 | struct timespec *rqtp) | 1522 | struct timespec *rqtp) |
1521 | { | 1523 | { |
1522 | return posix_cpu_nsleep(PROCESS_CLOCK, flags, rqtp); | 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 | return posix_cpu_clock_getres(THREAD_CLOCK, tp); | 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 | return posix_cpu_clock_get(THREAD_CLOCK, tp); | 1534 | return posix_cpu_clock_get(THREAD_CLOCK, tp); |
1531 | } | 1535 | } |
@@ -1534,7 +1538,7 @@ static int thread_cpu_timer_create(struct k_itimer *timer) | |||
1534 | timer->it_clock = THREAD_CLOCK; | 1538 | timer->it_clock = THREAD_CLOCK; |
1535 | return posix_cpu_timer_create(timer); | 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 | struct timespec *rqtp) | 1542 | struct timespec *rqtp) |
1539 | { | 1543 | { |
1540 | return -EINVAL; | 1544 | return -EINVAL; |
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c index fdb710777439..69d5a4b5395b 100644 --- a/kernel/posix-timers.c +++ b/kernel/posix-timers.c | |||
@@ -151,7 +151,7 @@ static void posix_timer_fn(unsigned long); | |||
151 | static u64 do_posix_clock_monotonic_gettime_parts( | 151 | static u64 do_posix_clock_monotonic_gettime_parts( |
152 | struct timespec *tp, struct timespec *mo); | 152 | struct timespec *tp, struct timespec *mo); |
153 | int do_posix_clock_monotonic_gettime(struct timespec *tp); | 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 | static struct k_itimer *lock_timer(timer_t timer_id, unsigned long *flags); | 156 | static struct k_itimer *lock_timer(timer_t timer_id, unsigned long *flags); |
157 | 157 | ||
@@ -176,7 +176,7 @@ static inline void unlock_timer(struct k_itimer *timr, unsigned long flags) | |||
176 | * the function pointer CALL in struct k_clock. | 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 | struct timespec *tp) | 180 | struct timespec *tp) |
181 | { | 181 | { |
182 | tp->tv_sec = 0; | 182 | tp->tv_sec = 0; |
@@ -184,13 +184,15 @@ static inline int common_clock_getres(clockid_t which_clock, | |||
184 | return 0; | 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 | getnstimeofday(tp); | 190 | getnstimeofday(tp); |
190 | return 0; | 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 | return do_sys_settimeofday(tp, NULL); | 197 | return do_sys_settimeofday(tp, NULL); |
196 | } | 198 | } |
@@ -207,7 +209,7 @@ static inline int common_timer_create(struct k_itimer *new_timer) | |||
207 | /* | 209 | /* |
208 | * These ones are defined below. | 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 | static void common_timer_get(struct k_itimer *, struct itimerspec *); | 213 | static void common_timer_get(struct k_itimer *, struct itimerspec *); |
212 | static int common_timer_set(struct k_itimer *, int, | 214 | static int common_timer_set(struct k_itimer *, int, |
213 | struct itimerspec *, struct itimerspec *); | 215 | struct itimerspec *, struct itimerspec *); |
@@ -216,7 +218,7 @@ static int common_timer_del(struct k_itimer *timer); | |||
216 | /* | 218 | /* |
217 | * Return nonzero iff we know a priori this clockid_t value is bogus. | 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 | if (which_clock < 0) /* CPU clock, posix_cpu_* will check it */ | 223 | if (which_clock < 0) /* CPU clock, posix_cpu_* will check it */ |
222 | return 0; | 224 | return 0; |
@@ -522,7 +524,7 @@ static inline struct task_struct * good_sigevent(sigevent_t * event) | |||
522 | return rtn; | 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 | if ((unsigned) clock_id >= MAX_CLOCKS) { | 529 | if ((unsigned) clock_id >= MAX_CLOCKS) { |
528 | printk("POSIX clock register failed for clock_id %d\n", | 530 | printk("POSIX clock register failed for clock_id %d\n", |
@@ -568,7 +570,7 @@ static void release_posix_timer(struct k_itimer *tmr, int it_id_set) | |||
568 | /* Create a POSIX.1b interval timer. */ | 570 | /* Create a POSIX.1b interval timer. */ |
569 | 571 | ||
570 | asmlinkage long | 572 | asmlinkage long |
571 | sys_timer_create(clockid_t which_clock, | 573 | sys_timer_create(const clockid_t which_clock, |
572 | struct sigevent __user *timer_event_spec, | 574 | struct sigevent __user *timer_event_spec, |
573 | timer_t __user * created_timer_id) | 575 | timer_t __user * created_timer_id) |
574 | { | 576 | { |
@@ -1195,7 +1197,8 @@ static u64 do_posix_clock_monotonic_gettime_parts( | |||
1195 | return jiff; | 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 | struct timespec wall_to_mono; | 1203 | struct timespec wall_to_mono; |
1201 | 1204 | ||
@@ -1212,7 +1215,7 @@ int do_posix_clock_monotonic_gettime(struct timespec *tp) | |||
1212 | return do_posix_clock_monotonic_get(CLOCK_MONOTONIC, tp); | 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 | return -EINVAL; | 1220 | return -EINVAL; |
1218 | } | 1221 | } |
@@ -1224,7 +1227,8 @@ int do_posix_clock_notimer_create(struct k_itimer *timer) | |||
1224 | } | 1227 | } |
1225 | EXPORT_SYMBOL_GPL(do_posix_clock_notimer_create); | 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 | #ifndef ENOTSUP | 1233 | #ifndef ENOTSUP |
1230 | return -EOPNOTSUPP; /* aka ENOTSUP in userland for POSIX */ | 1234 | return -EOPNOTSUPP; /* aka ENOTSUP in userland for POSIX */ |
@@ -1234,8 +1238,8 @@ int do_posix_clock_nonanosleep(clockid_t clock, int flags, struct timespec *t) | |||
1234 | } | 1238 | } |
1235 | EXPORT_SYMBOL_GPL(do_posix_clock_nonanosleep); | 1239 | EXPORT_SYMBOL_GPL(do_posix_clock_nonanosleep); |
1236 | 1240 | ||
1237 | asmlinkage long | 1241 | asmlinkage long sys_clock_settime(const clockid_t which_clock, |
1238 | sys_clock_settime(clockid_t which_clock, const struct timespec __user *tp) | 1242 | const struct timespec __user *tp) |
1239 | { | 1243 | { |
1240 | struct timespec new_tp; | 1244 | struct timespec new_tp; |
1241 | 1245 | ||
@@ -1248,7 +1252,7 @@ sys_clock_settime(clockid_t which_clock, const struct timespec __user *tp) | |||
1248 | } | 1252 | } |
1249 | 1253 | ||
1250 | asmlinkage long | 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 | struct timespec kernel_tp; | 1257 | struct timespec kernel_tp; |
1254 | int error; | 1258 | int error; |
@@ -1265,7 +1269,7 @@ sys_clock_gettime(clockid_t which_clock, struct timespec __user *tp) | |||
1265 | } | 1269 | } |
1266 | 1270 | ||
1267 | asmlinkage long | 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 | struct timespec rtn_tp; | 1274 | struct timespec rtn_tp; |
1271 | int error; | 1275 | int error; |
@@ -1387,7 +1391,7 @@ void clock_was_set(void) | |||
1387 | long clock_nanosleep_restart(struct restart_block *restart_block); | 1391 | long clock_nanosleep_restart(struct restart_block *restart_block); |
1388 | 1392 | ||
1389 | asmlinkage long | 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 | const struct timespec __user *rqtp, | 1395 | const struct timespec __user *rqtp, |
1392 | struct timespec __user *rmtp) | 1396 | struct timespec __user *rmtp) |
1393 | { | 1397 | { |
@@ -1419,7 +1423,7 @@ sys_clock_nanosleep(clockid_t which_clock, int flags, | |||
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 | int flags, struct timespec *tsave) | 1427 | int flags, struct timespec *tsave) |
1424 | { | 1428 | { |
1425 | struct timespec t, dum; | 1429 | struct timespec t, dum; |