Poster of Linux kernelThe best gift for a Linux geek
 Linux kernel map 
⇦ prev ⇱ home next ⇨

18.6. The tty_driver Structure in Detail

The tty_driver structure is used to register a tty driver with the tty core. Here is a list of all of the different fields in the structure and how they are used by the tty core:

struct module *owner;

The module owner for this driver.

int magic;

The "magic" value for this structure. Should always be set to TTY_DRIVER_MAGIC. Is initialized in the alloc_tty_driver function.

const char *driver_name;

Name of the driver, used in /proc/tty and sysfs.

const char *name;

Node name of the driver.

int name_base;

Starting number to use when creating names for devices. This is used when the kernel creates a string representation of a specific tty device assigned to the tty driver.

short major;

Major number for the driver.

short minor_start;

Starting minor number for the driver. This is usually set to the same value as name_base. Typically, this value is set to 0.

short num;

Number of minor numbers assigned to the driver. If an entire major number range is used by the driver, this value should be set to 255. This variable is initialized in the alloc_tty_driver function.

short type;

short subtype;

Describe what kind of tty driver is being registered with the tty core. The value of subtype depends on the type. The type field can be:

TTY_DRIVER_TYPE_SYSTEM

Used internally by the tty subsystem to remember that it is dealing with an internal tty driver. subtype should be set to SYSTEM_TYPE_TTY, SYSTEM_TYPE_CONSOLE, SYSTEM_TYPE_SYSCONS, or SYSTEM_TYPE_SYSPTMX. This type should not be used by any "normal" tty driver.

TTY_DRIVER_TYPE_CONSOLE

Used only by the console driver.

TTY_DRIVER_TYPE_SERIAL

Used by any serial type driver. subtype should be set to SERIAL_TYPE_NORMAL or SERIAL_TYPE_CALLOUT, depending on which type your driver is. This is one of the most common settings for the type field.

TTY_DRIVER_TYPE_PTY

Used by the pseudo terminal interface (pty). subtype needs to be set to either PTY_TYPE_MASTER or PTY_TYPE_SLAVE.

struct termios init_termios;

Initial struct termios values for the device when it is created.

int flags;

Driver flags, as described earlier in this chapter.

struct proc_dir_entry *proc_entry;

This driver's /proc entry structure. It is created by the tty core if the driver implements the write_proc or read_proc functions. This field should not be set by the tty driver itself.

struct tty_driver *other;

Pointer to a tty slave driver. This is used only by the pty driver and should not be used by any other tty driver.

void *driver_state;

Internal state of the tty driver. Should be used only by the pty driver.

struct tty_driver *next;

struct tty_driver *prev;

Linking variables. These variables are used by the tty core to chain all of the different tty drivers together, and should not be touched by any tty driver.

    ⇦ prev ⇱ home next ⇨
    Poster of Linux kernelThe best gift for a Linux geek