86 lines · plain
1.. SPDX-License-Identifier: GPL-2.02 3===================4TTY Line Discipline5===================6 7.. contents:: :local:8 9TTY line discipline process all incoming and outgoing character from/to a tty10device. The default line discipline is :doc:`N_TTY <n_tty>`. It is also a11fallback if establishing any other discipline for a tty fails. If even N_TTY12fails, N_NULL takes over. That never fails, but also does not process any13characters -- it throws them away.14 15Registration16============17 18Line disciplines are registered with tty_register_ldisc() passing the ldisc19structure. At the point of registration the discipline must be ready to use and20it is possible it will get used before the call returns success. If the call21returns an error then it won’t get called. Do not re-use ldisc numbers as they22are part of the userspace ABI and writing over an existing ldisc will cause23demons to eat your computer. You must not re-register over the top of the line24discipline even with the same data or your computer again will be eaten by25demons. In order to remove a line discipline call tty_unregister_ldisc().26 27Heed this warning: the reference count field of the registered copies of the28tty_ldisc structure in the ldisc table counts the number of lines using this29discipline. The reference count of the tty_ldisc structure within a tty counts30the number of active users of the ldisc at this instant. In effect it counts31the number of threads of execution within an ldisc method (plus those about to32enter and exit although this detail matters not).33 34.. kernel-doc:: drivers/tty/tty_ldisc.c35 :identifiers: tty_register_ldisc tty_unregister_ldisc36 37Other Functions38===============39 40.. kernel-doc:: drivers/tty/tty_ldisc.c41 :identifiers: tty_set_ldisc tty_ldisc_flush42 43Line Discipline Operations Reference44====================================45 46.. kernel-doc:: include/linux/tty_ldisc.h47 :identifiers: tty_ldisc_ops48 49Driver Access50=============51 52Line discipline methods can call the methods of the underlying hardware driver.53These are documented as a part of struct tty_operations.54 55TTY Flags56=========57 58Line discipline methods have access to :c:member:`tty_struct.flags` field. See59:doc:`tty_struct`.60 61Locking62=======63 64Callers to the line discipline functions from the tty layer are required to65take line discipline locks. The same is true of calls from the driver side66but not yet enforced.67 68.. kernel-doc:: drivers/tty/tty_ldisc.c69 :identifiers: tty_ldisc_ref_wait tty_ldisc_ref tty_ldisc_deref70 71While these functions are slightly slower than the old code they should have72minimal impact as most receive logic uses the flip buffers and they only73need to take a reference when they push bits up through the driver.74 75A caution: The :c:member:`tty_ldisc_ops.open()`,76:c:member:`tty_ldisc_ops.close()` and :c:member:`tty_driver.set_ldisc()`77functions are called with the ldisc unavailable. Thus tty_ldisc_ref() will fail78in this situation if used within these functions. Ldisc and driver code79calling its own functions must be careful in this case.80 81Internal Functions82==================83 84.. kernel-doc:: drivers/tty/tty_ldisc.c85 :internal:86