]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tty: convert THROTTLE constants into enum
authorJiri Slaby (SUSE) <jirislaby@kernel.org>
Tue, 19 Sep 2023 08:51:53 +0000 (10:51 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 3 Oct 2023 12:31:16 +0000 (14:31 +0200)
And make an explicit constant for zero too. This allows for easier type
checking of the parameter.

Note: tty_struct::flow_change is kept as int because include/tty.h
(tty_struct) doesn't see tty/tty.h (this enum).

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230919085156.1578-13-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/tty.h
drivers/tty/tty_ioctl.c

index 50862f98273e3610a8fb3996dafb10cad8c7f90f..93cf5ef1e857ba6cb0936a613a7cce1361390bdd 100644 (file)
@@ -41,15 +41,20 @@ enum {
 };
 
 /* Values for tty->flow_change */
-#define TTY_THROTTLE_SAFE      1
-#define TTY_UNTHROTTLE_SAFE    2
+enum tty_flow_change {
+       TTY_FLOW_NO_CHANGE,
+       TTY_THROTTLE_SAFE,
+       TTY_UNTHROTTLE_SAFE,
+};
 
-static inline void __tty_set_flow_change(struct tty_struct *tty, int val)
+static inline void __tty_set_flow_change(struct tty_struct *tty,
+                                        enum tty_flow_change val)
 {
        tty->flow_change = val;
 }
 
-static inline void tty_set_flow_change(struct tty_struct *tty, int val)
+static inline void tty_set_flow_change(struct tty_struct *tty,
+                                      enum tty_flow_change val)
 {
        tty->flow_change = val;
        smp_mb();
index 42c793e9d1314b211e56f07492efdd80482486e6..4b499301a3db1d37cf6fee22507c5f5a843ca4d7 100644 (file)
@@ -104,7 +104,7 @@ void tty_unthrottle(struct tty_struct *tty)
        if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) &&
            tty->ops->unthrottle)
                tty->ops->unthrottle(tty);
-       tty->flow_change = 0;
+       tty->flow_change = TTY_FLOW_NO_CHANGE;
        up_write(&tty->termios_rwsem);
 }
 EXPORT_SYMBOL(tty_unthrottle);