diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2011-02-01 08:51:48 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2011-02-02 09:28:14 -0500 |
commit | 26f9a4796af330173d790c8d2b5e2efcc489e755 (patch) | |
tree | a44b9dbfeedeb22d5f34ce49e4dd2b26cfbeaf97 | |
parent | 79c9da0d0539fb341a1b48a2a5a23d974726de90 (diff) |
posix-timers: Convert clock_settime to clockid_to_kclock()
Use the new kclock decoding function in clock_settime and cleanup all
kclocks which use the default functions. Rename the misnomed
common_clock_set() to posix_clock_realtime_set().
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: John Stultz <johnstul@us.ibm.com>
Tested-by: Richard Cochran <richard.cochran@omicron.at>
LKML-Reference: <20110201134418.518851246@linutronix.de>
-rw-r--r-- | include/linux/posix-timers.h | 3 | ||||
-rw-r--r-- | kernel/posix-cpu-timers.c | 2 | ||||
-rw-r--r-- | kernel/posix-timers.c | 31 |
3 files changed, 12 insertions, 24 deletions
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h index cd6da067bce1..4aaf0c5c7cea 100644 --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h | |||
@@ -89,9 +89,6 @@ extern struct k_clock clock_posix_cpu; | |||
89 | 89 | ||
90 | void register_posix_clock(const 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 | /* error handlers for timer_create, nanosleep and settime */ | ||
93 | int do_posix_clock_nosettime(const clockid_t, const struct timespec *tp); | ||
94 | |||
95 | /* function to call to trigger timer event */ | 92 | /* function to call to trigger timer event */ |
96 | int posix_timer_event(struct k_itimer *timr, int si_private); | 93 | int posix_timer_event(struct k_itimer *timr, int si_private); |
97 | 94 | ||
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c index 8dc4cd7faf89..504fbab10b82 100644 --- a/kernel/posix-cpu-timers.c +++ b/kernel/posix-cpu-timers.c | |||
@@ -1604,7 +1604,6 @@ static __init int init_posix_cpu_timers(void) | |||
1604 | struct k_clock process = { | 1604 | struct k_clock process = { |
1605 | .clock_getres = process_cpu_clock_getres, | 1605 | .clock_getres = process_cpu_clock_getres, |
1606 | .clock_get = process_cpu_clock_get, | 1606 | .clock_get = process_cpu_clock_get, |
1607 | .clock_set = do_posix_clock_nosettime, | ||
1608 | .timer_create = process_cpu_timer_create, | 1607 | .timer_create = process_cpu_timer_create, |
1609 | .nsleep = process_cpu_nsleep, | 1608 | .nsleep = process_cpu_nsleep, |
1610 | .nsleep_restart = process_cpu_nsleep_restart, | 1609 | .nsleep_restart = process_cpu_nsleep_restart, |
@@ -1612,7 +1611,6 @@ static __init int init_posix_cpu_timers(void) | |||
1612 | struct k_clock thread = { | 1611 | struct k_clock thread = { |
1613 | .clock_getres = thread_cpu_clock_getres, | 1612 | .clock_getres = thread_cpu_clock_getres, |
1614 | .clock_get = thread_cpu_clock_get, | 1613 | .clock_get = thread_cpu_clock_get, |
1615 | .clock_set = do_posix_clock_nosettime, | ||
1616 | .timer_create = thread_cpu_timer_create, | 1614 | .timer_create = thread_cpu_timer_create, |
1617 | }; | 1615 | }; |
1618 | struct timespec ts; | 1616 | struct timespec ts; |
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c index 4762986814c8..49f358c37708 100644 --- a/kernel/posix-timers.c +++ b/kernel/posix-timers.c | |||
@@ -199,12 +199,6 @@ static int common_clock_get(clockid_t which_clock, struct timespec *tp) | |||
199 | return 0; | 199 | return 0; |
200 | } | 200 | } |
201 | 201 | ||
202 | static inline int common_clock_set(const clockid_t which_clock, | ||
203 | const struct timespec *tp) | ||
204 | { | ||
205 | return do_sys_settimeofday(tp, NULL); | ||
206 | } | ||
207 | |||
208 | static int common_timer_create(struct k_itimer *new_timer) | 202 | static int common_timer_create(struct k_itimer *new_timer) |
209 | { | 203 | { |
210 | hrtimer_init(&new_timer->it.real.timer, new_timer->it_clock, 0); | 204 | hrtimer_init(&new_timer->it.real.timer, new_timer->it_clock, 0); |
@@ -232,6 +226,13 @@ static inline int invalid_clockid(const clockid_t which_clock) | |||
232 | return 1; | 226 | return 1; |
233 | } | 227 | } |
234 | 228 | ||
229 | /* Set clock_realtime */ | ||
230 | static int posix_clock_realtime_set(const clockid_t which_clock, | ||
231 | const struct timespec *tp) | ||
232 | { | ||
233 | return do_sys_settimeofday(tp, NULL); | ||
234 | } | ||
235 | |||
235 | /* | 236 | /* |
236 | * Get monotonic time for posix timers | 237 | * Get monotonic time for posix timers |
237 | */ | 238 | */ |
@@ -276,32 +277,29 @@ static __init int init_posix_timers(void) | |||
276 | { | 277 | { |
277 | struct k_clock clock_realtime = { | 278 | struct k_clock clock_realtime = { |
278 | .clock_getres = hrtimer_get_res, | 279 | .clock_getres = hrtimer_get_res, |
280 | .clock_set = posix_clock_realtime_set, | ||
279 | .nsleep = common_nsleep, | 281 | .nsleep = common_nsleep, |
280 | .nsleep_restart = hrtimer_nanosleep_restart, | 282 | .nsleep_restart = hrtimer_nanosleep_restart, |
281 | }; | 283 | }; |
282 | struct k_clock clock_monotonic = { | 284 | struct k_clock clock_monotonic = { |
283 | .clock_getres = hrtimer_get_res, | 285 | .clock_getres = hrtimer_get_res, |
284 | .clock_get = posix_ktime_get_ts, | 286 | .clock_get = posix_ktime_get_ts, |
285 | .clock_set = do_posix_clock_nosettime, | ||
286 | .nsleep = common_nsleep, | 287 | .nsleep = common_nsleep, |
287 | .nsleep_restart = hrtimer_nanosleep_restart, | 288 | .nsleep_restart = hrtimer_nanosleep_restart, |
288 | }; | 289 | }; |
289 | struct k_clock clock_monotonic_raw = { | 290 | struct k_clock clock_monotonic_raw = { |
290 | .clock_getres = hrtimer_get_res, | 291 | .clock_getres = hrtimer_get_res, |
291 | .clock_get = posix_get_monotonic_raw, | 292 | .clock_get = posix_get_monotonic_raw, |
292 | .clock_set = do_posix_clock_nosettime, | ||
293 | .timer_create = no_timer_create, | 293 | .timer_create = no_timer_create, |
294 | }; | 294 | }; |
295 | struct k_clock clock_realtime_coarse = { | 295 | struct k_clock clock_realtime_coarse = { |
296 | .clock_getres = posix_get_coarse_res, | 296 | .clock_getres = posix_get_coarse_res, |
297 | .clock_get = posix_get_realtime_coarse, | 297 | .clock_get = posix_get_realtime_coarse, |
298 | .clock_set = do_posix_clock_nosettime, | ||
299 | .timer_create = no_timer_create, | 298 | .timer_create = no_timer_create, |
300 | }; | 299 | }; |
301 | struct k_clock clock_monotonic_coarse = { | 300 | struct k_clock clock_monotonic_coarse = { |
302 | .clock_getres = posix_get_coarse_res, | 301 | .clock_getres = posix_get_coarse_res, |
303 | .clock_get = posix_get_monotonic_coarse, | 302 | .clock_get = posix_get_monotonic_coarse, |
304 | .clock_set = do_posix_clock_nosettime, | ||
305 | .timer_create = no_timer_create, | 303 | .timer_create = no_timer_create, |
306 | }; | 304 | }; |
307 | 305 | ||
@@ -940,24 +938,19 @@ void exit_itimers(struct signal_struct *sig) | |||
940 | } | 938 | } |
941 | } | 939 | } |
942 | 940 | ||
943 | /* Not available / possible... functions */ | ||
944 | int do_posix_clock_nosettime(const clockid_t clockid, const struct timespec *tp) | ||
945 | { | ||
946 | return -EINVAL; | ||
947 | } | ||
948 | EXPORT_SYMBOL_GPL(do_posix_clock_nosettime); | ||
949 | |||
950 | SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock, | 941 | SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock, |
951 | const struct timespec __user *, tp) | 942 | const struct timespec __user *, tp) |
952 | { | 943 | { |
944 | struct k_clock *kc = clockid_to_kclock(which_clock); | ||
953 | struct timespec new_tp; | 945 | struct timespec new_tp; |
954 | 946 | ||
955 | if (invalid_clockid(which_clock)) | 947 | if (!kc || !kc->clock_set) |
956 | return -EINVAL; | 948 | return -EINVAL; |
949 | |||
957 | if (copy_from_user(&new_tp, tp, sizeof (*tp))) | 950 | if (copy_from_user(&new_tp, tp, sizeof (*tp))) |
958 | return -EFAULT; | 951 | return -EFAULT; |
959 | 952 | ||
960 | return CLOCK_DISPATCH(which_clock, clock_set, (which_clock, &new_tp)); | 953 | return kc->clock_set(which_clock, &new_tp); |
961 | } | 954 | } |
962 | 955 | ||
963 | SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock, | 956 | SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock, |