include/linux/posix-clock.h

Source file repositories/reference/linux-study-clean/include/linux/posix-clock.h

File Facts

System
Linux kernel
Corpus path
include/linux/posix-clock.h
Extension
.h
Size
4808 bytes
Lines
143
Domain
Core OS
Bucket
Core Kernel Interface
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct posix_clock_operations {
	struct module *owner;

	int  (*clock_adjtime)(struct posix_clock *pc, struct __kernel_timex *tx);

	int  (*clock_gettime)(struct posix_clock *pc, struct timespec64 *ts);

	int  (*clock_getres) (struct posix_clock *pc, struct timespec64 *ts);

	int  (*clock_settime)(struct posix_clock *pc,
			      const struct timespec64 *ts);

	/*
	 * Optional character device methods:
	 */
	long (*ioctl)(struct posix_clock_context *pccontext, unsigned int cmd,
		      unsigned long arg);

	int (*open)(struct posix_clock_context *pccontext, fmode_t f_mode);

	__poll_t (*poll)(struct posix_clock_context *pccontext, struct file *file,
			 poll_table *wait);

	int (*release)(struct posix_clock_context *pccontext);

	ssize_t (*read)(struct posix_clock_context *pccontext, uint flags,
			char __user *buf, size_t cnt);
};

/**
 * struct posix_clock - represents a dynamic posix clock
 *
 * @ops:     Functional interface to the clock
 * @cdev:    Character device instance for this clock
 * @dev:     Pointer to the clock's device.
 * @rwsem:   Protects the 'zombie' field from concurrent access.
 * @zombie:  If 'zombie' is true, then the hardware has disappeared.
 *
 * Drivers should embed their struct posix_clock within a private
 * structure, obtaining a reference to it during callbacks using
 * container_of().
 *
 * Drivers should supply an initialized but not exposed struct device
 * to posix_clock_register(). It is used to manage lifetime of the
 * driver's private structure. It's 'release' field should be set to
 * a release function for this private structure.
 */
struct posix_clock {
	struct posix_clock_operations ops;
	struct cdev cdev;
	struct device *dev;
	struct rw_semaphore rwsem;
	bool zombie;
};

/**
 * struct posix_clock_context - represents clock file operations context
 *
 * @clk:              Pointer to the clock
 * @fp:               Pointer to the file used to open the clock
 * @private_clkdata:  Pointer to user data
 *
 * Drivers should use struct posix_clock_context during specific character
 * device file operation methods to access the posix clock. In particular,
 * the file pointer can be used to verify correct access mode for ioctl()
 * calls.
 *
 * Drivers can store a private data structure during the open operation
 * if they have specific information that is required in other file
 * operations.
 */
struct posix_clock_context {
	struct posix_clock *clk;
	struct file *fp;
	void *private_clkdata;
};

/**
 * posix_clock_register() - register a new clock
 * @clk:   Pointer to the clock. Caller must provide 'ops' field
 * @dev:   Pointer to the initialized device. Caller must provide
 *         'release' field
 *
 * A clock driver calls this function to register itself with the
 * clock device subsystem. If 'clk' points to dynamically allocated
 * memory, then the caller must provide a 'release' function to free
 * that memory.
 *
 * Returns zero on success, non-zero otherwise.
 */

Annotation

Implementation Notes