Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

posix-clocks: Remove interval timer facility and mmap/fasync callbacks

The only user of this facility is ptp_clock, which does not implement any of
those functions.

Remove them to prevent accidental users. Especially the interval timer
interfaces are now more or less impossible to implement because the
necessary infrastructure has been confined to the core code. Aside of that
it's really complex to make these callbacks implemented according to spec
as the alarm timer implementation demonstrates. If at all then a nanosleep
callback might be a reasonable extension. For now keep just what ptp_clock
needs.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/20170530211656.145036286@linutronix.de

-135
-22
include/linux/posix-clock.h
··· 42 42 * @clock_gettime: Read the current time 43 43 * @clock_getres: Get the clock resolution 44 44 * @clock_settime: Set the current time value 45 - * @timer_create: Create a new timer 46 - * @timer_delete: Remove a previously created timer 47 - * @timer_gettime: Get remaining time and interval of a timer 48 - * @timer_settime: Set a timer's initial expiration and interval 49 - * @fasync: Optional character device fasync method 50 - * @mmap: Optional character device mmap method 51 45 * @open: Optional character device open method 52 46 * @release: Optional character device release method 53 47 * @ioctl: Optional character device ioctl method ··· 60 66 int (*clock_settime)(struct posix_clock *pc, 61 67 const struct timespec64 *ts); 62 68 63 - int (*timer_create) (struct posix_clock *pc, struct k_itimer *kit); 64 - 65 - int (*timer_delete) (struct posix_clock *pc, struct k_itimer *kit); 66 - 67 - void (*timer_gettime)(struct posix_clock *pc, 68 - struct k_itimer *kit, struct itimerspec64 *tsp); 69 - 70 - int (*timer_settime)(struct posix_clock *pc, 71 - struct k_itimer *kit, int flags, 72 - struct itimerspec64 *tsp, struct itimerspec64 *old); 73 69 /* 74 70 * Optional character device methods: 75 71 */ 76 - int (*fasync) (struct posix_clock *pc, 77 - int fd, struct file *file, int on); 78 - 79 72 long (*ioctl) (struct posix_clock *pc, 80 73 unsigned int cmd, unsigned long arg); 81 - 82 - int (*mmap) (struct posix_clock *pc, 83 - struct vm_area_struct *vma); 84 74 85 75 int (*open) (struct posix_clock *pc, fmode_t f_mode); 86 76
-113
kernel/time/posix-clock.c
··· 82 82 return result; 83 83 } 84 84 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 85 static long posix_clock_ioctl(struct file *fp, 118 86 unsigned int cmd, unsigned long arg) 119 87 { ··· 167 199 .unlocked_ioctl = posix_clock_ioctl, 168 200 .open = posix_clock_open, 169 201 .release = posix_clock_release, 170 - .fasync = posix_clock_fasync, 171 - .mmap = posix_clock_mmap, 172 202 #ifdef CONFIG_COMPAT 173 203 .compat_ioctl = posix_clock_compat_ioctl, 174 204 #endif ··· 325 359 return err; 326 360 } 327 361 328 - static int pc_timer_create(struct k_itimer *kit) 329 - { 330 - clockid_t id = kit->it_clock; 331 - struct posix_clock_desc cd; 332 - int err; 333 - 334 - err = get_clock_desc(id, &cd); 335 - if (err) 336 - return err; 337 - 338 - if (cd.clk->ops.timer_create) 339 - err = cd.clk->ops.timer_create(cd.clk, kit); 340 - else 341 - err = -EOPNOTSUPP; 342 - 343 - put_clock_desc(&cd); 344 - 345 - return err; 346 - } 347 - 348 - static int pc_timer_delete(struct k_itimer *kit) 349 - { 350 - clockid_t id = kit->it_clock; 351 - struct posix_clock_desc cd; 352 - int err; 353 - 354 - err = get_clock_desc(id, &cd); 355 - if (err) 356 - return err; 357 - 358 - if (cd.clk->ops.timer_delete) 359 - err = cd.clk->ops.timer_delete(cd.clk, kit); 360 - else 361 - err = -EOPNOTSUPP; 362 - 363 - put_clock_desc(&cd); 364 - 365 - return err; 366 - } 367 - 368 - static void pc_timer_gettime(struct k_itimer *kit, struct itimerspec64 *ts) 369 - { 370 - clockid_t id = kit->it_clock; 371 - struct posix_clock_desc cd; 372 - 373 - if (get_clock_desc(id, &cd)) 374 - return; 375 - 376 - if (cd.clk->ops.timer_gettime) 377 - cd.clk->ops.timer_gettime(cd.clk, kit, ts); 378 - 379 - put_clock_desc(&cd); 380 - } 381 - 382 - static int pc_timer_settime(struct k_itimer *kit, int flags, 383 - struct itimerspec64 *ts, struct itimerspec64 *old) 384 - { 385 - clockid_t id = kit->it_clock; 386 - struct posix_clock_desc cd; 387 - int err; 388 - 389 - err = get_clock_desc(id, &cd); 390 - if (err) 391 - return err; 392 - 393 - if (cd.clk->ops.timer_settime) 394 - err = cd.clk->ops.timer_settime(cd.clk, kit, flags, ts, old); 395 - else 396 - err = -EOPNOTSUPP; 397 - 398 - put_clock_desc(&cd); 399 - 400 - return err; 401 - } 402 - 403 362 const struct k_clock clock_posix_dynamic = { 404 363 .clock_getres = pc_clock_getres, 405 364 .clock_set = pc_clock_settime, 406 365 .clock_get = pc_clock_gettime, 407 366 .clock_adj = pc_clock_adjtime, 408 - .timer_create = pc_timer_create, 409 - .timer_set = pc_timer_settime, 410 - .timer_del = pc_timer_delete, 411 - .timer_get = pc_timer_gettime, 412 367 };