Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tty: remove TTY_MAGIC

According to Greg, in the context of magic numbers as defined in
magic-number.rst, "the tty layer should not need this and I'll gladly
take patches"

Acked-by: Jiri Slaby <jirislaby@kernel.org>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Ref: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
Link: https://lore.kernel.org/r/476d024cd6b04160a5de381ea2b9856b60088cbd.1663288066.git.nabijaczleweli@nabijaczleweli.xyz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

наб and committed by
Greg Kroah-Hartman
7a4e0d2c 1d5859ef

-24
-1
Documentation/process/magic-number.rst
··· 84 84 STRIP_MAGIC 0x5303 strip ``drivers/net/strip.c`` 85 85 SIXPACK_MAGIC 0x5304 sixpack ``drivers/net/hamradio/6pack.h`` 86 86 AX25_MAGIC 0x5316 ax_disp ``drivers/net/mkiss.h`` 87 - TTY_MAGIC 0x5401 tty_struct ``include/linux/tty.h`` 88 87 MGSL_MAGIC 0x5401 mgsl_info ``drivers/char/synclink.c`` 89 88 TTY_DRIVER_MAGIC 0x5402 tty_driver ``include/linux/tty_driver.h`` 90 89 MGSLPC_MAGIC 0x5402 mgslpc_info ``drivers/char/pcmcia/synclink_cs.c``
-1
Documentation/translations/it_IT/process/magic-number.rst
··· 90 90 STRIP_MAGIC 0x5303 strip ``drivers/net/strip.c`` 91 91 SIXPACK_MAGIC 0x5304 sixpack ``drivers/net/hamradio/6pack.h`` 92 92 AX25_MAGIC 0x5316 ax_disp ``drivers/net/mkiss.h`` 93 - TTY_MAGIC 0x5401 tty_struct ``include/linux/tty.h`` 94 93 MGSL_MAGIC 0x5401 mgsl_info ``drivers/char/synclink.c`` 95 94 TTY_DRIVER_MAGIC 0x5402 tty_driver ``include/linux/tty_driver.h`` 96 95 MGSLPC_MAGIC 0x5402 mgslpc_info ``drivers/char/pcmcia/synclink_cs.c``
-1
Documentation/translations/zh_CN/process/magic-number.rst
··· 73 73 STRIP_MAGIC 0x5303 strip ``drivers/net/strip.c`` 74 74 SIXPACK_MAGIC 0x5304 sixpack ``drivers/net/hamradio/6pack.h`` 75 75 AX25_MAGIC 0x5316 ax_disp ``drivers/net/mkiss.h`` 76 - TTY_MAGIC 0x5401 tty_struct ``include/linux/tty.h`` 77 76 MGSL_MAGIC 0x5401 mgsl_info ``drivers/char/synclink.c`` 78 77 TTY_DRIVER_MAGIC 0x5402 tty_driver ``include/linux/tty_driver.h`` 79 78 MGSLPC_MAGIC 0x5402 mgslpc_info ``drivers/char/pcmcia/synclink_cs.c``
-1
Documentation/translations/zh_TW/process/magic-number.rst
··· 76 76 STRIP_MAGIC 0x5303 strip ``drivers/net/strip.c`` 77 77 SIXPACK_MAGIC 0x5304 sixpack ``drivers/net/hamradio/6pack.h`` 78 78 AX25_MAGIC 0x5316 ax_disp ``drivers/net/mkiss.h`` 79 - TTY_MAGIC 0x5401 tty_struct ``include/linux/tty.h`` 80 79 MGSL_MAGIC 0x5401 mgsl_info ``drivers/char/synclink.c`` 81 80 TTY_DRIVER_MAGIC 0x5402 tty_driver ``include/linux/tty_driver.h`` 82 81 MGSLPC_MAGIC 0x5402 mgslpc_info ``drivers/char/pcmcia/synclink_cs.c``
-8
drivers/tty/tty_io.c
··· 170 170 tty_ldisc_deinit(tty); 171 171 put_device(tty->dev); 172 172 kvfree(tty->write_buf); 173 - tty->magic = 0xDEADDEAD; 174 173 kfree(tty); 175 174 } 176 175 ··· 261 262 #ifdef TTY_PARANOIA_CHECK 262 263 if (!tty) { 263 264 pr_warn("(%d:%d): %s: NULL tty\n", 264 - imajor(inode), iminor(inode), routine); 265 - return 1; 266 - } 267 - if (tty->magic != TTY_MAGIC) { 268 - pr_warn("(%d:%d): %s: bad magic number\n", 269 265 imajor(inode), iminor(inode), routine); 270 266 return 1; 271 267 } ··· 1527 1533 if (tty->ops->cleanup) 1528 1534 tty->ops->cleanup(tty); 1529 1535 1530 - tty->magic = 0; 1531 1536 tty_driver_kref_put(driver); 1532 1537 module_put(owner); 1533 1538 ··· 3086 3093 return NULL; 3087 3094 3088 3095 kref_init(&tty->kref); 3089 - tty->magic = TTY_MAGIC; 3090 3096 if (tty_ldisc_init(tty)) { 3091 3097 kfree(tty); 3092 3098 return NULL;
-6
drivers/tty/tty_mutex.c
··· 14 14 15 15 void tty_lock(struct tty_struct *tty) 16 16 { 17 - if (WARN(tty->magic != TTY_MAGIC, "L Bad %p\n", tty)) 18 - return; 19 17 tty_kref_get(tty); 20 18 mutex_lock(&tty->legacy_mutex); 21 19 } ··· 23 25 { 24 26 int ret; 25 27 26 - if (WARN(tty->magic != TTY_MAGIC, "L Bad %p\n", tty)) 27 - return -EIO; 28 28 tty_kref_get(tty); 29 29 ret = mutex_lock_interruptible(&tty->legacy_mutex); 30 30 if (ret) ··· 32 36 33 37 void tty_unlock(struct tty_struct *tty) 34 38 { 35 - if (WARN(tty->magic != TTY_MAGIC, "U Bad %p\n", tty)) 36 - return; 37 39 mutex_unlock(&tty->legacy_mutex); 38 40 tty_kref_put(tty); 39 41 }
-6
include/linux/tty.h
··· 122 122 /** 123 123 * struct tty_struct - state associated with a tty while open 124 124 * 125 - * @magic: magic value set early in @alloc_tty_struct to %TTY_MAGIC, for 126 - * debugging purposes 127 125 * @kref: reference counting by tty_kref_get() and tty_kref_put(), reaching zero 128 126 * frees the structure 129 127 * @dev: class device or %NULL (e.g. ptys, serdev) ··· 191 193 * &struct tty_port. 192 194 */ 193 195 struct tty_struct { 194 - int magic; 195 196 struct kref kref; 196 197 struct device *dev; 197 198 struct tty_driver *driver; ··· 256 259 struct file *file; 257 260 struct list_head list; 258 261 }; 259 - 260 - /* tty magic number */ 261 - #define TTY_MAGIC 0x5401 262 262 263 263 /** 264 264 * DOC: TTY Struct Flags