From: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
To: gregkh@linuxfoundation.org
Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
"Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Subject: [PATCH 01/29] tty: convert "TTY Struct Flags" to an enum
Date: Thu, 20 Feb 2025 12:15:38 +0100 [thread overview]
Message-ID: <20250220111606.138045-2-jirislaby@kernel.org> (raw)
In-Reply-To: <20250220111606.138045-1-jirislaby@kernel.org>
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>
---
Documentation/driver-api/tty/tty_struct.rst | 2 +-
include/linux/tty.h | 52 +++++++++++----------
2 files changed, 28 insertions(+), 26 deletions(-)
diff --git a/Documentation/driver-api/tty/tty_struct.rst b/Documentation/driver-api/tty/tty_struct.rst
index c72f5a4293b2..29caf1c1ca5f 100644
--- a/Documentation/driver-api/tty/tty_struct.rst
+++ b/Documentation/driver-api/tty/tty_struct.rst
@@ -72,7 +72,7 @@ TTY Struct Flags
================
.. kernel-doc:: include/linux/tty.h
- :doc: TTY Struct Flags
+ :identifiers: tty_struct_flags
TTY Struct Reference
====================
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 2372f9357240..6bb4fb3845f0 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -251,7 +251,7 @@ struct tty_file_private {
};
/**
- * DOC: TTY Struct Flags
+ * enum tty_struct_flags - TTY Struct Flags
*
* These bits are used in the :c:member:`tty_struct.flags` field.
*
@@ -260,62 +260,64 @@ struct tty_file_private {
* tty->write. Thus, you must use the inline functions set_bit() and
* clear_bit() to make things atomic.
*
- * TTY_THROTTLED
+ * @TTY_THROTTLED:
* Driver input is throttled. The ldisc should call
* :c:member:`tty_driver.unthrottle()` in order to resume reception when
* it is ready to process more data (at threshold min).
*
- * TTY_IO_ERROR
+ * @TTY_IO_ERROR:
* If set, causes all subsequent userspace read/write calls on the tty to
* fail, returning -%EIO. (May be no ldisc too.)
*
- * TTY_OTHER_CLOSED
+ * @TTY_OTHER_CLOSED:
* Device is a pty and the other side has closed.
*
- * TTY_EXCLUSIVE
+ * @TTY_EXCLUSIVE:
* Exclusive open mode (a single opener).
*
- * TTY_DO_WRITE_WAKEUP
+ * @TTY_DO_WRITE_WAKEUP:
* If set, causes the driver to call the
* :c:member:`tty_ldisc_ops.write_wakeup()` method in order to resume
* transmission when it can accept more data to transmit.
*
- * TTY_LDISC_OPEN
+ * @TTY_LDISC_OPEN:
* Indicates that a line discipline is open. For debugging purposes only.
*
- * TTY_PTY_LOCK
+ * @TTY_PTY_LOCK:
* A flag private to pty code to implement %TIOCSPTLCK/%TIOCGPTLCK logic.
*
- * TTY_NO_WRITE_SPLIT
+ * @TTY_NO_WRITE_SPLIT:
* Prevent driver from splitting up writes into smaller chunks (preserve
* write boundaries to driver).
*
- * TTY_HUPPED
+ * @TTY_HUPPED:
* The TTY was hung up. This is set post :c:member:`tty_driver.hangup()`.
*
- * TTY_HUPPING
+ * @TTY_HUPPING:
* The TTY is in the process of hanging up to abort potential readers.
*
- * TTY_LDISC_CHANGING
+ * @TTY_LDISC_CHANGING:
* Line discipline for this TTY is being changed. I/O should not block
* when this is set. Use tty_io_nonblock() to check.
*
- * TTY_LDISC_HALTED
+ * @TTY_LDISC_HALTED:
* Line discipline for this TTY was stopped. No work should be queued to
* this ldisc.
*/
-#define TTY_THROTTLED 0
-#define TTY_IO_ERROR 1
-#define TTY_OTHER_CLOSED 2
-#define TTY_EXCLUSIVE 3
-#define TTY_DO_WRITE_WAKEUP 5
-#define TTY_LDISC_OPEN 11
-#define TTY_PTY_LOCK 16
-#define TTY_NO_WRITE_SPLIT 17
-#define TTY_HUPPED 18
-#define TTY_HUPPING 19
-#define TTY_LDISC_CHANGING 20
-#define TTY_LDISC_HALTED 22
+enum tty_struct_flags {
+ TTY_THROTTLED,
+ TTY_IO_ERROR,
+ TTY_OTHER_CLOSED,
+ TTY_EXCLUSIVE,
+ TTY_DO_WRITE_WAKEUP,
+ TTY_LDISC_OPEN,
+ TTY_PTY_LOCK,
+ TTY_NO_WRITE_SPLIT,
+ TTY_HUPPED,
+ TTY_HUPPING,
+ TTY_LDISC_CHANGING,
+ TTY_LDISC_HALTED,
+};
static inline bool tty_io_nonblock(struct tty_struct *tty, struct file *file)
{
--
2.48.1
next prev parent reply other threads:[~2025-02-20 11:16 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-20 11:15 [PATCH 00/29] tty: cleanup no. 99 Jiri Slaby (SUSE)
2025-02-20 11:15 ` Jiri Slaby (SUSE) [this message]
2025-02-20 11:15 ` [PATCH 02/29] tty: audit: do not use N_TTY_BUF_SIZE Jiri Slaby (SUSE)
2025-02-20 11:15 ` [PATCH 03/29] tty: caif: " Jiri Slaby (SUSE)
2025-02-20 14:27 ` Jakub Kicinski
2025-02-20 11:15 ` [PATCH 04/29] tty: move N_TTY_BUF_SIZE to n_tty Jiri Slaby (SUSE)
2025-02-20 11:15 ` [PATCH 05/29] tty: n_tty: use uint for space returned by tty_write_room() Jiri Slaby (SUSE)
2025-02-20 11:15 ` [PATCH 06/29] tty: n_tty: simplify process_output() Jiri Slaby (SUSE)
2025-02-20 11:15 ` [PATCH 07/29] tty: n_tty: clean up process_output_block() Jiri Slaby (SUSE)
2025-02-20 11:15 ` [PATCH 08/29] tty: n_tty: drop n_tty_trace() Jiri Slaby (SUSE)
2025-02-20 11:15 ` [PATCH 09/29] tty: n_tty: extract n_tty_continue_cookie() from n_tty_read() Jiri Slaby (SUSE)
2025-02-20 11:15 ` [PATCH 10/29] tty: n_tty: extract n_tty_wait_for_input() Jiri Slaby (SUSE)
2025-02-20 11:15 ` [PATCH 11/29] tty: n_tty: move more_to_be_read to the end of n_tty_read() Jiri Slaby (SUSE)
2025-02-20 11:15 ` [PATCH 12/29] tty: tty_driver: move TTY macros to the top Jiri Slaby (SUSE)
2025-02-20 11:15 ` [PATCH 13/29] tty: tty_driver: convert "TTY Driver Flags" to an enum Jiri Slaby (SUSE)
2025-02-20 11:15 ` [PATCH 14/29] tty: tty_driver: document both {,__}tty_alloc_driver() properly Jiri Slaby (SUSE)
2025-02-20 11:15 ` [PATCH 15/29] tty: tty_driver: introduce TTY driver sub/types enums Jiri Slaby (SUSE)
2025-02-20 11:15 ` [PATCH 16/29] tty: serdev: drop serdev_controller_ops::write_room() Jiri Slaby (SUSE)
2025-02-20 11:15 ` [PATCH 17/29] tty: moxa: drop version dump to logs Jiri Slaby (SUSE)
2025-02-20 11:15 ` [PATCH 18/29] tty: moxa: drop ISA support Jiri Slaby (SUSE)
2025-02-20 11:15 ` [PATCH 19/29] tty: moxa: carve out special ioctls and extra tty_port Jiri Slaby (SUSE)
2025-02-20 11:15 ` [PATCH 20/29] tty: srmcons: fix retval from srmcons_init() Jiri Slaby (SUSE)
2025-02-20 21:48 ` Magnus Lindholm
2025-02-21 7:53 ` Jiri Slaby
2025-02-20 11:15 ` [PATCH 21/29] tty: staging/greybus: pass tty_driver flags to tty_alloc_driver() Jiri Slaby (SUSE)
2025-02-21 12:25 ` Johan Hovold
2025-02-20 11:15 ` [PATCH 22/29] tty: sunsu: drop serial_{in,out}p() Jiri Slaby (SUSE)
2025-02-20 11:16 ` [PATCH 23/29] tty: sunsu: remove unused serial_icr_read() Jiri Slaby (SUSE)
2025-02-20 11:16 ` [PATCH 24/29] serial: remove redundant tty_port_link_device() Jiri Slaby (SUSE)
2025-02-20 11:16 ` [PATCH 25/29] serial: pass struct uart_state to uart_line_info() Jiri Slaby (SUSE)
2025-02-20 11:16 ` [PATCH 26/29] serial: 8250: use serial_in/out() helpers Jiri Slaby (SUSE)
2025-02-20 12:27 ` Andy Shevchenko
2025-02-20 14:39 ` Greg KH
2025-02-20 14:57 ` Andy Shevchenko
2025-02-20 15:27 ` Andy Shevchenko
2025-02-20 15:23 ` Andy Shevchenko
2025-02-21 10:07 ` Jiri Slaby
2025-02-20 11:16 ` [PATCH 27/29] serial: 8250_rsa: simplify rsa8250_{request/release}_resource() Jiri Slaby (SUSE)
2025-02-20 11:16 ` [PATCH 28/29] serial: 8250_port: do not use goto for UPQ_NO_TXEN_TEST code flow Jiri Slaby (SUSE)
2025-02-20 11:16 ` [PATCH 29/29] serial: 8250_port: simplify serial8250_request_std_resource() Jiri Slaby (SUSE)
2025-03-17 4:28 ` [PATCH 00/29] tty: cleanup no. 99 Greg KH
2025-03-17 4:59 ` Jiri Slaby
2025-03-17 7:00 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250220111606.138045-2-jirislaby@kernel.org \
--to=jirislaby@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).