]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tty: tty_driver: convert "TTY Driver Flags" to an enum
authorJiri Slaby (SUSE) <jirislaby@kernel.org>
Mon, 17 Mar 2025 07:00:28 +0000 (08:00 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 20 Mar 2025 15:00:51 +0000 (08:00 -0700)
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>
Link: https://lore.kernel.org/r/20250317070046.24386-14-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Documentation/driver-api/tty/tty_driver.rst
include/linux/tty_driver.h

index cc529f863406079afdbc7d2db931a0e487dc513f..f6cbffdb6e011501f7ec69665b5d08fe67a45d28 100644 (file)
@@ -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
 
 ----
 
index f3be6d56e9e535b659c56307a5ffdd349c821e64..d0d9402365807c009f01b4f0a071eec3f364f991 100644 (file)
@@ -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