diff options
Diffstat (limited to 'kernel/time/posix-clock.c')
-rw-r--r-- | kernel/time/posix-clock.c | 117 |
1 files changed, 3 insertions, 114 deletions
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c index 31d588d37a17..17cdc554c9fe 100644 --- a/kernel/time/posix-clock.c +++ b/kernel/time/posix-clock.c | |||
@@ -25,6 +25,8 @@ | |||
25 | #include <linux/syscalls.h> | 25 | #include <linux/syscalls.h> |
26 | #include <linux/uaccess.h> | 26 | #include <linux/uaccess.h> |
27 | 27 | ||
28 | #include "posix-timers.h" | ||
29 | |||
28 | static void delete_clock(struct kref *kref); | 30 | static void delete_clock(struct kref *kref); |
29 | 31 | ||
30 | /* | 32 | /* |
@@ -82,38 +84,6 @@ static unsigned int posix_clock_poll(struct file *fp, poll_table *wait) | |||
82 | return result; | 84 | return result; |
83 | } | 85 | } |
84 | 86 | ||
85 | static int posix_clock_fasync(int fd, struct file *fp, int on) | ||
86 | { | ||
87 | struct posix_clock *clk = get_posix_clock(fp); | ||
88 | int err = 0; | ||
89 | |||
90 | if (!clk) | ||
91 | return -ENODEV; | ||
92 | |||
93 | if (clk->ops.fasync) | ||
94 | err = clk->ops.fasync(clk, fd, fp, on); | ||
95 | |||
96 | put_posix_clock(clk); | ||
97 | |||
98 | return err; | ||
99 | } | ||
100 | |||
101 | static int posix_clock_mmap(struct file *fp, struct vm_area_struct *vma) | ||
102 | { | ||
103 | struct posix_clock *clk = get_posix_clock(fp); | ||
104 | int err = -ENODEV; | ||
105 | |||
106 | if (!clk) | ||
107 | return -ENODEV; | ||
108 | |||
109 | if (clk->ops.mmap) | ||
110 | err = clk->ops.mmap(clk, vma); | ||
111 | |||
112 | put_posix_clock(clk); | ||
113 | |||
114 | return err; | ||
115 | } | ||
116 | |||
117 | static long posix_clock_ioctl(struct file *fp, | 87 | static long posix_clock_ioctl(struct file *fp, |
118 | unsigned int cmd, unsigned long arg) | 88 | unsigned int cmd, unsigned long arg) |
119 | { | 89 | { |
@@ -199,8 +169,6 @@ static const struct file_operations posix_clock_file_operations = { | |||
199 | .unlocked_ioctl = posix_clock_ioctl, | 169 | .unlocked_ioctl = posix_clock_ioctl, |
200 | .open = posix_clock_open, | 170 | .open = posix_clock_open, |
201 | .release = posix_clock_release, | 171 | .release = posix_clock_release, |
202 | .fasync = posix_clock_fasync, | ||
203 | .mmap = posix_clock_mmap, | ||
204 | #ifdef CONFIG_COMPAT | 172 | #ifdef CONFIG_COMPAT |
205 | .compat_ioctl = posix_clock_compat_ioctl, | 173 | .compat_ioctl = posix_clock_compat_ioctl, |
206 | #endif | 174 | #endif |
@@ -359,88 +327,9 @@ out: | |||
359 | return err; | 327 | return err; |
360 | } | 328 | } |
361 | 329 | ||
362 | static int pc_timer_create(struct k_itimer *kit) | 330 | const struct k_clock clock_posix_dynamic = { |
363 | { | ||
364 | clockid_t id = kit->it_clock; | ||
365 | struct posix_clock_desc cd; | ||
366 | int err; | ||
367 | |||
368 | err = get_clock_desc(id, &cd); | ||
369 | if (err) | ||
370 | return err; | ||
371 | |||
372 | if (cd.clk->ops.timer_create) | ||
373 | err = cd.clk->ops.timer_create(cd.clk, kit); | ||
374 | else | ||
375 | err = -EOPNOTSUPP; | ||
376 | |||
377 | put_clock_desc(&cd); | ||
378 | |||
379 | return err; | ||
380 | } | ||
381 | |||
382 | static int pc_timer_delete(struct k_itimer *kit) | ||
383 | { | ||
384 | clockid_t id = kit->it_clock; | ||
385 | struct posix_clock_desc cd; | ||
386 | int err; | ||
387 | |||
388 | err = get_clock_desc(id, &cd); | ||
389 | if (err) | ||
390 | return err; | ||
391 | |||
392 | if (cd.clk->ops.timer_delete) | ||
393 | err = cd.clk->ops.timer_delete(cd.clk, kit); | ||
394 | else | ||
395 | err = -EOPNOTSUPP; | ||
396 | |||
397 | put_clock_desc(&cd); | ||
398 | |||
399 | return err; | ||
400 | } | ||
401 | |||
402 | static void pc_timer_gettime(struct k_itimer *kit, struct itimerspec64 *ts) | ||
403 | { | ||
404 | clockid_t id = kit->it_clock; | ||
405 | struct posix_clock_desc cd; | ||
406 | |||
407 | if (get_clock_desc(id, &cd)) | ||
408 | return; | ||
409 | |||
410 | if (cd.clk->ops.timer_gettime) | ||
411 | cd.clk->ops.timer_gettime(cd.clk, kit, ts); | ||
412 | |||
413 | put_clock_desc(&cd); | ||
414 | } | ||
415 | |||
416 | static int pc_timer_settime(struct k_itimer *kit, int flags, | ||
417 | struct itimerspec64 *ts, struct itimerspec64 *old) | ||
418 | { | ||
419 | clockid_t id = kit->it_clock; | ||
420 | struct posix_clock_desc cd; | ||
421 | int err; | ||
422 | |||
423 | err = get_clock_desc(id, &cd); | ||
424 | if (err) | ||
425 | return err; | ||
426 | |||
427 | if (cd.clk->ops.timer_settime) | ||
428 | err = cd.clk->ops.timer_settime(cd.clk, kit, flags, ts, old); | ||
429 | else | ||
430 | err = -EOPNOTSUPP; | ||
431 | |||
432 | put_clock_desc(&cd); | ||
433 | |||
434 | return err; | ||
435 | } | ||
436 | |||
437 | struct k_clock clock_posix_dynamic = { | ||
438 | .clock_getres = pc_clock_getres, | 331 | .clock_getres = pc_clock_getres, |
439 | .clock_set = pc_clock_settime, | 332 | .clock_set = pc_clock_settime, |
440 | .clock_get = pc_clock_gettime, | 333 | .clock_get = pc_clock_gettime, |
441 | .clock_adj = pc_clock_adjtime, | 334 | .clock_adj = pc_clock_adjtime, |
442 | .timer_create = pc_timer_create, | ||
443 | .timer_set = pc_timer_settime, | ||
444 | .timer_del = pc_timer_delete, | ||
445 | .timer_get = pc_timer_gettime, | ||
446 | }; | 335 | }; |