public inbox for linux-serial@vger.kernel.org
 help / color / mirror / Atom feed
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 v2 13/31] tty: tty_driver: convert "TTY Driver Flags" to an enum
Date: Mon, 17 Mar 2025 08:00:28 +0100	[thread overview]
Message-ID: <20250317070046.24386-14-jirislaby@kernel.org> (raw)
In-Reply-To: <20250317070046.24386-1-jirislaby@kernel.org>

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

Given these are flags, define them using modern BIT() instead of hex
constants.

It turns out (thanks, kernel-doc checker) that internal
TTY_DRIVER_INSTALLED was undocumented. Fix that too.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
 Documentation/driver-api/tty/tty_driver.rst |  2 +-
 include/linux/tty_driver.h                  | 40 ++++++++++++---------
 2 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/Documentation/driver-api/tty/tty_driver.rst b/Documentation/driver-api/tty/tty_driver.rst
index cc529f863406..f6cbffdb6e01 100644
--- a/Documentation/driver-api/tty/tty_driver.rst
+++ b/Documentation/driver-api/tty/tty_driver.rst
@@ -35,7 +35,7 @@ Here comes the documentation of flags accepted by tty_alloc_driver() (or
 __tty_alloc_driver()):
 
 .. kernel-doc:: include/linux/tty_driver.h
-   :doc: TTY Driver Flags
+   :identifiers: tty_driver_flag
 
 ----
 
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index f3be6d56e9e5..d0d940236580 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -17,13 +17,19 @@ struct serial_icounter_struct;
 struct serial_struct;
 
 /**
- * DOC: TTY Driver Flags
+ * enum tty_driver_flag -- TTY Driver Flags
  *
- * TTY_DRIVER_RESET_TERMIOS
+ * These are flags passed to tty_alloc_driver().
+ *
+ * @TTY_DRIVER_INSTALLED:
+ *	Whether this driver was succesfully installed. This is a tty internal
+ *	flag. Do not touch.
+ *
+ * @TTY_DRIVER_RESET_TERMIOS:
  *	Requests the tty layer to reset the termios setting when the last
  *	process has closed the device. Used for PTYs, in particular.
  *
- * TTY_DRIVER_REAL_RAW
+ * @TTY_DRIVER_REAL_RAW:
  *	Indicates that the driver will guarantee not to set any special
  *	character handling flags if this is set for the tty:
  *
@@ -35,7 +41,7 @@ struct serial_struct;
  *	this case if this flag is set.  (Note that there is also a promise, if
  *	the above case is true, not to signal overruns, either.)
  *
- * TTY_DRIVER_DYNAMIC_DEV
+ * @TTY_DRIVER_DYNAMIC_DEV:
  *	The individual tty devices need to be registered with a call to
  *	tty_register_device() when the device is found in the system and
  *	unregistered with a call to tty_unregister_device() so the devices will
@@ -45,33 +51,35 @@ struct serial_struct;
  *	appear and disappear while the main tty driver is registered with the
  *	tty core.
  *
- * TTY_DRIVER_DEVPTS_MEM
+ * @TTY_DRIVER_DEVPTS_MEM:
  *	Don't use the standard arrays (&tty_driver.ttys and
  *	&tty_driver.termios), instead use dynamic memory keyed through the
  *	devpts filesystem. This is only applicable to the PTY driver.
  *
- * TTY_DRIVER_HARDWARE_BREAK
+ * @TTY_DRIVER_HARDWARE_BREAK:
  *	Hardware handles break signals. Pass the requested timeout to the
  *	&tty_operations.break_ctl instead of using a simple on/off interface.
  *
- * TTY_DRIVER_DYNAMIC_ALLOC
+ * @TTY_DRIVER_DYNAMIC_ALLOC:
  *	Do not allocate structures which are needed per line for this driver
  *	(&tty_driver.ports) as it would waste memory. The driver will take
  *	care. This is only applicable to the PTY driver.
  *
- * TTY_DRIVER_UNNUMBERED_NODE
+ * @TTY_DRIVER_UNNUMBERED_NODE:
  *	Do not create numbered ``/dev`` nodes. For example, create
  *	``/dev/ttyprintk`` and not ``/dev/ttyprintk0``. Applicable only when a
  *	driver for a single tty device is being allocated.
  */
-#define TTY_DRIVER_INSTALLED		0x0001
-#define TTY_DRIVER_RESET_TERMIOS	0x0002
-#define TTY_DRIVER_REAL_RAW		0x0004
-#define TTY_DRIVER_DYNAMIC_DEV		0x0008
-#define TTY_DRIVER_DEVPTS_MEM		0x0010
-#define TTY_DRIVER_HARDWARE_BREAK	0x0020
-#define TTY_DRIVER_DYNAMIC_ALLOC	0x0040
-#define TTY_DRIVER_UNNUMBERED_NODE	0x0080
+enum tty_driver_flag {
+	TTY_DRIVER_INSTALLED		= BIT(0),
+	TTY_DRIVER_RESET_TERMIOS	= BIT(1),
+	TTY_DRIVER_REAL_RAW		= BIT(2),
+	TTY_DRIVER_DYNAMIC_DEV		= BIT(3),
+	TTY_DRIVER_DEVPTS_MEM		= BIT(4),
+	TTY_DRIVER_HARDWARE_BREAK	= BIT(5),
+	TTY_DRIVER_DYNAMIC_ALLOC	= BIT(6),
+	TTY_DRIVER_UNNUMBERED_NODE	= BIT(7),
+};
 
 /* tty driver types */
 #define TTY_DRIVER_TYPE_SYSTEM		0x0001
-- 
2.49.0


  parent reply	other threads:[~2025-03-17  7:01 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-17  7:00 [PATCH v2 00/31] tty: cleanup no. 99 Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 01/31] tty: convert "TTY Struct Flags" to an enum Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 02/31] tty: audit: do not use N_TTY_BUF_SIZE Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 03/31] tty: caif: " Jiri Slaby (SUSE)
2025-03-20 11:17   ` Simon Horman
2025-03-17  7:00 ` [PATCH v2 04/31] tty: move N_TTY_BUF_SIZE to n_tty Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 05/31] tty: n_tty: use uint for space returned by tty_write_room() Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 06/31] tty: n_tty: simplify process_output() Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 07/31] tty: n_tty: clean up process_output_block() Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 08/31] tty: n_tty: drop n_tty_trace() Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 09/31] tty: n_tty: extract n_tty_continue_cookie() from n_tty_read() Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 10/31] tty: n_tty: extract n_tty_wait_for_input() Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 11/31] tty: n_tty: move more_to_be_read to the end of n_tty_read() Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 12/31] tty: tty_driver: move TTY macros to the top Jiri Slaby (SUSE)
2025-03-17  7:00 ` Jiri Slaby (SUSE) [this message]
2025-03-17  7:00 ` [PATCH v2 14/31] tty: tty_driver: document both {,__}tty_alloc_driver() properly Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 15/31] tty: tty_driver: introduce TTY driver sub/types enums Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 16/31] tty: serdev: drop serdev_controller_ops::write_room() Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 17/31] tty: mmc: sdio: use bool for cts and remove parentheses Jiri Slaby (SUSE)
2025-03-17 10:50   ` Ulf Hansson
2025-03-17  7:00 ` [PATCH v2 18/31] tty: moxa: drop version dump to logs Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 19/31] tty: moxa: drop ISA support Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 20/31] tty: moxa: carve out special ioctls and extra tty_port Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 21/31] tty: srmcons: fix retval from srmcons_init() Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 22/31] tty: staging/greybus: pass tty_driver flags to tty_alloc_driver() Jiri Slaby (SUSE)
2025-03-17 12:35   ` Alex Elder
2025-03-17  7:00 ` [PATCH v2 23/31] tty: sunsu: drop serial_{in,out}p() Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 24/31] tty: sunsu: remove unused serial_icr_read() Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 25/31] serial: remove redundant tty_port_link_device() Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 26/31] serial: pass struct uart_state to uart_line_info() Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 27/31] serial: 8250: use serial_port_in/out() helpers Jiri Slaby (SUSE)
2025-03-17  7:25   ` Andy Shevchenko
2025-03-17  7:42     ` Jiri Slaby
2025-03-17  7:00 ` [PATCH v2 28/31] serial: 8250_rsa: simplify rsa8250_{request/release}_resource() Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 29/31] serial: 8250_port: do not use goto for UPQ_NO_TXEN_TEST code flow Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 30/31] serial: 8250_port: simplify serial8250_request_std_resource() Jiri Slaby (SUSE)
2025-03-17  7:00 ` [PATCH v2 31/31] serial: switch change_irq and change_port to bool in uart_set_info() Jiri Slaby (SUSE)
2025-03-17  7:03 ` [PATCH v2 00/31] tty: cleanup no. 99 Jiri Slaby

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=20250317070046.24386-14-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