8388608
     EˆÆÍ„�ŸÅÀÐ ?÷     E/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_TTY_DRIVER_H
#define _LINUX_TTY_DRIVER_H

#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)``
 *
 *	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.
 *
 * @install: ``int ()(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.
 *
 *	Optional method. Default behaviour is to use the @self->ttys array.
 *
 * @remove: ``void ()(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.
 *
 *	Optional method. Default behaviour is to use the @self->ttys array.
 *
 * @open: ``int ()(struct tty_struct *tty, struct file *)``
 *
 *	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.
 *
 * @close: ``void ()(struct tty_struct *tty, struct file *)``
 *
 *	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.
 *
 *	Remark: called even if the corresponding @open() failed.
 *
 *	Required method. Called with tty lock held. May sleep.
 *
 * @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.
 *
 * @cleanup: ``void ()(struct tty_struct *tty)``
 *
 *	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: ``ssize_t ()(struct tty_struct *tty, const u8 *buf, size_t count)``
 *
 *	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.
 *
 *	May occur in parallel in special cases. Because this includes panic
 *	paths drivers generally shouldn't try and do clever locking here.
 *
 *	Optional: Required for writable devices. May not sleep.
 *
 * @put_char: ``int ()(struct tty_struct *tty, u8 ch)``
 *
 *	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.
 *
 *	Optional: Kernel will use the @write method if not provided. Do not
 *	call this function directly, call tty_put_char().
 *
 * @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().
 *
 *	Optional. Do not call this function directly, call
 *	tty_driver_flush_chars().
 *
 * @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 t