STRUCT TTY_DRIVER(9)
π NAME
struct tty_driver β the driver for TTY devices, bestie. That's it, that's the whole vibe. It's the manual page for this struct from the Kernel API Manual, and we're gonna go through every single field together π«Ά
β¨ SYNOPSIS β¨
Okay so here's the whole struct, no cap, copied exactly:
struct tty_driver {
struct kref kref;
struct cdev **cdevs;
struct module *owner;
const char *driver_name;
const char *name;
int name_base;
int major;
int minor_start;
unsigned int num;
enum tty_driver_type type;
enum tty_driver_subtype subtype;
struct ktermios init_termios;
unsigned long flags;
struct proc_dir_entry *proc_entry;
struct tty_driver *other;
struct workqueue_struct *flip_wq;
struct tty_struct **ttys;
struct tty_port **ports;
struct ktermios **termios;
void *driver_state;
const struct tty_operations *ops;
struct list_head tty_drivers;
};
π Members
Every field, one by one, let's go π
krefβ reference counting, literally its whole job. When it hits zero, all the internals and the driver get freed. Zero = cleanup era πcdevsβ the allocated/registered character/devdevices. The actual device nodes living their lives.ownerβ the modules owning this driver. Used drivers cannot bermmod'ed, periodt. This one gets set automatically bytty_alloc_driver, so don't stress.driver_nameβ name of the driver, the one that shows up in/proc/tty.nameβ used for constructing the/devnode name. Yep, that name.name_baseβ used as a number base for constructing the/devnode name π’majorβ major/devdevice number. Zero means autoassignment, so the kernel picks for you slay.minor_startβ the first minor/devdevice number.numβ number of devices allocated. Count 'em.typeβ type of tty driver (that'senum tty_driver_type).subtypeβ subtype of tty driver (that'senum tty_driver_subtype). Yes there's a subtype, we love layers.init_termiosβ the termios to set to each tty initially (e.g.tty_std_termios). First-impression termios.flagsβ tty driver flags (TTY_DRIVER_).proc_entryβ proc fs entry, used internally. Don't touch, it's doing internals things πotherβ driver of the linked tty; only used for the PTY driver. Very exclusive, very main character.flip_wqβ workqueue to queue flip buffer work on.ttysβ array of activestruct tty_struct, set bytty_standard_install.portsβ array ofstruct tty_port; can be set during initialization bytty_port_link_deviceand similar.termiosβ storage for termios at each TTY close, for the next open. Saving it for later, we love foresight β¨driver_stateβ pointer to driver's arbitrary data. Whatever you want, it's your data bestie.opsβ driver hooks for TTYs. Set them usingtty_set_operations. And please, usestruct tty_porthelpers in them as much as possible β that's the assignment πtty_driversβ used internally to link tty_drivers together. Chain 'em up.
π DESCRIPTION π
So the usual handling of struct tty_driver goes like this, in order, no skipping steps:
- Allocate it with
tty_alloc_driver. - Set up all the necessary members.
- Register it with
tty_register_driver. - At last, tear the driver down by calling
tty_unregister_driver, followed bytty_driver_kref_put.
That's the whole lifecycle arc, literally character development.
The fields required to be set before callingtty_register_driverincludedriver_name,name,type,subtype,init_termios, andops. Don't skip these, fr fr β they're mandatory and the registration will not be cute if you forget them π
π SEE ALSO π
Go read these next, iykyk:
- Kernel file
./include/linux/tty_driver.h enum tty_driver_flag(9)struct tty_operations(9)tty_alloc_driver(9)
Okay that's the whole page bestie, you ate it up π This one came from ./include/linux, dated October 2026, and it's struct tty_driver(9) β go forth and register those TTY drivers responsibly, mwah ππ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms