Skip to content

Commit a72f418

Browse files
Jiri Slaby (SUSE)gregkh
authored andcommitted
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) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d2fa8e5 commit a72f418

File tree

2 files changed

+28
-26
lines changed

2 files changed

+28
-26
lines changed

Documentation/driver-api/tty/tty_struct.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ TTY Struct Flags
7272
================
7373

7474
.. kernel-doc:: include/linux/tty.h
75-
:doc: TTY Struct Flags
75+
:identifiers: tty_struct_flags
7676

7777
TTY Struct Reference
7878
====================

include/linux/tty.h

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ struct tty_file_private {
251251
};
252252

253253
/**
254-
* DOC: TTY Struct Flags
254+
* enum tty_struct_flags - TTY Struct Flags
255255
*
256256
* These bits are used in the :c:member:`tty_struct.flags` field.
257257
*
@@ -260,62 +260,64 @@ struct tty_file_private {
260260
* tty->write. Thus, you must use the inline functions set_bit() and
261261
* clear_bit() to make things atomic.
262262
*
263-
* TTY_THROTTLED
263+
* @TTY_THROTTLED:
264264
* Driver input is throttled. The ldisc should call
265265
* :c:member:`tty_driver.unthrottle()` in order to resume reception when
266266
* it is ready to process more data (at threshold min).
267267
*
268-
* TTY_IO_ERROR
268+
* @TTY_IO_ERROR:
269269
* If set, causes all subsequent userspace read/write calls on the tty to
270270
* fail, returning -%EIO. (May be no ldisc too.)
271271
*
272-
* TTY_OTHER_CLOSED
272+
* @TTY_OTHER_CLOSED:
273273
* Device is a pty and the other side has closed.
274274
*
275-
* TTY_EXCLUSIVE
275+
* @TTY_EXCLUSIVE:
276276
* Exclusive open mode (a single opener).
277277
*
278-
* TTY_DO_WRITE_WAKEUP
278+
* @TTY_DO_WRITE_WAKEUP:
279279
* If set, causes the driver to call the
280280
* :c:member:`tty_ldisc_ops.write_wakeup()` method in order to resume
281281
* transmission when it can accept more data to transmit.
282282
*
283-
* TTY_LDISC_OPEN
283+
* @TTY_LDISC_OPEN:
284284
* Indicates that a line discipline is open. For debugging purposes only.
285285
*
286-
* TTY_PTY_LOCK
286+
* @TTY_PTY_LOCK:
287287
* A flag private to pty code to implement %TIOCSPTLCK/%TIOCGPTLCK logic.
288288
*
289-
* TTY_NO_WRITE_SPLIT
289+
* @TTY_NO_WRITE_SPLIT:
290290
* Prevent driver from splitting up writes into smaller chunks (preserve
291291
* write boundaries to driver).
292292
*
293-
* TTY_HUPPED
293+
* @TTY_HUPPED:
294294
* The TTY was hung up. This is set post :c:member:`tty_driver.hangup()`.
295295
*
296-
* TTY_HUPPING
296+
* @TTY_HUPPING:
297297
* The TTY is in the process of hanging up to abort potential readers.
298298
*
299-
* TTY_LDISC_CHANGING
299+
* @TTY_LDISC_CHANGING:
300300
* Line discipline for this TTY is being changed. I/O should not block
301301
* when this is set. Use tty_io_nonblock() to check.
302302
*
303-
* TTY_LDISC_HALTED
303+
* @TTY_LDISC_HALTED:
304304
* Line discipline for this TTY was stopped. No work should be queued to
305305
* this ldisc.
306306
*/
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+
};
319321

320322
static inline bool tty_io_nonblock(struct tty_struct *tty, struct file *file)
321323
{

0 commit comments

Comments
 (0)