20 #include <linux/device.h>
21 #include <linux/export.h>
24 #include <linux/slab.h>
28 static void delete_clock(
struct kref *
kref);
47 static void put_posix_clock(
struct posix_clock *clk)
53 size_t count, loff_t *ppos)
62 err = clk->
ops.read(clk, fp->
f_flags, buf, count);
78 result = clk->
ops.poll(clk, fp, wait);
85 static int posix_clock_fasync(
int fd,
struct file *fp,
int on)
94 err = clk->
ops.fasync(clk, fd, fp, on);
110 err = clk->
ops.mmap(clk, vma);
112 put_posix_clock(clk);
117 static long posix_clock_ioctl(
struct file *fp,
118 unsigned int cmd,
unsigned long arg)
127 err = clk->
ops.ioctl(clk, cmd, arg);
129 put_posix_clock(clk);
135 static long posix_clock_compat_ioctl(
struct file *fp,
136 unsigned int cmd,
unsigned long arg)
145 err = clk->
ops.ioctl(clk, cmd, arg);
147 put_posix_clock(clk);
171 kref_get(&clk->
kref);
179 static int posix_clock_release(
struct inode *inode,
struct file *fp)
184 if (clk->
ops.release)
185 err = clk->
ops.release(clk);
187 kref_put(&clk->
kref, delete_clock);
197 .read = posix_clock_read,
198 .poll = posix_clock_poll,
199 .unlocked_ioctl = posix_clock_ioctl,
200 .open = posix_clock_open,
201 .release = posix_clock_release,
202 .fasync = posix_clock_fasync,
203 .mmap = posix_clock_mmap,
205 .compat_ioctl = posix_clock_compat_ioctl,
213 kref_init(&clk->
kref);
217 clk->
cdev.owner = clk->
ops.owner;
224 static void delete_clock(
struct kref *
kref)
240 kref_put(&clk->
kref, delete_clock);
261 cd->
clk = get_posix_clock(fp);
272 put_posix_clock(cd->
clk);
281 err = get_clock_desc(
id, &
cd);
290 if (
cd.clk->ops.clock_adjtime)
291 err =
cd.clk->ops.clock_adjtime(
cd.clk, tx);
305 err = get_clock_desc(
id, &
cd);
309 if (
cd.clk->ops.clock_gettime)
310 err =
cd.clk->ops.clock_gettime(
cd.clk, ts);
324 err = get_clock_desc(
id, &
cd);
328 if (
cd.clk->ops.clock_getres)
329 err =
cd.clk->ops.clock_getres(
cd.clk, ts);
343 err = get_clock_desc(
id, &
cd);
352 if (
cd.clk->ops.clock_settime)
353 err =
cd.clk->ops.clock_settime(
cd.clk, ts);
362 static int pc_timer_create(
struct k_itimer *kit)
368 err = get_clock_desc(
id, &
cd);
372 if (
cd.clk->ops.timer_create)
373 err =
cd.clk->ops.timer_create(
cd.clk, kit);
382 static int pc_timer_delete(
struct k_itimer *kit)
388 err = get_clock_desc(
id, &
cd);
392 if (
cd.clk->ops.timer_delete)
393 err =
cd.clk->ops.timer_delete(
cd.clk, kit);
407 if (get_clock_desc(
id, &
cd))
410 if (
cd.clk->ops.timer_gettime)
411 cd.clk->ops.timer_gettime(
cd.clk, kit, ts);
423 err = get_clock_desc(
id, &
cd);
427 if (
cd.clk->ops.timer_settime)
428 err =
cd.clk->ops.timer_settime(
cd.clk, kit, flags, ts, old);
438 .clock_getres = pc_clock_getres,
439 .clock_set = pc_clock_settime,
440 .clock_get = pc_clock_gettime,
441 .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,