blob: 2c423c3884be516ecc3913e94bb4bae1da4be760 [file] [log] [blame]
Nicholas Flintham1e3d3112013-04-10 10:48:38 +01001/*
2 * posix-clock.h - support for dynamic clock devices
3 *
4 * Copyright (C) 2010 OMICRON electronics GmbH
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20#ifndef _LINUX_POSIX_CLOCK_H_
21#define _LINUX_POSIX_CLOCK_H_
22
23#include <linux/cdev.h>
24#include <linux/fs.h>
25#include <linux/poll.h>
26#include <linux/posix-timers.h>
27#include <linux/rwsem.h>
28
29struct posix_clock;
30
31struct posix_clock_operations {
32 struct module *owner;
33
34 int (*clock_adjtime)(struct posix_clock *pc, struct timex *tx);
35
36 int (*clock_gettime)(struct posix_clock *pc, struct timespec *ts);
37
38 int (*clock_getres) (struct posix_clock *pc, struct timespec *ts);
39
40 int (*clock_settime)(struct posix_clock *pc,
41 const struct timespec *ts);
42
43 int (*timer_create) (struct posix_clock *pc, struct k_itimer *kit);
44
45 int (*timer_delete) (struct posix_clock *pc, struct k_itimer *kit);
46
47 void (*timer_gettime)(struct posix_clock *pc,
48 struct k_itimer *kit, struct itimerspec *tsp);
49
50 int (*timer_settime)(struct posix_clock *pc,
51 struct k_itimer *kit, int flags,
52 struct itimerspec *tsp, struct itimerspec *old);
53 int (*fasync) (struct posix_clock *pc,
54 int fd, struct file *file, int on);
55
56 long (*ioctl) (struct posix_clock *pc,
57 unsigned int cmd, unsigned long arg);
58
59 int (*mmap) (struct posix_clock *pc,
60 struct vm_area_struct *vma);
61
62 int (*open) (struct posix_clock *pc, fmode_t f_mode);
63
64 uint (*poll) (struct posix_clock *pc,
65 struct file *file, poll_table *wait);
66
67 int (*release) (struct posix_clock *pc);
68
69 ssize_t (*read) (struct posix_clock *pc,
70 uint flags, char __user *buf, size_t cnt);
71};
72
73struct posix_clock {
74 struct posix_clock_operations ops;
75 struct cdev cdev;
76 struct kref kref;
77 struct rw_semaphore rwsem;
78 bool zombie;
79 void (*release)(struct posix_clock *clk);
80};
81
82int posix_clock_register(struct posix_clock *clk, dev_t devid);
83
84void posix_clock_unregister(struct posix_clock *clk);
85
86#endif