summaryrefslogtreecommitdiffstats
path: root/kernel/time/posix-clock.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-07-03 19:14:51 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-07-03 19:14:51 -0400
commit1b044f1cfc65a7d90b209dfabd57e16d98b58c5b (patch)
treead657c911b563f9176b17578c0b88a1ea9916a02 /kernel/time/posix-clock.c
parente0f3e8f14da868047c524a0cf11e08b95fd1b008 (diff)
parent2287d8664fe7345ead891017eccd879fc605305e (diff)
Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer updates from Thomas Gleixner: "A rather large update for timers/timekeeping: - compat syscall consolidation (Al Viro) - Posix timer consolidation (Christoph Helwig / Thomas Gleixner) - Cleanup of the device tree based initialization for clockevents and clocksources (Daniel Lezcano) - Consolidation of the FTTMR010 clocksource/event driver (Linus Walleij) - The usual set of small fixes and updates all over the place" * 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (93 commits) timers: Make the cpu base lock raw clocksource/drivers/mips-gic-timer: Fix an error code in 'gic_clocksource_of_init()' clocksource/drivers/fsl_ftm_timer: Unmap region obtained by of_iomap clocksource/drivers/tcb_clksrc: Make IO endian agnostic clocksource/drivers/sun4i: Switch to the timer-of common init clocksource/drivers/timer-of: Fix invalid iomap check Revert "ktime: Simplify ktime_compare implementation" clocksource/drivers: Fix uninitialized variable use in timer_of_init kselftests: timers: Add test for frequency step kselftests: timers: Fix inconsistency-check to not ignore first timestamp time: Add warning about imminent deprecation of CONFIG_GENERIC_TIME_VSYSCALL_OLD time: Clean up CLOCK_MONOTONIC_RAW time handling posix-cpu-timers: Make timespec to nsec conversion safe itimer: Make timeval to nsec conversion range limited timers: Fix parameter description of try_to_del_timer_sync() ktime: Simplify ktime_compare implementation clocksource/drivers/fttmr010: Factor out clock read code clocksource/drivers/fttmr010: Implement delay timer clocksource/drivers: Add timer-of common init routine clocksource/drivers/tcb_clksrc: Save timer context on suspend/resume ...
Diffstat (limited to 'kernel/time/posix-clock.c')
-rw-r--r--kernel/time/posix-clock.c117
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
28static void delete_clock(struct kref *kref); 30static 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
85static 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
101static 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
117static long posix_clock_ioctl(struct file *fp, 87static 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
362static int pc_timer_create(struct k_itimer *kit) 330const 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
382static 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
402static 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
416static 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
437struct 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};