include/linux/tty_driver.h
Source file repositories/reference/linux-study-clean/include/linux/tty_driver.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/tty_driver.h- Extension
.h- Size
- 23206 bytes
- Lines
- 614
- 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.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/fs.hlinux/kref.hlinux/list.hlinux/cdev.hlinux/uaccess.hlinux/termios.hlinux/seq_file.h
Detected Declarations
struct tty_structstruct tty_driverstruct serial_icounter_structstruct serial_structstruct tty_operationsstruct tty_driverenum tty_driver_flagenum tty_driver_typeenum tty_driver_subtypefunction __tty_alloc_driverfunction tty_set_operationsfunction proc_tty_register_driver
Annotated Snippet
struct tty_operations {
struct tty_struct * (*lookup)(struct tty_driver *driver,
struct file *filp, int idx);
int (*install)(struct tty_driver *driver, struct tty_struct *tty);
void (*remove)(struct tty_driver *driver, struct tty_struct *tty);
int (*open)(struct tty_struct * tty, struct file * filp);
void (*close)(struct tty_struct * tty, struct file * filp);
void (*shutdown)(struct tty_struct *tty);
void (*cleanup)(struct tty_struct *tty);
ssize_t (*write)(struct tty_struct *tty, const u8 *buf, size_t count);
int (*put_char)(struct tty_struct *tty, u8 ch);
void (*flush_chars)(struct tty_struct *tty);
unsigned int (*write_room)(struct tty_struct *tty);
unsigned int (*chars_in_buffer)(struct tty_struct *tty);
int (*ioctl)(struct tty_struct *tty,
unsigned int cmd, unsigned long arg);
long (*compat_ioctl)(struct tty_struct *tty,
unsigned int cmd, unsigned long arg);
void (*set_termios)(struct tty_struct *tty, const struct ktermios *old);
void (*throttle)(struct tty_struct * tty);
void (*unthrottle)(struct tty_struct * tty);
void (*stop)(struct tty_struct *tty);
void (*start)(struct tty_struct *tty);
void (*hangup)(struct tty_struct *tty);
int (*break_ctl)(struct tty_struct *tty, int state);
void (*flush_buffer)(struct tty_struct *tty);
int (*ldisc_ok)(struct tty_struct *tty, int ldisc);
void (*set_ldisc)(struct tty_struct *tty);
void (*wait_until_sent)(struct tty_struct *tty, int timeout);
void (*send_xchar)(struct tty_struct *tty, u8 ch);
int (*tiocmget)(struct tty_struct *tty);
int (*tiocmset)(struct tty_struct *tty,
unsigned int set, unsigned int clear);
int (*resize)(struct tty_struct *tty, struct winsize *ws);
int (*get_icount)(struct tty_struct *tty,
struct serial_icounter_struct *icount);
int (*get_serial)(struct tty_struct *tty, struct serial_struct *p);
int (*set_serial)(struct tty_struct *tty, struct serial_struct *p);
void (*show_fdinfo)(struct tty_struct *tty, struct seq_file *m);
#ifdef CONFIG_CONSOLE_POLL
int (*poll_init)(struct tty_driver *driver, int line, char *options);
int (*poll_get_char)(struct tty_driver *driver, int line);
void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
#endif
int (*proc_show)(struct seq_file *m, void *driver);
} __randomize_layout;
/**
* struct tty_driver -- driver for TTY devices
*
* @kref: reference counting. Reaching zero frees all the internals and the
* driver.
* @cdevs: allocated/registered character /dev devices
* @owner: modules owning this driver. Used drivers cannot be rmmod'ed.
* Automatically set by tty_alloc_driver().
* @driver_name: name of the driver used in /proc/tty
* @name: used for constructing /dev node name
* @name_base: used as a number base for constructing /dev node name
* @major: major /dev device number (zero for autoassignment)
* @minor_start: the first minor /dev device number
* @num: number of devices allocated
* @type: type of tty driver (enum tty_driver_type)
* @subtype: subtype of tty driver (enum tty_driver_subtype)
* @init_termios: termios to set to each tty initially (e.g. %tty_std_termios)
* @flags: tty driver flags (%TTY_DRIVER_)
* @proc_entry: proc fs entry, used internally
* @other: driver of the linked tty; only used for the PTY driver
* @flip_wq: workqueue to queue flip buffer work on
* @ttys: array of active &struct tty_struct, set by tty_standard_install()
* @ports: array of &struct tty_port; can be set during initialization by
* tty_port_link_device() and similar
* @termios: storage for termios at each TTY close for the next open
* @driver_state: pointer to driver's arbitrary data
* @ops: driver hooks for TTYs. Set them using tty_set_operations(). Use &struct
* tty_port helpers in them as much as possible.
* @tty_drivers: used internally to link tty_drivers together
*
* The usual handling of &struct tty_driver is to allocate it by
* tty_alloc_driver(), set up all the necessary members, and register it by
* tty_register_driver(). At last, the driver is torn down by calling
* tty_unregister_driver() followed by tty_driver_kref_put().
*
* The fields required to be set before calling tty_register_driver() include
* @driver_name, @name, @type, @subtype, @init_termios, and @ops.
*/
struct tty_driver {
struct kref kref;
struct cdev **cdevs;
struct module *owner;
const char *driver_name;
Annotation
- Immediate include surface: `linux/export.h`, `linux/fs.h`, `linux/kref.h`, `linux/list.h`, `linux/cdev.h`, `linux/uaccess.h`, `linux/termios.h`, `linux/seq_file.h`.
- Detected declarations: `struct tty_struct`, `struct tty_driver`, `struct serial_icounter_struct`, `struct serial_struct`, `struct tty_operations`, `struct tty_driver`, `enum tty_driver_flag`, `enum tty_driver_type`, `enum tty_driver_subtype`, `function __tty_alloc_driver`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.