Merge tag 'net-5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[linux-2.6-microblaze.git] / include / linux / tty_driver.h
index 795b94c..4841d80 100644 (file)
 #ifndef _LINUX_TTY_DRIVER_H
 #define _LINUX_TTY_DRIVER_H
 
-/*
- * This structure defines the interface between the low-level tty
- * driver and the tty routines.  The following routines can be
- * defined; unless noted otherwise, they are optional, and can be
- * filled in with a null pointer.
+#include <linux/export.h>
+#include <linux/fs.h>
+#include <linux/kref.h>
+#include <linux/list.h>
+#include <linux/cdev.h>
+#include <linux/termios.h>
+#include <linux/seq_file.h>
+
+struct tty_struct;
+struct tty_driver;
+struct serial_icounter_struct;
+struct serial_struct;
+
+/**
+ * struct tty_operations -- interface between driver and tty
+ *
+ * @lookup: ``struct tty_struct *()(struct tty_driver *self, struct file *,
+ *                                 int idx)``
  *
- * struct tty_struct * (*lookup)(struct tty_driver *self, struct file *, int idx)
+ *     Return the tty device corresponding to @idx, %NULL if there is not
+ *     one currently in use and an %ERR_PTR value on error. Called under
+ *     %tty_mutex (for now!)
  *
- *     Return the tty device corresponding to idx, NULL if there is not
- *     one currently in use and an ERR_PTR value on error. Called under
- *     tty_mutex (for now!)
+ *     Optional method. Default behaviour is to use the @self->ttys array.
  *
- *     Optional method. Default behaviour is to use the ttys array
+ * @install: ``int ()(struct tty_driver *self, struct tty_struct *tty)``
  *
- * int (*install)(struct tty_driver *self, struct tty_struct *tty)
+ *     Install a new @tty into the @self's internal tables. Used in
+ *     conjunction with @lookup and @remove methods.
  *
- *     Install a new tty into the tty driver internal tables. Used in
- *     conjunction with lookup and remove methods.
+ *     Optional method. Default behaviour is to use the @self->ttys array.
  *
- *     Optional method. Default behaviour is to use the ttys array
+ * @remove: ``void ()(struct tty_driver *self, struct tty_struct *tty)``
  *
- * void (*remove)(struct tty_driver *self, struct tty_struct *tty)
+ *     Remove a closed @tty from the @self's internal tables. Used in
+ *     conjunction with @lookup and @remove methods.
  *
- *     Remove a closed tty from the tty driver internal tables. Used in
- *     conjunction with lookup and remove methods.
+ *     Optional method. Default behaviour is to use the @self->ttys array.
  *
- *     Optional method. Default behaviour is to use the ttys array
+ * @open: ``int ()(struct tty_struct *tty, struct file *)``
  *
- * int  (*open)(struct tty_struct * tty, struct file * filp);
+ *     This routine is called when a particular @tty device is opened. This
+ *     routine is mandatory; if this routine is not filled in, the attempted
+ *     open will fail with %ENODEV.
  *
- *     This routine is called when a particular tty device is opened.
- *     This routine is mandatory; if this routine is not filled in,
- *     the attempted open will fail with ENODEV.
+ *     Required method. Called with tty lock held. May sleep.
  *
- *     Required method. Called with tty lock held.
+ * @close: ``void ()(struct tty_struct *tty, struct file *)``
  *
- * void (*close)(struct tty_struct * tty, struct file * filp);
+ *     This routine is called when a particular @tty device is closed. At the
+ *     point of return from this call the driver must make no further ldisc
+ *     calls of any kind.
  *
- *     This routine is called when a particular tty device is closed.
- *     Note: called even if the corresponding open() failed.
+ *     Remark: called even if the corresponding @open() failed.
  *
- *     Required method. Called with tty lock held.
+ *     Required method. Called with tty lock held. May sleep.
  *
- * void (*shutdown)(struct tty_struct * tty);
+ * @shutdown: ``void ()(struct tty_struct *tty)``
  *
- *     This routine is called under the tty lock when a particular tty device
- *     is closed for the last time. It executes before the tty resources
- *     are freed so may execute while another function holds a tty kref.
+ *     This routine is called under the tty lock when a particular @tty device
+ *     is closed for the last time. It executes before the @tty resources
+ *     are freed so may execute while another function holds a @tty kref.
  *
- * void (*cleanup)(struct tty_struct * tty);
+ * @cleanup: ``void ()(struct tty_struct *tty)``
  *
- *     This routine is called asynchronously when a particular tty device
+ *     This routine is called asynchronously when a particular @tty device
  *     is closed for the last time freeing up the resources. This is
  *     actually the second part of shutdown for routines that might sleep.
  *
+ * @write: ``int ()(struct tty_struct *tty, const unsigned char *buf,
+ *                 int count)``
  *
- * int (*write)(struct tty_struct * tty,
- *              const unsigned char *buf, int count);
- *
- *     This routine is called by the kernel to write a series of
- *     characters to the tty device.  The characters may come from
- *     user space or kernel space.  This routine will return the
+ *     This routine is called by the kernel to write a series (@count) of
+ *     characters (@buf) to the @tty device. The characters may come from
+ *     user space or kernel space.  This routine will return the
  *     number of characters actually accepted for writing.
  *
- *     Optional: Required for writable devices.
+ *     May occur in parallel in special cases. Because this includes panic
+ *     paths drivers generally shouldn't try and do clever locking here.
  *
- * int (*put_char)(struct tty_struct *tty, unsigned char ch);
+ *     Optional: Required for writable devices. May not sleep.
  *
- *     This routine is called by the kernel to write a single
- *     character to the tty device.  If the kernel uses this routine,
- *     it must call the flush_chars() routine (if defined) when it is
- *     done stuffing characters into the driver.  If there is no room
- *     in the queue, the character is ignored.
+ * @put_char: ``int ()(struct tty_struct *tty, unsigned char ch)``
  *
- *     Optional: Kernel will use the write method if not provided.
+ *     This routine is called by the kernel to write a single character @ch to
+ *     the @tty device. If the kernel uses this routine, it must call the
+ *     @flush_chars() routine (if defined) when it is done stuffing characters
+ *     into the driver. If there is no room in the queue, the character is
+ *     ignored.
  *
- *     Note: Do not call this function directly, call tty_put_char
+ *     Optional: Kernel will use the @write method if not provided. Do not
+ *     call this function directly, call tty_put_char().
  *
- * void (*flush_chars)(struct tty_struct *tty);
+ * @flush_chars: ``void ()(struct tty_struct *tty)``
  *
- *     This routine is called by the kernel after it has written a
- *     series of characters to the tty device using put_char().  
+ *     This routine is called by the kernel after it has written a
+ *     series of characters to the tty device using @put_char().
  *
- *     Optional:
+ *     Optional. Do not call this function directly, call
+ *     tty_driver_flush_chars().
  *
- *     Note: Do not call this function directly, call tty_driver_flush_chars
- * 
- * unsigned int  (*write_room)(struct tty_struct *tty);
+ * @write_room: ``unsigned int ()(struct tty_struct *tty)``
  *
- *     This routine returns the numbers of characters the tty driver
- *     will accept for queuing to be written.  This number is subject
- *     to change as output buffers get emptied, or if the output flow
+ *     This routine returns the numbers of characters the @tty driver
+ *     will accept for queuing to be written.  This number is subject
+ *     to change as output buffers get emptied, or if the output flow
  *     control is acted.
  *
- *     Required if write method is provided else not needed.
+ *     The ldisc is responsible for being intelligent about multi-threading of
+ *     write_room/write calls
+ *
+ *     Required if @write method is provided else not needed. Do not call this
+ *     function directly, call tty_write_room()
+ *
+ * @chars_in_buffer: ``unsigned int ()(struct tty_struct *tty)``
+ *
+ *     This routine returns the number of characters in the device private
+ *     output queue. Used in tty_wait_until_sent() and for poll()
+ *     implementation.
  *
- *     Note: Do not call this function directly, call tty_write_room
- * 
- * int  (*ioctl)(struct tty_struct *tty, unsigned int cmd, unsigned long arg);
+ *     Optional: if not provided, it is assumed there is no queue on the
+ *     device. Do not call this function directly, call tty_chars_in_buffer().
  *
- *     This routine allows the tty driver to implement
- *     device-specific ioctls.  If the ioctl number passed in cmd
- *     is not recognized by the driver, it should return ENOIOCTLCMD.
+ * @ioctl: ``int ()(struct tty_struct *tty, unsigned int cmd,
+ *                 unsigned long arg)``
  *
- *     Optional
+ *     This routine allows the @tty driver to implement device-specific
+ *     ioctls. If the ioctl number passed in @cmd is not recognized by the
+ *     driver, it should return %ENOIOCTLCMD.
  *
- * long (*compat_ioctl)(struct tty_struct *tty,,
- *                     unsigned int cmd, unsigned long arg);
+ *     Optional.
  *
- *     implement ioctl processing for 32 bit process on 64 bit system
+ * @compat_ioctl: ``long ()(struct tty_struct *tty, unsigned int cmd,
+ *                       unsigned long arg)``
  *
- *     Optional
- * 
- * void (*set_termios)(struct tty_struct *tty, struct ktermios * old);
+ *     Implement ioctl processing for 32 bit process on 64 bit system.
  *
- *     This routine allows the tty driver to be notified when
- *     device's termios settings have changed.
+ *     Optional.
  *
- *     Optional: Called under the termios lock
+ * @set_termios: ``void ()(struct tty_struct *tty, struct ktermios *old)``
  *
+ *     This routine allows the @tty driver to be notified when device's
+ *     termios settings have changed. New settings are in @tty->termios.
+ *     Previous settings are passed in the @old argument.
  *
- * void (*set_ldisc)(struct tty_struct *tty);
+ *     The API is defined such that the driver should return the actual modes
+ *     selected. This means that the driver is responsible for modifying any
+ *     bits in @tty->termios it cannot fulfill to indicate the actual modes
+ *     being used.
  *
- *     This routine allows the tty driver to be notified when the
- *     device's termios settings have changed.
+ *     Optional. Called under the @tty->termios_rwsem. May sleep.
  *
- *     Optional: Called under BKL (currently)
- * 
- * void (*throttle)(struct tty_struct * tty);
+ * @set_ldisc: ``void ()(struct tty_struct *tty)``
  *
- *     This routine notifies the tty driver that input buffers for
- *     the line discipline are close to full, and it should somehow
- *     signal that no more characters should be sent to the tty.
+ *     This routine allows the @tty driver to be notified when the device's
+ *     line discipline is being changed. At the point this is done the
+ *     discipline is not yet usable.
  *
- *     Optional: Always invoke via tty_throttle_safe(), called under the
- *     termios lock.
- * 
- * void (*unthrottle)(struct tty_struct * tty);
+ *     Optional. Called under the @tty->ldisc_sem and @tty->termios_rwsem.
  *
- *     This routine notifies the tty drivers that it should signals
- *     that characters can now be sent to the tty without fear of
- *     overrunning the input buffers of the line disciplines.
- * 
- *     Optional: Always invoke via tty_unthrottle(), called under the
- *     termios lock.
+ * @throttle: ``void ()(struct tty_struct *tty)``
  *
- * void (*stop)(struct tty_struct *tty);
+ *     This routine notifies the @tty driver that input buffers for the line
+ *     discipline are close to full, and it should somehow signal that no more
+ *     characters should be sent to the @tty.
  *
- *     This routine notifies the tty driver that it should stop
- *     outputting characters to the tty device.  
+ *     Serialization including with @unthrottle() is the job of the ldisc
+ *     layer.
  *
- *     Called with ->flow.lock held. Serialized with start() method.
+ *     Optional: Always invoke via tty_throttle_safe(). Called under the
+ *     @tty->termios_rwsem.
  *
- *     Optional:
+ * @unthrottle: ``void ()(struct tty_struct *tty)``
  *
- *     Note: Call stop_tty not this method.
- * 
- * void (*start)(struct tty_struct *tty);
+ *     This routine notifies the @tty driver that it should signal that
+ *     characters can now be sent to the @tty without fear of overrunning the
+ *     input buffers of the line disciplines.
  *
- *     This routine notifies the tty driver that it resume sending
+ *     Optional. Always invoke via tty_unthrottle(). Called under the
+ *     @tty->termios_rwsem.
+ *
+ * @stop: ``void ()(struct tty_struct *tty)``
+ *
+ *     This routine notifies the @tty driver that it should stop outputting
  *     characters to the tty device.
  *
- *     Called with ->flow.lock held. Serialized with stop() method.
+ *     Called with @tty->flow.lock held. Serialized with @start() method.
+ *
+ *     Optional. Always invoke via stop_tty().
+ *
+ * @start: ``void ()(struct tty_struct *tty)``
+ *
+ *     This routine notifies the @tty driver that it resumed sending
+ *     characters to the @tty device.
+ *
+ *     Called with @tty->flow.lock held. Serialized with stop() method.
+ *
+ *     Optional. Always invoke via start_tty().
+ *
+ * @hangup: ``void ()(struct tty_struct *tty)``
+ *
+ *     This routine notifies the @tty driver that it should hang up the @tty
+ *     device.
  *
- *     Optional:
+ *     Optional. Called with tty lock held.
  *
- *     Note: Call start_tty not this method.
- * 
- * void (*hangup)(struct tty_struct *tty);
+ * @break_ctl: ``int ()(struct tty_struct *tty, int state)``
  *
- *     This routine notifies the tty driver that it should hang up the
- *     tty device.
+ *     This optional routine requests the @tty driver to turn on or off BREAK
+ *     status on the RS-232 port. If @state is -1, then the BREAK status
+ *     should be turned on; if @state is 0, then BREAK should be turned off.
  *
- *     Optional:
+ *     If this routine is implemented, the high-level tty driver will handle
+ *     the following ioctls: %TCSBRK, %TCSBRKP, %TIOCSBRK, %TIOCCBRK.
  *
- *     Called with tty lock held.
+ *     If the driver sets %TTY_DRIVER_HARDWARE_BREAK in tty_alloc_driver(),
+ *     then the interface will also be called with actual times and the
+ *     hardware is expected to do the delay work itself. 0 and -1 are still
+ *     used for on/off.
  *
- * int (*break_ctl)(struct tty_struct *tty, int state);
+ *     Optional: Required for %TCSBRK/%BRKP/etc. handling. May sleep.
  *
- *     This optional routine requests the tty driver to turn on or
- *     off BREAK status on the RS-232 port.  If state is -1,
- *     then the BREAK status should be turned on; if state is 0, then
- *     BREAK should be turned off.
+ * @flush_buffer: ``void ()(struct tty_struct *tty)``
  *
- *     If this routine is implemented, the high-level tty driver will
- *     handle the following ioctls: TCSBRK, TCSBRKP, TIOCSBRK,
- *     TIOCCBRK.
+ *     This routine discards device private output buffer. Invoked on close,
+ *     hangup, to implement %TCOFLUSH ioctl and similar.
  *
- *     If the driver sets TTY_DRIVER_HARDWARE_BREAK then the interface
- *     will also be called with actual times and the hardware is expected
- *     to do the delay work itself. 0 and -1 are still used for on/off.
+ *     Optional: if not provided, it is assumed there is no queue on the
+ *     device. Do not call this function directly, call
+ *     tty_driver_flush_buffer().
  *
- *     Optional: Required for TCSBRK/BRKP/etc handling.
+ * @wait_until_sent: ``void ()(struct tty_struct *tty, int timeout)``
  *
- * void (*wait_until_sent)(struct tty_struct *tty, int timeout);
- * 
- *     This routine waits until the device has written out all of the
- *     characters in its transmitter FIFO.
+ *     This routine waits until the device has written out all of the
+ *     characters in its transmitter FIFO. Or until @timeout (in jiffies) is
+ *     reached.
  *
- *     Optional: If not provided the device is assumed to have no FIFO
+ *     Optional: If not provided, the device is assumed to have no FIFO.
+ *     Usually correct to invoke via tty_wait_until_sent(). May sleep.
  *
- *     Note: Usually correct to call tty_wait_until_sent
+ * @send_xchar: ``void ()(struct tty_struct *tty, char ch)``
  *
- * void (*send_xchar)(struct tty_struct *tty, char ch);
+ *     This routine is used to send a high-priority XON/XOFF character (@ch)
+ *     to the @tty device.
  *
- *     This routine is used to send a high-priority XON/XOFF
- *     character to the device.
+ *     Optional: If not provided, then the @write method is called under
+ *     the @tty->atomic_write_lock to keep it serialized with the ldisc.
  *
- *     Optional: If not provided then the write method is called under
- *     the atomic write lock to keep it serialized with the ldisc.
+ * @tiocmget: ``int ()(struct tty_struct *tty)``
  *
- * int (*resize)(struct tty_struct *tty, struct winsize *ws)
+ *     This routine is used to obtain the modem status bits from the @tty
+ *     driver.
  *
- *     Called when a termios request is issued which changes the
- *     requested terminal geometry.
+ *     Optional: If not provided, then %ENOTTY is returned from the %TIOCMGET
+ *     ioctl. Do not call this function directly, call tty_tiocmget().
+ *
+ * @tiocmset: ``int ()(struct tty_struct *tty,
+ *                    unsigned int set, unsigned int clear)``
+ *
+ *     This routine is used to set the modem status bits to the @tty driver.
+ *     First, @clear bits should be cleared, then @set bits set.
+ *
+ *     Optional: If not provided, then %ENOTTY is returned from the %TIOCMSET
+ *     ioctl. Do not call this function directly, call tty_tiocmset().
+ *
+ * @resize: ``int ()(struct tty_struct *tty, struct winsize *ws)``
+ *
+ *     Called when a termios request is issued which changes the requested
+ *     terminal geometry to @ws.
  *
  *     Optional: the default action is to update the termios structure
  *     without error. This is usually the correct behaviour. Drivers should
- *     not force errors here if they are not resizable objects (eg a serial
+ *     not force errors here if they are not resizable objects (e.g. a serial
  *     line). See tty_do_resize() if you need to wrap the standard method
- *     in your own logic - the usual case.
+ *     in your own logic -- the usual case.
+ *
+ * @get_icount: ``int ()(struct tty_struct *tty,
+ *                      struct serial_icounter *icount)``
+ *
+ *     Called when the @tty device receives a %TIOCGICOUNT ioctl. Passed a
+ *     kernel structure @icount to complete.
+ *
+ *     Optional: called only if provided, otherwise %ENOTTY will be returned.
  *
- * int (*get_icount)(struct tty_struct *tty, struct serial_icounter *icount);
+ * @get_serial: ``int ()(struct tty_struct *tty, struct serial_struct *p)``
  *
- *     Called when the device receives a TIOCGICOUNT ioctl. Passed a kernel
- *     structure to complete. This method is optional and will only be called
- *     if provided (otherwise ENOTTY will be returned).
+ *     Called when the @tty device receives a %TIOCGSERIAL ioctl. Passed a
+ *     kernel structure @p (&struct serial_struct) to complete.
+ *
+ *     Optional: called only if provided, otherwise %ENOTTY will be returned.
+ *     Do not call this function directly, call tty_tiocgserial().
+ *
+ * @set_serial: ``int ()(struct tty_struct *tty, struct serial_struct *p)``
+ *
+ *     Called when the @tty device receives a %TIOCSSERIAL ioctl. Passed a
+ *     kernel structure @p (&struct serial_struct) to set the values from.
+ *
+ *     Optional: called only if provided, otherwise %ENOTTY will be returned.
+ *     Do not call this function directly, call tty_tiocsserial().
+ *
+ * @show_fdinfo: ``void ()(struct tty_struct *tty, struct seq_file *m)``
+ *
+ *     Called when the @tty device file descriptor receives a fdinfo request
+ *     from VFS (to show in /proc/<pid>/fdinfo/). @m should be filled with
+ *     information.
+ *
+ *     Optional: called only if provided, otherwise nothing is written to @m.
+ *     Do not call this function directly, call tty_show_fdinfo().
+ *
+ * @poll_init: ``int ()(struct tty_driver *driver, int line, char *options)``
+ *
+ *     kgdboc support (Documentation/dev-tools/kgdb.rst). This routine is
+ *     called to initialize the HW for later use by calling @poll_get_char or
+ *     @poll_put_char.
+ *
+ *     Optional: called only if provided, otherwise skipped as a non-polling
+ *     driver.
+ *
+ * @poll_get_char: ``int ()(struct tty_driver *driver, int line)``
+ *
+ *     kgdboc support (see @poll_init). @driver should read a character from a
+ *     tty identified by @line and return it.
+ *
+ *     Optional: called only if @poll_init provided.
+ *
+ * @poll_put_char: ``void ()(struct tty_driver *driver, int line, char ch)``
+ *
+ *     kgdboc support (see @poll_init). @driver should write character @ch to
+ *     a tty identified by @line.
+ *
+ *     Optional: called only if @poll_init provided.
+ *
+ * @proc_show: ``int ()(struct seq_file *m, void *driver)``
+ *
+ *     Driver @driver (cast to &struct tty_driver) can show additional info in
+ *     /proc/tty/driver/<driver_name>. It is enough to fill in the information
+ *     into @m.
+ *
+ *     Optional: called only if provided, otherwise no /proc entry created.
+ *
+ * This structure defines the interface between the low-level tty driver and
+ * the tty routines. These routines can be defined. Unless noted otherwise,
+ * they are optional, and can be filled in with a %NULL pointer.
  */
-
-#include <linux/export.h>
-#include <linux/fs.h>
-#include <linux/kref.h>
-#include <linux/list.h>
-#include <linux/cdev.h>
-#include <linux/termios.h>
-#include <linux/seq_file.h>
-
-struct tty_struct;
-struct tty_driver;
-struct serial_icounter_struct;
-struct serial_struct;
-
 struct tty_operations {
        struct tty_struct * (*lookup)(struct tty_driver *driver,
                        struct file *filp, int idx);
@@ -288,26 +390,64 @@ struct tty_operations {
        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 *, void *);
+       int (*proc_show)(struct seq_file *m, void *driver);
 } __randomize_layout;
 
+/**
+ * struct tty_driver -- driver for TTY devices
+ *
+ * @magic: set to %TTY_DRIVER_MAGIC in __tty_alloc_driver()
+ * @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 (%TTY_DRIVER_TYPE_)
+ * @subtype: subtype of tty driver (%SYSTEM_TYPE_, %PTY_TYPE_, %SERIAL_TYPE_)
+ * @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
+ * @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 {
-       int     magic;          /* magic number for this structure */
-       struct kref kref;       /* Reference management */
+       int     magic;
+       struct kref kref;
        struct cdev **cdevs;
        struct module   *owner;
        const char      *driver_name;
        const char      *name;
-       int     name_base;      /* offset of printed name */
-       int     major;          /* major device number */
-       int     minor_start;    /* start of minor device number */
-       unsigned int    num;    /* number of devices allocated */
-       short   type;           /* type of tty driver */
-       short   subtype;        /* subtype of tty driver */
-       struct ktermios init_termios; /* Initial termios */
-       unsigned long   flags;          /* tty driver flags */
-       struct proc_dir_entry *proc_entry; /* /proc fs entry */
-       struct tty_driver *other; /* only used for the PTY driver */
+       int     name_base;
+       int     major;
+       int     minor_start;
+       unsigned int    num;
+       short   type;
+       short   subtype;
+       struct ktermios init_termios;
+       unsigned long   flags;
+       struct proc_dir_entry *proc_entry;
+       struct tty_driver *other;
 
        /*
         * Pointer to the tty data structures
@@ -352,49 +492,53 @@ static inline void tty_set_operations(struct tty_driver *driver,
 /* tty driver magic number */
 #define TTY_DRIVER_MAGIC               0x5402
 
-/*
- * tty driver flags
- * 
- * TTY_DRIVER_RESET_TERMIOS --- requests the tty layer to reset the
- *     termios setting when the last process has closed the device.
- *     Used for PTY's, in particular.
- * 
- * TTY_DRIVER_REAL_RAW --- if set, indicates that the driver will
- *     guarantee never to set any special character handling
- *     flags if ((IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR ||
- *     !INPCK)).  That is, if there is no reason for the driver to
- *     send notifications of parity and break characters up to the
- *     line driver, it won't do so.  This allows the line driver to
- *     optimize for this case if this flag is set.  (Note that there
- *     is also a promise, if the above case is true, not to signal
- *     overruns, either.)
- *
- * TTY_DRIVER_DYNAMIC_DEV --- if set, the individual tty devices need
- *     to be registered with a call to tty_register_device() when the
- *     device is found in the system and unregistered with a call to
- *     tty_unregister_device() so the devices will be show up
- *     properly in sysfs.  If not set, driver->num entries will be
- *     created by the tty core in sysfs when tty_register_driver() is
- *     called.  This is to be used by drivers that have tty devices
- *     that can appear and disappear while the main tty driver is
- *     registered with the tty core.
- *
- * TTY_DRIVER_DEVPTS_MEM -- don't use the standard arrays, instead
- *     use dynamic memory keyed through the devpts filesystem.  This
- *     is only applicable to the pty driver.
- *
- * TTY_DRIVER_HARDWARE_BREAK -- hardware handles break signals. Pass
- *     the requested timeout to the caller instead of using a simple
- *     on/off interface.
- *
- * TTY_DRIVER_DYNAMIC_ALLOC -- do not allocate structures which are
- *     needed per line for this driver as it would waste memory.
- *     The driver will take care.
- *
- * TTY_DRIVER_UNNUMBERED_NODE -- do not create numbered /dev nodes. In
- *     other words create /dev/ttyprintk and not /dev/ttyprintk0.
- *     Applicable only when a driver for a single tty device is
- *     being allocated.
+/**
+ * DOC: TTY Driver Flags
+ *
+ * TTY_DRIVER_RESET_TERMIOS
+ *     Requests the tty layer to reset the termios setting when the last
+ *     process has closed the device. Used for PTYs, in particular.
+ *
+ * TTY_DRIVER_REAL_RAW
+ *     Indicates that the driver will guarantee not to set any special
+ *     character handling flags if this is set for the tty:
+ *
+ *     ``(IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR || !INPCK)``
+ *
+ *     That is, if there is no reason for the driver to
+ *     send notifications of parity and break characters up to the line
+ *     driver, it won't do so.  This allows the line driver to optimize for
+ *     this case if this flag is set.  (Note that there is also a promise, if
+ *     the above case is true, not to signal overruns, either.)
+ *
+ * TTY_DRIVER_DYNAMIC_DEV
+ *     The individual tty devices need to be registered with a call to
+ *     tty_register_device() when the device is found in the system and
+ *     unregistered with a call to tty_unregister_device() so the devices will
+ *     be show up properly in sysfs.  If not set, all &tty_driver.num entries
+ *     will be created by the tty core in sysfs when tty_register_driver() is
+ *     called.  This is to be used by drivers that have tty devices that can
+ *     appear and disappear while the main tty driver is registered with the
+ *     tty core.
+ *
+ * TTY_DRIVER_DEVPTS_MEM
+ *     Don't use the standard arrays (&tty_driver.ttys and
+ *     &tty_driver.termios), instead use dynamic memory keyed through the
+ *     devpts filesystem. This is only applicable to the PTY driver.
+ *
+ * TTY_DRIVER_HARDWARE_BREAK
+ *     Hardware handles break signals. Pass the requested timeout to the
+ *     &tty_operations.break_ctl instead of using a simple on/off interface.
+ *
+ * TTY_DRIVER_DYNAMIC_ALLOC
+ *     Do not allocate structures which are needed per line for this driver
+ *     (&tty_driver.ports) as it would waste memory. The driver will take
+ *     care. This is only applicable to the PTY driver.
+ *
+ * TTY_DRIVER_UNNUMBERED_NODE
+ *     Do not create numbered ``/dev`` nodes. For example, create
+ *     ``/dev/ttyprintk`` and not ``/dev/ttyprintk0``. Applicable only when a
+ *     driver for a single tty device is being allocated.
  */
 #define TTY_DRIVER_INSTALLED           0x0001
 #define TTY_DRIVER_RESET_TERMIOS       0x0002