Lines Matching +full:ts +full:- +full:attached
1 // SPDX-License-Identifier: GPL-2.0+
10 #include <linux/posix-clock.h>
15 #include "posix-timers.h"
18 * Returns NULL if the posix_clock instance attached to 'fp' is old and stale.
22 struct posix_clock_context *pccontext = fp->private_data; in get_posix_clock()
23 struct posix_clock *clk = pccontext->clk; in get_posix_clock()
25 down_read(&clk->rwsem); in get_posix_clock()
27 if (!clk->zombie) in get_posix_clock()
30 up_read(&clk->rwsem); in get_posix_clock()
37 up_read(&clk->rwsem); in put_posix_clock()
43 struct posix_clock_context *pccontext = fp->private_data; in posix_clock_read()
45 int err = -EINVAL; in posix_clock_read()
48 return -ENODEV; in posix_clock_read()
50 if (clk->ops.read) in posix_clock_read()
51 err = clk->ops.read(pccontext, fp->f_flags, buf, count); in posix_clock_read()
60 struct posix_clock_context *pccontext = fp->private_data; in posix_clock_poll()
67 if (clk->ops.poll) in posix_clock_poll()
68 result = clk->ops.poll(pccontext, fp, wait); in posix_clock_poll()
78 struct posix_clock_context *pccontext = fp->private_data; in posix_clock_ioctl()
80 int err = -ENOTTY; in posix_clock_ioctl()
83 return -ENODEV; in posix_clock_ioctl()
85 if (clk->ops.ioctl) in posix_clock_ioctl()
86 err = clk->ops.ioctl(pccontext, cmd, arg); in posix_clock_ioctl()
97 struct posix_clock_context *pccontext = fp->private_data; in posix_clock_compat_ioctl()
99 int err = -ENOTTY; in posix_clock_compat_ioctl()
102 return -ENODEV; in posix_clock_compat_ioctl()
104 if (clk->ops.ioctl) in posix_clock_compat_ioctl()
105 err = clk->ops.ioctl(pccontext, cmd, arg); in posix_clock_compat_ioctl()
117 container_of(inode->i_cdev, struct posix_clock, cdev); in posix_clock_open()
120 down_read(&clk->rwsem); in posix_clock_open()
122 if (clk->zombie) { in posix_clock_open()
123 err = -ENODEV; in posix_clock_open()
128 err = -ENOMEM; in posix_clock_open()
131 pccontext->clk = clk; in posix_clock_open()
132 if (clk->ops.open) { in posix_clock_open()
133 err = clk->ops.open(pccontext, fp->f_mode); in posix_clock_open()
140 fp->private_data = pccontext; in posix_clock_open()
141 get_device(clk->dev); in posix_clock_open()
144 up_read(&clk->rwsem); in posix_clock_open()
150 struct posix_clock_context *pccontext = fp->private_data; in posix_clock_release()
155 return -ENODEV; in posix_clock_release()
156 clk = pccontext->clk; in posix_clock_release()
158 if (clk->ops.release) in posix_clock_release()
159 err = clk->ops.release(pccontext); in posix_clock_release()
161 put_device(clk->dev); in posix_clock_release()
164 fp->private_data = NULL; in posix_clock_release()
185 init_rwsem(&clk->rwsem); in posix_clock_register()
187 cdev_init(&clk->cdev, &posix_clock_file_operations); in posix_clock_register()
188 err = cdev_device_add(&clk->cdev, dev); in posix_clock_register()
191 dev_name(dev), MAJOR(dev->devt), MINOR(dev->devt)); in posix_clock_register()
194 clk->cdev.owner = clk->ops.owner; in posix_clock_register()
195 clk->dev = dev; in posix_clock_register()
203 cdev_device_del(&clk->cdev, clk->dev); in posix_clock_unregister()
205 down_write(&clk->rwsem); in posix_clock_unregister()
206 clk->zombie = true; in posix_clock_unregister()
207 up_write(&clk->rwsem); in posix_clock_unregister()
209 put_device(clk->dev); in posix_clock_unregister()
221 int err = -EINVAL; in get_clock_desc()
226 if (fp->f_op->open != posix_clock_open || !fp->private_data) in get_clock_desc()
229 cd->fp = fp; in get_clock_desc()
230 cd->clk = get_posix_clock(fp); in get_clock_desc()
232 err = cd->clk ? 0 : -ENODEV; in get_clock_desc()
241 put_posix_clock(cd->clk); in put_clock_desc()
242 fput(cd->fp); in put_clock_desc()
254 if ((cd.fp->f_mode & FMODE_WRITE) == 0) { in pc_clock_adjtime()
255 err = -EACCES; in pc_clock_adjtime()
259 if (cd.clk->ops.clock_adjtime) in pc_clock_adjtime()
260 err = cd.clk->ops.clock_adjtime(cd.clk, tx); in pc_clock_adjtime()
262 err = -EOPNOTSUPP; in pc_clock_adjtime()
269 static int pc_clock_gettime(clockid_t id, struct timespec64 *ts) in pc_clock_gettime() argument
278 if (cd.clk->ops.clock_gettime) in pc_clock_gettime()
279 err = cd.clk->ops.clock_gettime(cd.clk, ts); in pc_clock_gettime()
281 err = -EOPNOTSUPP; in pc_clock_gettime()
288 static int pc_clock_getres(clockid_t id, struct timespec64 *ts) in pc_clock_getres() argument
297 if (cd.clk->ops.clock_getres) in pc_clock_getres()
298 err = cd.clk->ops.clock_getres(cd.clk, ts); in pc_clock_getres()
300 err = -EOPNOTSUPP; in pc_clock_getres()
307 static int pc_clock_settime(clockid_t id, const struct timespec64 *ts) in pc_clock_settime() argument
312 if (!timespec64_valid_strict(ts)) in pc_clock_settime()
313 return -EINVAL; in pc_clock_settime()
319 if ((cd.fp->f_mode & FMODE_WRITE) == 0) { in pc_clock_settime()
320 err = -EACCES; in pc_clock_settime()
324 if (cd.clk->ops.clock_settime) in pc_clock_settime()
325 err = cd.clk->ops.clock_settime(cd.clk, ts); in pc_clock_settime()
327 err = -EOPNOTSUPP; in pc_clock_settime()