~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/posix-clock.h

Version: ~ [ linux-5.9.1 ] ~ [ linux-5.8.16 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.72 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.152 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.202 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.240 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.240 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  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 
 29 struct posix_clock;
 30 
 31 /**
 32  * struct posix_clock_operations - functional interface to the clock
 33  *
 34  * Every posix clock is represented by a character device. Drivers may
 35  * optionally offer extended capabilities by implementing the
 36  * character device methods. The character device file operations are
 37  * first handled by the clock device layer, then passed on to the
 38  * driver by calling these functions.
 39  *
 40  * @owner:          The clock driver should set to THIS_MODULE
 41  * @clock_adjtime:  Adjust the clock
 42  * @clock_gettime:  Read the current time
 43  * @clock_getres:   Get the clock resolution
 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  * @open:           Optional character device open method
 52  * @release:        Optional character device release method
 53  * @ioctl:          Optional character device ioctl method
 54  * @read:           Optional character device read method
 55  * @poll:           Optional character device poll method
 56  */
 57 struct posix_clock_operations {
 58         struct module *owner;
 59 
 60         int  (*clock_adjtime)(struct posix_clock *pc, struct timex *tx);
 61 
 62         int  (*clock_gettime)(struct posix_clock *pc, struct timespec *ts);
 63 
 64         int  (*clock_getres) (struct posix_clock *pc, struct timespec *ts);
 65 
 66         int  (*clock_settime)(struct posix_clock *pc,
 67                               const struct timespec *ts);
 68 
 69         int  (*timer_create) (struct posix_clock *pc, struct k_itimer *kit);
 70 
 71         int  (*timer_delete) (struct posix_clock *pc, struct k_itimer *kit);
 72 
 73         void (*timer_gettime)(struct posix_clock *pc,
 74                               struct k_itimer *kit, struct itimerspec *tsp);
 75 
 76         int  (*timer_settime)(struct posix_clock *pc,
 77                               struct k_itimer *kit, int flags,
 78                               struct itimerspec *tsp, struct itimerspec *old);
 79         /*
 80          * Optional character device methods:
 81          */
 82         int     (*fasync)  (struct posix_clock *pc,
 83                             int fd, struct file *file, int on);
 84 
 85         long    (*ioctl)   (struct posix_clock *pc,
 86                             unsigned int cmd, unsigned long arg);
 87 
 88         int     (*mmap)    (struct posix_clock *pc,
 89                             struct vm_area_struct *vma);
 90 
 91         int     (*open)    (struct posix_clock *pc, fmode_t f_mode);
 92 
 93         uint    (*poll)    (struct posix_clock *pc,
 94                             struct file *file, poll_table *wait);
 95 
 96         int     (*release) (struct posix_clock *pc);
 97 
 98         ssize_t (*read)    (struct posix_clock *pc,
 99                             uint flags, char __user *buf, size_t cnt);
100 };
101 
102 /**
103  * struct posix_clock - represents a dynamic posix clock
104  *
105  * @ops:     Functional interface to the clock
106  * @cdev:    Character device instance for this clock
107  * @kref:    Reference count.
108  * @rwsem:   Protects the 'zombie' field from concurrent access.
109  * @zombie:  If 'zombie' is true, then the hardware has disappeared.
110  * @release: A function to free the structure when the reference count reaches
111  *           zero. May be NULL if structure is statically allocated.
112  *
113  * Drivers should embed their struct posix_clock within a private
114  * structure, obtaining a reference to it during callbacks using
115  * container_of().
116  */
117 struct posix_clock {
118         struct posix_clock_operations ops;
119         struct cdev cdev;
120         struct kref kref;
121         struct rw_semaphore rwsem;
122         bool zombie;
123         void (*release)(struct posix_clock *clk);
124 };
125 
126 /**
127  * posix_clock_register() - register a new clock
128  * @clk:   Pointer to the clock. Caller must provide 'ops' and 'release'
129  * @devid: Allocated device id
130  *
131  * A clock driver calls this function to register itself with the
132  * clock device subsystem. If 'clk' points to dynamically allocated
133  * memory, then the caller must provide a 'release' function to free
134  * that memory.
135  *
136  * Returns zero on success, non-zero otherwise.
137  */
138 int posix_clock_register(struct posix_clock *clk, dev_t devid);
139 
140 /**
141  * posix_clock_unregister() - unregister a clock
142  * @clk: Clock instance previously registered via posix_clock_register()
143  *
144  * A clock driver calls this function to remove itself from the clock
145  * device subsystem. The posix_clock itself will remain (in an
146  * inactive state) until its reference count drops to zero, at which
147  * point it will be deallocated with its 'release' method.
148  */
149 void posix_clock_unregister(struct posix_clock *clk);
150 
151 #endif
152 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp