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

Configure Feed

Select the types of activity you want to include in your feed.

tty: convert "TTY Struct Flags" to an enum

Convert TTY_* macros (flags) to an enum. This allows for easier
kernel-doc (the comment needed fine tuning), grouping of these nicely,
and proper checking.

Note that these are bit positions. So they are used such as
test_bit(TTY_THROTTLED, ...). Given these are not the user API (only
in-kernel API/ABI), the bit positions are NOT preserved in this patch.
All are renumbered naturally using the enum-auto-numbering.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20250317070046.24386-2-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
a72f4187 d2fa8e52

+28 -26
+1 -1
Documentation/driver-api/tty/tty_struct.rst
··· 72 72 ================ 73 73 74 74 .. kernel-doc:: include/linux/tty.h 75 - :doc: TTY Struct Flags 75 + :identifiers: tty_struct_flags 76 76 77 77 TTY Struct Reference 78 78 ====================
+27 -25
include/linux/tty.h
··· 251 251 }; 252 252 253 253 /** 254 - * DOC: TTY Struct Flags 254 + * enum tty_struct_flags - TTY Struct Flags 255 255 * 256 256 * These bits are used in the :c:member:`tty_struct.flags` field. 257 257 * ··· 260 260 * tty->write. Thus, you must use the inline functions set_bit() and 261 261 * clear_bit() to make things atomic. 262 262 * 263 - * TTY_THROTTLED 263 + * @TTY_THROTTLED: 264 264 * Driver input is throttled. The ldisc should call 265 265 * :c:member:`tty_driver.unthrottle()` in order to resume reception when 266 266 * it is ready to process more data (at threshold min). 267 267 * 268 - * TTY_IO_ERROR 268 + * @TTY_IO_ERROR: 269 269 * If set, causes all subsequent userspace read/write calls on the tty to 270 270 * fail, returning -%EIO. (May be no ldisc too.) 271 271 * 272 - * TTY_OTHER_CLOSED 272 + * @TTY_OTHER_CLOSED: 273 273 * Device is a pty and the other side has closed. 274 274 * 275 - * TTY_EXCLUSIVE 275 + * @TTY_EXCLUSIVE: 276 276 * Exclusive open mode (a single opener). 277 277 * 278 - * TTY_DO_WRITE_WAKEUP 278 + * @TTY_DO_WRITE_WAKEUP: 279 279 * If set, causes the driver to call the 280 280 * :c:member:`tty_ldisc_ops.write_wakeup()` method in order to resume 281 281 * transmission when it can accept more data to transmit. 282 282 * 283 - * TTY_LDISC_OPEN 283 + * @TTY_LDISC_OPEN: 284 284 * Indicates that a line discipline is open. For debugging purposes only. 285 285 * 286 - * TTY_PTY_LOCK 286 + * @TTY_PTY_LOCK: 287 287 * A flag private to pty code to implement %TIOCSPTLCK/%TIOCGPTLCK logic. 288 288 * 289 - * TTY_NO_WRITE_SPLIT 289 + * @TTY_NO_WRITE_SPLIT: 290 290 * Prevent driver from splitting up writes into smaller chunks (preserve 291 291 * write boundaries to driver). 292 292 * 293 - * TTY_HUPPED 293 + * @TTY_HUPPED: 294 294 * The TTY was hung up. This is set post :c:member:`tty_driver.hangup()`. 295 295 * 296 - * TTY_HUPPING 296 + * @TTY_HUPPING: 297 297 * The TTY is in the process of hanging up to abort potential readers. 298 298 * 299 - * TTY_LDISC_CHANGING 299 + * @TTY_LDISC_CHANGING: 300 300 * Line discipline for this TTY is being changed. I/O should not block 301 301 * when this is set. Use tty_io_nonblock() to check. 302 302 * 303 - * TTY_LDISC_HALTED 303 + * @TTY_LDISC_HALTED: 304 304 * Line discipline for this TTY was stopped. No work should be queued to 305 305 * this ldisc. 306 306 */ 307 - #define TTY_THROTTLED 0 308 - #define TTY_IO_ERROR 1 309 - #define TTY_OTHER_CLOSED 2 310 - #define TTY_EXCLUSIVE 3 311 - #define TTY_DO_WRITE_WAKEUP 5 312 - #define TTY_LDISC_OPEN 11 313 - #define TTY_PTY_LOCK 16 314 - #define TTY_NO_WRITE_SPLIT 17 315 - #define TTY_HUPPED 18 316 - #define TTY_HUPPING 19 317 - #define TTY_LDISC_CHANGING 20 318 - #define TTY_LDISC_HALTED 22 307 + enum tty_struct_flags { 308 + TTY_THROTTLED, 309 + TTY_IO_ERROR, 310 + TTY_OTHER_CLOSED, 311 + TTY_EXCLUSIVE, 312 + TTY_DO_WRITE_WAKEUP, 313 + TTY_LDISC_OPEN, 314 + TTY_PTY_LOCK, 315 + TTY_NO_WRITE_SPLIT, 316 + TTY_HUPPED, 317 + TTY_HUPPING, 318 + TTY_LDISC_CHANGING, 319 + TTY_LDISC_HALTED, 320 + }; 319 321 320 322 static inline bool tty_io_nonblock(struct tty_struct *tty, struct file *file) 321 323 {