Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Documentation: improve line discipline method descriptions

Mention that the ldisc open method must set tty->receive_room, and
that many methods are optional. Add description of receive_buf2 method.

Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Tilman Schmidt and committed by
Greg Kroah-Hartman
1a76eb5b 850b37a7

+39 -21
+39 -21
Documentation/serial/tty.txt
··· 39 39 open() - Called when the line discipline is attached to 40 40 the terminal. No other call into the line 41 41 discipline for this tty will occur until it 42 - completes successfully. Returning an error will 43 - prevent the ldisc from being attached. Can sleep. 42 + completes successfully. Should initialize any 43 + state needed by the ldisc, and set receive_room 44 + in the tty_struct to the maximum amount of data 45 + the line discipline is willing to accept from the 46 + driver with a single call to receive_buf(). 47 + Returning an error will prevent the ldisc from 48 + being attached. Can sleep. 44 49 45 50 close() - This is called on a terminal when the line 46 51 discipline is being unplugged. At the point of ··· 57 52 No further calls into the ldisc code will occur. 58 53 The return value is ignored. Can sleep. 59 54 60 - write() - A process is writing data through the line 61 - discipline. Multiple write calls are serialized 62 - by the tty layer for the ldisc. May sleep. 55 + read() - (optional) A process requests reading data from 56 + the line. Multiple read calls may occur in parallel 57 + and the ldisc must deal with serialization issues. 58 + If not defined, the process will receive an EIO 59 + error. May sleep. 60 + 61 + write() - (optional) A process requests writing data to the 62 + line. Multiple write calls are serialized by the 63 + tty layer for the ldisc. If not defined, the 64 + process will receive an EIO error. May sleep. 63 65 64 66 flush_buffer() - (optional) May be called at any point between 65 67 open and close, and instructs the line discipline ··· 81 69 termios semaphore so allowed to sleep. Serialized 82 70 against itself only. 83 71 84 - read() - Move data from the line discipline to the user. 85 - Multiple read calls may occur in parallel and the 86 - ldisc must deal with serialization issues. May 87 - sleep. 72 + poll() - (optional) Check the status for the poll/select 73 + calls. Multiple poll calls may occur in parallel. 74 + May sleep. 88 75 89 - poll() - Check the status for the poll/select calls. Multiple 90 - poll calls may occur in parallel. May sleep. 76 + ioctl() - (optional) Called when an ioctl is handed to the 77 + tty layer that might be for the ldisc. Multiple 78 + ioctl calls may occur in parallel. May sleep. 91 79 92 - ioctl() - Called when an ioctl is handed to the tty layer 93 - that might be for the ldisc. Multiple ioctl calls 94 - may occur in parallel. May sleep. 95 - 96 - compat_ioctl() - Called when a 32 bit ioctl is handed to the tty layer 97 - that might be for the ldisc. Multiple ioctl calls 98 - may occur in parallel. May sleep. 80 + compat_ioctl() - (optional) Called when a 32 bit ioctl is handed 81 + to the tty layer that might be for the ldisc. 82 + Multiple ioctl calls may occur in parallel. 83 + May sleep. 99 84 100 85 Driver Side Interfaces: 101 86 102 - receive_buf() - Hand buffers of bytes from the driver to the ldisc 103 - for processing. Semantics currently rather 104 - mysterious 8( 87 + receive_buf() - (optional) Called by the low-level driver to hand 88 + a buffer of received bytes to the ldisc for 89 + processing. The number of bytes is guaranteed not 90 + to exceed the current value of tty->receive_room. 91 + All bytes must be processed. 92 + 93 + receive_buf2() - (optional) Called by the low-level driver to hand 94 + a buffer of received bytes to the ldisc for 95 + processing. Returns the number of bytes processed. 96 + 97 + If both receive_buf() and receive_buf2() are 98 + defined, receive_buf2() should be preferred. 105 99 106 100 write_wakeup() - May be called at any point between open and close. 107 101 The TTY_DO_WRITE_WAKEUP flag indicates if a call