aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2006-01-09 23:52:27 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-10 11:01:36 -0500
commita924b04ddea9788e09f387fe19ccbede5f09ddd8 (patch)
treeaa519a2427b7686d35ceae764d3e37d69a6ae5e8
parent57a558757bdbb877b54ed5ea15bd0892e02a707d (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>
-rw-r--r--include/linux/posix-timers.h22
-rw-r--r--kernel/posix-cpu-timers.c40
-rw-r--r--kernel/posix-timers.c38
3 files changed, 54 insertions, 46 deletions
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index f942e2bad8e3..ecda38e07899 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -72,12 +72,12 @@ struct k_clock_abs {
72}; 72};
73struct k_clock { 73struct k_clock {
74 int res; /* in nano seconds */ 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 struct k_clock_abs *abs_struct; 76 struct k_clock_abs *abs_struct;
77 int (*clock_set) (clockid_t which_clock, struct timespec * tp); 77 int (*clock_set) (const clockid_t which_clock, struct timespec * tp);
78 int (*clock_get) (clockid_t which_clock, struct timespec * tp); 78 int (*clock_get) (const clockid_t which_clock, struct timespec * tp);
79 int (*timer_create) (struct k_itimer *timer); 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 int (*timer_set) (struct k_itimer * timr, int flags, 81 int (*timer_set) (struct k_itimer * timr, int flags,
82 struct itimerspec * new_setting, 82 struct itimerspec * new_setting,
83 struct itimerspec * old_setting); 83 struct itimerspec * old_setting);
@@ -87,12 +87,12 @@ struct k_clock {
87 struct itimerspec * cur_setting); 87 struct itimerspec * cur_setting);
88}; 88};
89 89
90void register_posix_clock(clockid_t clock_id, struct k_clock *new_clock); 90void register_posix_clock(const clockid_t clock_id, struct k_clock *new_clock);
91 91
92/* Error handlers for timer_create, nanosleep and settime */ 92/* Error handlers for timer_create, nanosleep and settime */
93int do_posix_clock_notimer_create(struct k_itimer *timer); 93int do_posix_clock_notimer_create(struct k_itimer *timer);
94int do_posix_clock_nonanosleep(clockid_t, int flags, struct timespec *); 94int do_posix_clock_nonanosleep(const clockid_t, int flags, struct timespec *);
95int do_posix_clock_nosettime(clockid_t, struct timespec *tp); 95int do_posix_clock_nosettime(const clockid_t, struct timespec *tp);
96 96
97/* function to call to trigger timer event */ 97/* function to call to trigger timer event */
98int posix_timer_event(struct k_itimer *timr, int si_private); 98int posix_timer_event(struct k_itimer *timr, int si_private);
@@ -117,11 +117,11 @@ struct now_struct {
117 } \ 117 } \
118 }while (0) 118 }while (0)
119 119
120int posix_cpu_clock_getres(clockid_t which_clock, struct timespec *); 120int posix_cpu_clock_getres(const clockid_t which_clock, struct timespec *);
121int posix_cpu_clock_get(clockid_t which_clock, struct timespec *); 121int posix_cpu_clock_get(const clockid_t which_clock, struct timespec *);
122int posix_cpu_clock_set(clockid_t which_clock, const struct timespec *tp); 122int posix_cpu_clock_set(const clockid_t which_clock, const struct timespec *tp);
123int posix_cpu_timer_create(struct k_itimer *); 123int posix_cpu_timer_create(struct k_itimer *);
124int posix_cpu_nsleep(clockid_t, int, struct timespec *); 124int posix_cpu_nsleep(const clockid_t, int, struct timespec *);
125int posix_cpu_timer_set(struct k_itimer *, int, 125int posix_cpu_timer_set(struct k_itimer *, int,
126 struct itimerspec *, struct itimerspec *); 126 struct itimerspec *, struct itimerspec *);
127int posix_cpu_timer_del(struct k_itimer *); 127int posix_cpu_timer_del(struct k_itimer *);
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
10static int check_clock(clockid_t which_clock) 10static 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
33static inline union cpu_time_count 33static inline union cpu_time_count
34timespec_to_sample(clockid_t which_clock, const struct timespec *tp) 34timespec_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
46static void sample_to_timespec(clockid_t which_clock, 46static 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
58static inline int cpu_time_before(clockid_t which_clock, 58static 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}
68static inline void cpu_time_add(clockid_t which_clock, 68static 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}
78static inline union cpu_time_count cpu_time_sub(clockid_t which_clock, 78static 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
154int posix_cpu_clock_getres(clockid_t which_clock, struct timespec *tp) 154int 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
172int posix_cpu_clock_set(clockid_t which_clock, const struct timespec *tp) 172int 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 */
189static int cpu_clock_sample(clockid_t which_clock, struct task_struct *p, 189static 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 */
251static int cpu_clock_sample_group(clockid_t which_clock, 251static 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
265int posix_cpu_clock_get(clockid_t which_clock, struct timespec *tp) 265int 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
1400static long posix_cpu_clock_nanosleep_restart(struct restart_block *); 1400static long posix_cpu_clock_nanosleep_restart(struct restart_block *);
1401 1401
1402int posix_cpu_nsleep(clockid_t which_clock, int flags, 1402int 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
1506static int process_cpu_clock_getres(clockid_t which_clock, struct timespec *tp) 1506static 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}
1510static int process_cpu_clock_get(clockid_t which_clock, struct timespec *tp) 1511static 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}
1519static int process_cpu_nsleep(clockid_t which_clock, int flags, 1521static 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}
1524static int thread_cpu_clock_getres(clockid_t which_clock, struct timespec *tp) 1526static 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}
1528static int thread_cpu_clock_get(clockid_t which_clock, struct timespec *tp) 1531static 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}
1537static int thread_cpu_nsleep(clockid_t which_clock, int flags, 1541static 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);
151static u64 do_posix_clock_monotonic_gettime_parts( 151static u64 do_posix_clock_monotonic_gettime_parts(
152 struct timespec *tp, struct timespec *mo); 152 struct timespec *tp, struct timespec *mo);
153int do_posix_clock_monotonic_gettime(struct timespec *tp); 153int do_posix_clock_monotonic_gettime(struct timespec *tp);
154static int do_posix_clock_monotonic_get(clockid_t, struct timespec *tp); 154static int do_posix_clock_monotonic_get(const clockid_t, struct timespec *tp);
155 155
156static struct k_itimer *lock_timer(timer_t timer_id, unsigned long *flags); 156static 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
179static inline int common_clock_getres(clockid_t which_clock, 179static 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
187static inline int common_clock_get(clockid_t which_clock, struct timespec *tp) 187static 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
193static inline int common_clock_set(clockid_t which_clock, struct timespec *tp) 194static 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 */
210static int common_nsleep(clockid_t, int flags, struct timespec *t); 212static int common_nsleep(const clockid_t, int flags, struct timespec *t);
211static void common_timer_get(struct k_itimer *, struct itimerspec *); 213static void common_timer_get(struct k_itimer *, struct itimerspec *);
212static int common_timer_set(struct k_itimer *, int, 214static 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 */
219static inline int invalid_clockid(clockid_t which_clock) 221static 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
525void register_posix_clock(clockid_t clock_id, struct k_clock *new_clock) 527void 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
570asmlinkage long 572asmlinkage long
571sys_timer_create(clockid_t which_clock, 573sys_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
1198static int do_posix_clock_monotonic_get(clockid_t clock, struct timespec *tp) 1200static 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
1215int do_posix_clock_nosettime(clockid_t clockid, struct timespec *tp) 1218int 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}
1225EXPORT_SYMBOL_GPL(do_posix_clock_notimer_create); 1228EXPORT_SYMBOL_GPL(do_posix_clock_notimer_create);
1226 1229
1227int do_posix_clock_nonanosleep(clockid_t clock, int flags, struct timespec *t) 1230int 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}
1235EXPORT_SYMBOL_GPL(do_posix_clock_nonanosleep); 1239EXPORT_SYMBOL_GPL(do_posix_clock_nonanosleep);
1236 1240
1237asmlinkage long 1241asmlinkage long sys_clock_settime(const clockid_t which_clock,
1238sys_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
1250asmlinkage long 1254asmlinkage long
1251sys_clock_gettime(clockid_t which_clock, struct timespec __user *tp) 1255sys_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
1267asmlinkage long 1271asmlinkage long
1268sys_clock_getres(clockid_t which_clock, struct timespec __user *tp) 1272sys_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)
1387long clock_nanosleep_restart(struct restart_block *restart_block); 1391long clock_nanosleep_restart(struct restart_block *restart_block);
1388 1392
1389asmlinkage long 1393asmlinkage long
1390sys_clock_nanosleep(clockid_t which_clock, int flags, 1394sys_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
1422static int common_nsleep(clockid_t which_clock, 1426static 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;