struct tty_port; ================ ---------------- void tty_port_init(struct tty_port *port); /** * tty_port_destroy -- destroy inited port * @port: tty port to be doestroyed * * When a port was initialized using tty_port_init, one has to destroy the * port by this function. Either indirectly by using tty_port refcounting * (tty_port_put) or directly if refcounting is not used. */ void tty_port_destroy(struct tty_port *port); ---------------- struct tty_port_operations { ... /* Called when the last close completes or a hangup finishes IFF the port was initialized. Do not use to free resources. Called under the port mutex to serialize against activate/shutdowns */ void (*shutdown)(struct tty_port *port); ... /* Called under the port mutex from tty_port_open, serialized using the port mutex */ /* FIXME: long term getting the tty argument *out* of this would be good for consoles */ int (*activate)(struct tty_port *port, struct tty_struct *tty); ... }; int tty_port_open(struct tty_port *port, struct tty_struct *tty, struct file *filp); void tty_port_close(struct tty_port *port, struct tty_struct *tty, struct file *filp); struct tty_operations { ... int (*open)(struct tty_struct * tty, struct file * filp); void (*close)(struct tty_struct * tty, struct file * filp); ... } tty_operations -> open tty_port_open //call activate if and only if first process open tty tty_port_operations -> activate tty_operations -> close tty_port_close //call shutdown if and only if last process close tty tty_port_operations -> shutdown ---------------- /** * tty_port_register_device - register tty device * @port: tty_port of the device * @driver: tty_driver for this device * @index: index of the tty * @device: parent if exists, otherwise NULL * * It is the same as tty_register_device except the provided @port is linked to * a concrete tty specified by @index. Use this or tty_port_install (or both). * Call tty_port_link_device as a last resort. */ struct device *tty_port_register_device(struct tty_port *port, struct tty_driver *driver, unsigned index, struct device *device);