All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] tty: remove TTY_MAGIC
@ 2022-09-16  1:54 наб
  2022-09-16  1:55 ` [PATCH 2/5] tty: remove TTY_DRIVER_MAGIC наб
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: наб @ 2022-09-16  1:54 UTC (permalink / raw)
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Greg Kroah-Hartman, Jiri Slaby, linux-doc, linux-kernel,
	linux-doc-tw-discuss

[-- Attachment #1: Type: text/plain, Size: 8069 bytes --]

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"

Ref: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
Whole series: amd64 allyesconfig builds; amd64 Debian config boots and
appears to work; naturally, the HVC stuff is S/390 only, but it's a
constant offset

 Documentation/process/magic-number.rst                    | 1 -
 Documentation/translations/it_IT/process/magic-number.rst | 1 -
 Documentation/translations/zh_CN/process/magic-number.rst | 1 -
 Documentation/translations/zh_TW/process/magic-number.rst | 1 -
 drivers/tty/tty_io.c                                      | 8 --------
 drivers/tty/tty_mutex.c                                   | 6 ------
 include/linux/tty.h                                       | 6 ------
 7 files changed, 24 deletions(-)

diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
index f5ba36e96461..b4c7ec61437e 100644
--- a/Documentation/process/magic-number.rst
+++ b/Documentation/process/magic-number.rst
@@ -84,7 +84,6 @@ SLIP_MAGIC            0x5302           slip                     ``drivers/net/sl
 STRIP_MAGIC           0x5303           strip                    ``drivers/net/strip.c``
 SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
 AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
-TTY_MAGIC             0x5401           tty_struct               ``include/linux/tty.h``
 MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
 TTY_DRIVER_MAGIC      0x5402           tty_driver               ``include/linux/tty_driver.h``
 MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
index f452fafb1e84..bcb23384fefd 100644
--- a/Documentation/translations/it_IT/process/magic-number.rst
+++ b/Documentation/translations/it_IT/process/magic-number.rst
@@ -90,7 +90,6 @@ SLIP_MAGIC            0x5302           slip                     ``drivers/net/sl
 STRIP_MAGIC           0x5303           strip                    ``drivers/net/strip.c``
 SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
 AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
-TTY_MAGIC             0x5401           tty_struct               ``include/linux/tty.h``
 MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
 TTY_DRIVER_MAGIC      0x5402           tty_driver               ``include/linux/tty_driver.h``
 MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
index 42f0635ca70a..6250087d36c5 100644
--- a/Documentation/translations/zh_CN/process/magic-number.rst
+++ b/Documentation/translations/zh_CN/process/magic-number.rst
@@ -73,7 +73,6 @@ SLIP_MAGIC            0x5302           slip                     ``drivers/net/sl
 STRIP_MAGIC           0x5303           strip                    ``drivers/net/strip.c``
 SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
 AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
-TTY_MAGIC             0x5401           tty_struct               ``include/linux/tty.h``
 MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
 TTY_DRIVER_MAGIC      0x5402           tty_driver               ``include/linux/tty_driver.h``
 MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
index ae321a9aaece..fd169d760bbd 100644
--- a/Documentation/translations/zh_TW/process/magic-number.rst
+++ b/Documentation/translations/zh_TW/process/magic-number.rst
@@ -76,7 +76,6 @@ SLIP_MAGIC            0x5302           slip                     ``drivers/net/sl
 STRIP_MAGIC           0x5303           strip                    ``drivers/net/strip.c``
 SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
 AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
-TTY_MAGIC             0x5401           tty_struct               ``include/linux/tty.h``
 MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
 TTY_DRIVER_MAGIC      0x5402           tty_driver               ``include/linux/tty_driver.h``
 MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 82a8855981f7..33962109bd10 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -170,7 +170,6 @@ static void free_tty_struct(struct tty_struct *tty)
 	tty_ldisc_deinit(tty);
 	put_device(tty->dev);
 	kvfree(tty->write_buf);
-	tty->magic = 0xDEADDEAD;
 	kfree(tty);
 }
 
@@ -265,11 +264,6 @@ static int tty_paranoia_check(struct tty_struct *tty, struct inode *inode,
 			imajor(inode), iminor(inode), routine);
 		return 1;
 	}
-	if (tty->magic != TTY_MAGIC) {
-		pr_warn("(%d:%d): %s: bad magic number\n",
-			imajor(inode), iminor(inode), routine);
-		return 1;
-	}
 #endif
 	return 0;
 }
@@ -1533,7 +1527,6 @@ static void release_one_tty(struct work_struct *work)
 	if (tty->ops->cleanup)
 		tty->ops->cleanup(tty);
 
-	tty->magic = 0;
 	tty_driver_kref_put(driver);
 	module_put(owner);
 
@@ -3093,7 +3086,6 @@ struct tty_struct *alloc_tty_struct(struct tty_driver *driver, int idx)
 		return NULL;
 
 	kref_init(&tty->kref);
-	tty->magic = TTY_MAGIC;
 	if (tty_ldisc_init(tty)) {
 		kfree(tty);
 		return NULL;
diff --git a/drivers/tty/tty_mutex.c b/drivers/tty/tty_mutex.c
index 393518a24cfe..784e46a0a3b1 100644
--- a/drivers/tty/tty_mutex.c
+++ b/drivers/tty/tty_mutex.c
@@ -14,8 +14,6 @@
 
 void tty_lock(struct tty_struct *tty)
 {
-	if (WARN(tty->magic != TTY_MAGIC, "L Bad %p\n", tty))
-		return;
 	tty_kref_get(tty);
 	mutex_lock(&tty->legacy_mutex);
 }
@@ -25,8 +23,6 @@ int tty_lock_interruptible(struct tty_struct *tty)
 {
 	int ret;
 
-	if (WARN(tty->magic != TTY_MAGIC, "L Bad %p\n", tty))
-		return -EIO;
 	tty_kref_get(tty);
 	ret = mutex_lock_interruptible(&tty->legacy_mutex);
 	if (ret)
@@ -36,8 +32,6 @@ int tty_lock_interruptible(struct tty_struct *tty)
 
 void tty_unlock(struct tty_struct *tty)
 {
-	if (WARN(tty->magic != TTY_MAGIC, "U Bad %p\n", tty))
-		return;
 	mutex_unlock(&tty->legacy_mutex);
 	tty_kref_put(tty);
 }
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 7b0a5d478ef6..ba65043e9029 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -122,8 +122,6 @@ struct tty_operations;
 /**
  * struct tty_struct - state associated with a tty while open
  *
- * @magic: magic value set early in @alloc_tty_struct to %TTY_MAGIC, for
- *	   debugging purposes
  * @kref: reference counting by tty_kref_get() and tty_kref_put(), reaching zero
  *	  frees the structure
  * @dev: class device or %NULL (e.g. ptys, serdev)
@@ -193,7 +191,6 @@ struct tty_operations;
  * &struct tty_port.
  */
 struct tty_struct {
-	int	magic;
 	struct kref kref;
 	struct device *dev;
 	struct tty_driver *driver;
@@ -260,9 +257,6 @@ struct tty_file_private {
 	struct list_head list;
 };
 
-/* tty magic number */
-#define TTY_MAGIC		0x5401
-
 /**
  * DOC: TTY Struct Flags
  *
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/5] tty: remove TTY_DRIVER_MAGIC
  2022-09-16  1:54 [PATCH 1/5] tty: remove TTY_MAGIC наб
@ 2022-09-16  1:55 ` наб
  2022-09-16  6:51   ` Jiri Slaby
  2022-09-16  1:55 ` [PATCH 3/5] tty: n_hdlc: remove HDLC_MAGIC наб
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: наб @ 2022-09-16  1:55 UTC (permalink / raw)
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Greg Kroah-Hartman, Jiri Slaby, linux-doc, linux-kernel,
	linux-doc-tw-discuss

[-- Attachment #1: Type: text/plain, Size: 6449 bytes --]

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"

Ref: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 Documentation/process/magic-number.rst                    | 1 -
 Documentation/translations/it_IT/process/magic-number.rst | 1 -
 Documentation/translations/zh_CN/process/magic-number.rst | 1 -
 Documentation/translations/zh_TW/process/magic-number.rst | 1 -
 drivers/tty/tty_io.c                                      | 1 -
 include/linux/tty_driver.h                                | 5 -----
 6 files changed, 10 deletions(-)

diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
index b4c7ec61437e..d47799ba0ca4 100644
--- a/Documentation/process/magic-number.rst
+++ b/Documentation/process/magic-number.rst
@@ -85,7 +85,6 @@ STRIP_MAGIC           0x5303           strip                    ``drivers/net/st
 SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
 AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
 MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
-TTY_DRIVER_MAGIC      0x5402           tty_driver               ``include/linux/tty_driver.h``
 MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
 USB_SERIAL_MAGIC      0x6702           usb_serial               ``drivers/usb/serial/usb-serial.h``
 FULL_DUPLEX_MAGIC     0x6969                                    ``drivers/net/ethernet/dec/tulip/de2104x.c``
diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
index bcb23384fefd..24022ab52ebb 100644
--- a/Documentation/translations/it_IT/process/magic-number.rst
+++ b/Documentation/translations/it_IT/process/magic-number.rst
@@ -91,7 +91,6 @@ STRIP_MAGIC           0x5303           strip                    ``drivers/net/st
 SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
 AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
 MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
-TTY_DRIVER_MAGIC      0x5402           tty_driver               ``include/linux/tty_driver.h``
 MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
 USB_SERIAL_MAGIC      0x6702           usb_serial               ``drivers/usb/serial/usb-serial.h``
 FULL_DUPLEX_MAGIC     0x6969                                    ``drivers/net/ethernet/dec/tulip/de2104x.c``
diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
index 6250087d36c5..811804996283 100644
--- a/Documentation/translations/zh_CN/process/magic-number.rst
+++ b/Documentation/translations/zh_CN/process/magic-number.rst
@@ -74,7 +74,6 @@ STRIP_MAGIC           0x5303           strip                    ``drivers/net/st
 SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
 AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
 MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
-TTY_DRIVER_MAGIC      0x5402           tty_driver               ``include/linux/tty_driver.h``
 MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
 USB_SERIAL_MAGIC      0x6702           usb_serial               ``drivers/usb/serial/usb-serial.h``
 FULL_DUPLEX_MAGIC     0x6969                                    ``drivers/net/ethernet/dec/tulip/de2104x.c``
diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
index fd169d760bbd..8e37e00590f5 100644
--- a/Documentation/translations/zh_TW/process/magic-number.rst
+++ b/Documentation/translations/zh_TW/process/magic-number.rst
@@ -77,7 +77,6 @@ STRIP_MAGIC           0x5303           strip                    ``drivers/net/st
 SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
 AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
 MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
-TTY_DRIVER_MAGIC      0x5402           tty_driver               ``include/linux/tty_driver.h``
 MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
 USB_SERIAL_MAGIC      0x6702           usb_serial               ``drivers/usb/serial/usb-serial.h``
 FULL_DUPLEX_MAGIC     0x6969                                    ``drivers/net/ethernet/dec/tulip/de2104x.c``
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 33962109bd10..d036fc59a2e8 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -3321,7 +3321,6 @@ struct tty_driver *__tty_alloc_driver(unsigned int lines, struct module *owner,
 		return ERR_PTR(-ENOMEM);
 
 	kref_init(&driver->kref);
-	driver->magic = TTY_DRIVER_MAGIC;
 	driver->num = lines;
 	driver->owner = owner;
 	driver->flags = flags;
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index 4841d8069c07..b0421f5de8a6 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -396,7 +396,6 @@ struct tty_operations {
 /**
  * struct tty_driver -- driver for TTY devices
  *
- * @magic: set to %TTY_DRIVER_MAGIC in __tty_alloc_driver()
  * @kref: reference counting. Reaching zero frees all the internals and the
  *	  driver.
  * @cdevs: allocated/registered character /dev devices
@@ -432,7 +431,6 @@ struct tty_operations {
  * @driver_name, @name, @type, @subtype, @init_termios, and @ops.
  */
 struct tty_driver {
-	int	magic;
 	struct kref kref;
 	struct cdev **cdevs;
 	struct module	*owner;
@@ -489,9 +487,6 @@ static inline void tty_set_operations(struct tty_driver *driver,
 	driver->ops = op;
 }
 
-/* tty driver magic number */
-#define TTY_DRIVER_MAGIC		0x5402
-
 /**
  * DOC: TTY Driver Flags
  *
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/5] tty: n_hdlc: remove HDLC_MAGIC
  2022-09-16  1:54 [PATCH 1/5] tty: remove TTY_MAGIC наб
  2022-09-16  1:55 ` [PATCH 2/5] tty: remove TTY_DRIVER_MAGIC наб
@ 2022-09-16  1:55 ` наб
  2022-09-16  6:51   ` Jiri Slaby
  2022-09-16  1:55 ` [PATCH 4/5] tty: synclink_gt: remove MGSL_MAGIC наб
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: наб @ 2022-09-16  1:55 UTC (permalink / raw)
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Greg Kroah-Hartman, Jiri Slaby, linux-doc, linux-kernel,
	linux-doc-tw-discuss

[-- Attachment #1: Type: text/plain, Size: 7596 bytes --]

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"

Ref: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 Documentation/process/magic-number.rst        |  1 -
 .../it_IT/process/magic-number.rst            |  1 -
 .../zh_CN/process/magic-number.rst            |  1 -
 .../zh_TW/process/magic-number.rst            |  1 -
 drivers/tty/n_hdlc.c                          | 27 -------------------
 5 files changed, 31 deletions(-)

diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
index d47799ba0ca4..fdaa3e4b1953 100644
--- a/Documentation/process/magic-number.rst
+++ b/Documentation/process/magic-number.rst
@@ -71,7 +71,6 @@ Magic Name            Number           Structure                File
 PG_MAGIC              'P'              pg_{read,write}_hdr      ``include/linux/pg.h``
 CMAGIC                0x0111           user                     ``include/linux/a.out.h``
 MKISS_DRIVER_MAGIC    0x04bf           mkiss_channel            ``drivers/net/mkiss.h``
-HDLC_MAGIC            0x239e           n_hdlc                   ``drivers/char/n_hdlc.c``
 APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kernel/apm_32.c``
 DB_MAGIC              0x4442           fc_info                  ``drivers/net/iph5526_novram.c``
 DL_MAGIC              0x444d           fc_info                  ``drivers/net/iph5526_novram.c``
diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
index 24022ab52ebb..1898f98875de 100644
--- a/Documentation/translations/it_IT/process/magic-number.rst
+++ b/Documentation/translations/it_IT/process/magic-number.rst
@@ -77,7 +77,6 @@ Nome magico           Numero           Struttura                File
 PG_MAGIC              'P'              pg_{read,write}_hdr      ``include/linux/pg.h``
 CMAGIC                0x0111           user                     ``include/linux/a.out.h``
 MKISS_DRIVER_MAGIC    0x04bf           mkiss_channel            ``drivers/net/mkiss.h``
-HDLC_MAGIC            0x239e           n_hdlc                   ``drivers/char/n_hdlc.c``
 APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kernel/apm_32.c``
 DB_MAGIC              0x4442           fc_info                  ``drivers/net/iph5526_novram.c``
 DL_MAGIC              0x444d           fc_info                  ``drivers/net/iph5526_novram.c``
diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
index 811804996283..911cdaeaf698 100644
--- a/Documentation/translations/zh_CN/process/magic-number.rst
+++ b/Documentation/translations/zh_CN/process/magic-number.rst
@@ -60,7 +60,6 @@ Linux 魔术数
 PG_MAGIC              'P'              pg_{read,write}_hdr      ``include/linux/pg.h``
 CMAGIC                0x0111           user                     ``include/linux/a.out.h``
 MKISS_DRIVER_MAGIC    0x04bf           mkiss_channel            ``drivers/net/mkiss.h``
-HDLC_MAGIC            0x239e           n_hdlc                   ``drivers/char/n_hdlc.c``
 APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kernel/apm_32.c``
 DB_MAGIC              0x4442           fc_info                  ``drivers/net/iph5526_novram.c``
 DL_MAGIC              0x444d           fc_info                  ``drivers/net/iph5526_novram.c``
diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
index 8e37e00590f5..ac87f188235f 100644
--- a/Documentation/translations/zh_TW/process/magic-number.rst
+++ b/Documentation/translations/zh_TW/process/magic-number.rst
@@ -63,7 +63,6 @@ Linux 魔術數
 PG_MAGIC              'P'              pg_{read,write}_hdr      ``include/linux/pg.h``
 CMAGIC                0x0111           user                     ``include/linux/a.out.h``
 MKISS_DRIVER_MAGIC    0x04bf           mkiss_channel            ``drivers/net/mkiss.h``
-HDLC_MAGIC            0x239e           n_hdlc                   ``drivers/char/n_hdlc.c``
 APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kernel/apm_32.c``
 DB_MAGIC              0x4442           fc_info                  ``drivers/net/iph5526_novram.c``
 DL_MAGIC              0x444d           fc_info                  ``drivers/net/iph5526_novram.c``
diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c
index 94c1ec2dd754..b5aa27051119 100644
--- a/drivers/tty/n_hdlc.c
+++ b/drivers/tty/n_hdlc.c
@@ -76,8 +76,6 @@
  * OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#define HDLC_MAGIC 0x239e
-
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -124,7 +122,6 @@ struct n_hdlc_buf_list {
 
 /**
  * struct n_hdlc - per device instance data structure
- * @magic: magic value for structure
  * @tbusy: reentrancy flag for tx wakeup code
  * @woke_up: tx wakeup needs to be run again as it was called while @tbusy
  * @tx_buf_list: list of pending transmit frame buffers
@@ -133,7 +130,6 @@ struct n_hdlc_buf_list {
  * @rx_free_buf_list: list unused received frame buffers
  */
 struct n_hdlc {
-	int			magic;
 	bool			tbusy;
 	bool			woke_up;
 	struct n_hdlc_buf_list	tx_buf_list;
@@ -200,10 +196,6 @@ static void n_hdlc_tty_close(struct tty_struct *tty)
 {
 	struct n_hdlc *n_hdlc = tty->disc_data;
 
-	if (n_hdlc->magic != HDLC_MAGIC) {
-		pr_warn("n_hdlc: trying to close unopened tty!\n");
-		return;
-	}
 #if defined(TTY_NO_WRITE_SPLIT)
 	clear_bit(TTY_NO_WRITE_SPLIT, &tty->flags);
 #endif
@@ -386,12 +378,6 @@ static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data,
 
 	pr_debug("%s() called count=%d\n", __func__, count);
 
-	/* verify line is using HDLC discipline */
-	if (n_hdlc->magic != HDLC_MAGIC) {
-		pr_err("line not using HDLC discipline\n");
-		return;
-	}
-
 	if (count > maxframe) {
 		pr_debug("rx count>maxframesize, data discarded\n");
 		return;
@@ -542,9 +528,6 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
 
 	pr_debug("%s() called count=%zd\n", __func__, count);
 
-	if (n_hdlc->magic != HDLC_MAGIC)
-		return -EIO;
-
 	/* verify frame size */
 	if (count > maxframe) {
 		pr_debug("%s: truncating user packet from %zu to %d\n",
@@ -609,10 +592,6 @@ static int n_hdlc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
 
 	pr_debug("%s() called %d\n", __func__, cmd);
 
-	/* Verify the status of the device */
-	if (n_hdlc->magic != HDLC_MAGIC)
-		return -EBADF;
-
 	switch (cmd) {
 	case FIONREAD:
 		/* report count of read data available */
@@ -673,9 +652,6 @@ static __poll_t n_hdlc_tty_poll(struct tty_struct *tty, struct file *filp,
 	struct n_hdlc *n_hdlc = tty->disc_data;
 	__poll_t mask = 0;
 
-	if (n_hdlc->magic != HDLC_MAGIC)
-		return 0;
-
 	/*
 	 * queue the current process into any wait queue that may awaken in the
 	 * future (read and write)
@@ -739,9 +715,6 @@ static struct n_hdlc *n_hdlc_alloc(void)
 	n_hdlc_alloc_buf(&n_hdlc->rx_free_buf_list, DEFAULT_RX_BUF_COUNT, "rx");
 	n_hdlc_alloc_buf(&n_hdlc->tx_free_buf_list, DEFAULT_TX_BUF_COUNT, "tx");
 
-	/* Initialize the control block */
-	n_hdlc->magic  = HDLC_MAGIC;
-
 	return n_hdlc;
 
 }	/* end of n_hdlc_alloc() */
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/5] tty: synclink_gt: remove MGSL_MAGIC
  2022-09-16  1:54 [PATCH 1/5] tty: remove TTY_MAGIC наб
  2022-09-16  1:55 ` [PATCH 2/5] tty: remove TTY_DRIVER_MAGIC наб
  2022-09-16  1:55 ` [PATCH 3/5] tty: n_hdlc: remove HDLC_MAGIC наб
@ 2022-09-16  1:55 ` наб
  2022-09-16  6:52   ` Jiri Slaby
  2022-09-16  1:55   ` наб
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: наб @ 2022-09-16  1:55 UTC (permalink / raw)
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Greg Kroah-Hartman, Jiri Slaby, linux-doc, linux-kernel,
	linux-doc-tw-discuss

[-- Attachment #1: Type: text/plain, Size: 6301 bytes --]

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"

Ref: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 Documentation/process/magic-number.rst                    | 1 -
 Documentation/translations/it_IT/process/magic-number.rst | 1 -
 Documentation/translations/zh_CN/process/magic-number.rst | 1 -
 Documentation/translations/zh_TW/process/magic-number.rst | 1 -
 drivers/tty/synclink_gt.c                                 | 8 --------
 5 files changed, 12 deletions(-)

diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
index fdaa3e4b1953..2326c3be94fc 100644
--- a/Documentation/process/magic-number.rst
+++ b/Documentation/process/magic-number.rst
@@ -83,7 +83,6 @@ SLIP_MAGIC            0x5302           slip                     ``drivers/net/sl
 STRIP_MAGIC           0x5303           strip                    ``drivers/net/strip.c``
 SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
 AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
-MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
 MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
 USB_SERIAL_MAGIC      0x6702           usb_serial               ``drivers/usb/serial/usb-serial.h``
 FULL_DUPLEX_MAGIC     0x6969                                    ``drivers/net/ethernet/dec/tulip/de2104x.c``
diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
index 1898f98875de..1803497816f1 100644
--- a/Documentation/translations/it_IT/process/magic-number.rst
+++ b/Documentation/translations/it_IT/process/magic-number.rst
@@ -89,7 +89,6 @@ SLIP_MAGIC            0x5302           slip                     ``drivers/net/sl
 STRIP_MAGIC           0x5303           strip                    ``drivers/net/strip.c``
 SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
 AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
-MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
 MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
 USB_SERIAL_MAGIC      0x6702           usb_serial               ``drivers/usb/serial/usb-serial.h``
 FULL_DUPLEX_MAGIC     0x6969                                    ``drivers/net/ethernet/dec/tulip/de2104x.c``
diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
index 911cdaeaf698..9780bf710eeb 100644
--- a/Documentation/translations/zh_CN/process/magic-number.rst
+++ b/Documentation/translations/zh_CN/process/magic-number.rst
@@ -72,7 +72,6 @@ SLIP_MAGIC            0x5302           slip                     ``drivers/net/sl
 STRIP_MAGIC           0x5303           strip                    ``drivers/net/strip.c``
 SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
 AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
-MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
 MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
 USB_SERIAL_MAGIC      0x6702           usb_serial               ``drivers/usb/serial/usb-serial.h``
 FULL_DUPLEX_MAGIC     0x6969                                    ``drivers/net/ethernet/dec/tulip/de2104x.c``
diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
index ac87f188235f..933545e92137 100644
--- a/Documentation/translations/zh_TW/process/magic-number.rst
+++ b/Documentation/translations/zh_TW/process/magic-number.rst
@@ -75,7 +75,6 @@ SLIP_MAGIC            0x5302           slip                     ``drivers/net/sl
 STRIP_MAGIC           0x5303           strip                    ``drivers/net/strip.c``
 SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
 AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
-MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
 MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
 USB_SERIAL_MAGIC      0x6702           usb_serial               ``drivers/usb/serial/usb-serial.h``
 FULL_DUPLEX_MAGIC     0x6969                                    ``drivers/net/ethernet/dec/tulip/de2104x.c``
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
index 9bc2a9265277..19e3dd470fc2 100644
--- a/drivers/tty/synclink_gt.c
+++ b/drivers/tty/synclink_gt.c
@@ -91,7 +91,6 @@ static char *driver_name     = "SyncLink GT";
 static char *slgt_driver_name = "synclink_gt";
 static char *tty_dev_prefix  = "ttySLG";
 MODULE_LICENSE("GPL");
-#define MGSL_MAGIC 0x5401
 #define MAX_DEVICES 32
 
 static const struct pci_device_id pci_table[] = {
@@ -215,8 +214,6 @@ struct slgt_info {
 
 	struct slgt_info *next_device;	/* device list link */
 
-	int magic;
-
 	char device_name[25];
 	struct pci_dev *pdev;
 
@@ -554,10 +551,6 @@ static inline int sanity_check(struct slgt_info *info, char *devname, const char
 		printk("null struct slgt_info for (%s) in %s\n", devname, name);
 		return 1;
 	}
-	if (info->magic != MGSL_MAGIC) {
-		printk("bad magic number struct slgt_info (%s) in %s\n", devname, name);
-		return 1;
-	}
 #else
 	if (!info)
 		return 1;
@@ -3498,7 +3491,6 @@ static struct slgt_info *alloc_dev(int adapter_num, int port_num, struct pci_dev
 	} else {
 		tty_port_init(&info->port);
 		info->port.ops = &slgt_port_ops;
-		info->magic = MGSL_MAGIC;
 		INIT_WORK(&info->task, bh_handler);
 		info->max_frame_size = 4096;
 		info->base_clock = 14745600;
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/5] tty: hvc: remove HVC_IUCV_MAGIC
  2022-09-16  1:54 [PATCH 1/5] tty: remove TTY_MAGIC наб
@ 2022-09-16  1:55   ` наб
  2022-09-16  1:55 ` [PATCH 3/5] tty: n_hdlc: remove HDLC_MAGIC наб
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: наб @ 2022-09-16  1:55 UTC (permalink / raw)
  Cc: Greg Kroah-Hartman, Jiri Slaby, Randy Dunlap, linuxppc-dev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2168 bytes --]

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"

This stretches that definition slightly, since it multiplexes it with
the terminal number as a constant offset, but is equivalent

Ref: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 drivers/tty/hvc/hvc_iucv.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/hvc/hvc_iucv.c b/drivers/tty/hvc/hvc_iucv.c
index 32366caca662..7d49a872de48 100644
--- a/drivers/tty/hvc/hvc_iucv.c
+++ b/drivers/tty/hvc/hvc_iucv.c
@@ -29,7 +29,6 @@
 
 
 /* General device driver settings */
-#define HVC_IUCV_MAGIC		0xc9e4c3e5
 #define MAX_HVC_IUCV_LINES	HVC_ALLOC_TTY_ADAPTERS
 #define MEMPOOL_MIN_NR		(PAGE_SIZE / sizeof(struct iucv_tty_buffer)/4)
 
@@ -131,9 +130,9 @@ static struct iucv_handler hvc_iucv_handler = {
  */
 static struct hvc_iucv_private *hvc_iucv_get_private(uint32_t num)
 {
-	if ((num < HVC_IUCV_MAGIC) || (num - HVC_IUCV_MAGIC > hvc_iucv_devices))
+	if (num > hvc_iucv_devices)
 		return NULL;
-	return hvc_iucv_table[num - HVC_IUCV_MAGIC];
+	return hvc_iucv_table[num];
 }
 
 /**
@@ -1072,8 +1071,8 @@ static int __init hvc_iucv_alloc(int id, unsigned int is_console)
 	priv->is_console = is_console;
 
 	/* allocate hvc device */
-	priv->hvc = hvc_alloc(HVC_IUCV_MAGIC + id, /*		  PAGE_SIZE */
-			      HVC_IUCV_MAGIC + id, &hvc_iucv_ops, 256);
+	priv->hvc = hvc_alloc(id, /*		 PAGE_SIZE */
+			      id, &hvc_iucv_ops, 256);
 	if (IS_ERR(priv->hvc)) {
 		rc = PTR_ERR(priv->hvc);
 		goto out_error_hvc;
@@ -1371,7 +1370,7 @@ static int __init hvc_iucv_init(void)
 
 	/* register the first terminal device as console
 	 * (must be done before allocating hvc terminal devices) */
-	rc = hvc_instantiate(HVC_IUCV_MAGIC, IUCV_HVC_CON_IDX, &hvc_iucv_ops);
+	rc = hvc_instantiate(0, IUCV_HVC_CON_IDX, &hvc_iucv_ops);
 	if (rc) {
 		pr_err("Registering HVC terminal device as "
 		       "Linux console failed\n");
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/5] tty: hvc: remove HVC_IUCV_MAGIC
@ 2022-09-16  1:55   ` наб
  0 siblings, 0 replies; 14+ messages in thread
From: наб @ 2022-09-16  1:55 UTC (permalink / raw)
  Cc: Greg Kroah-Hartman, Randy Dunlap, Jiri Slaby, linuxppc-dev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2168 bytes --]

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"

This stretches that definition slightly, since it multiplexes it with
the terminal number as a constant offset, but is equivalent

Ref: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 drivers/tty/hvc/hvc_iucv.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/hvc/hvc_iucv.c b/drivers/tty/hvc/hvc_iucv.c
index 32366caca662..7d49a872de48 100644
--- a/drivers/tty/hvc/hvc_iucv.c
+++ b/drivers/tty/hvc/hvc_iucv.c
@@ -29,7 +29,6 @@
 
 
 /* General device driver settings */
-#define HVC_IUCV_MAGIC		0xc9e4c3e5
 #define MAX_HVC_IUCV_LINES	HVC_ALLOC_TTY_ADAPTERS
 #define MEMPOOL_MIN_NR		(PAGE_SIZE / sizeof(struct iucv_tty_buffer)/4)
 
@@ -131,9 +130,9 @@ static struct iucv_handler hvc_iucv_handler = {
  */
 static struct hvc_iucv_private *hvc_iucv_get_private(uint32_t num)
 {
-	if ((num < HVC_IUCV_MAGIC) || (num - HVC_IUCV_MAGIC > hvc_iucv_devices))
+	if (num > hvc_iucv_devices)
 		return NULL;
-	return hvc_iucv_table[num - HVC_IUCV_MAGIC];
+	return hvc_iucv_table[num];
 }
 
 /**
@@ -1072,8 +1071,8 @@ static int __init hvc_iucv_alloc(int id, unsigned int is_console)
 	priv->is_console = is_console;
 
 	/* allocate hvc device */
-	priv->hvc = hvc_alloc(HVC_IUCV_MAGIC + id, /*		  PAGE_SIZE */
-			      HVC_IUCV_MAGIC + id, &hvc_iucv_ops, 256);
+	priv->hvc = hvc_alloc(id, /*		 PAGE_SIZE */
+			      id, &hvc_iucv_ops, 256);
 	if (IS_ERR(priv->hvc)) {
 		rc = PTR_ERR(priv->hvc);
 		goto out_error_hvc;
@@ -1371,7 +1370,7 @@ static int __init hvc_iucv_init(void)
 
 	/* register the first terminal device as console
 	 * (must be done before allocating hvc terminal devices) */
-	rc = hvc_instantiate(HVC_IUCV_MAGIC, IUCV_HVC_CON_IDX, &hvc_iucv_ops);
+	rc = hvc_instantiate(0, IUCV_HVC_CON_IDX, &hvc_iucv_ops);
 	if (rc) {
 		pr_err("Registering HVC terminal device as "
 		       "Linux console failed\n");
-- 
2.30.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/5] tty: remove TTY_MAGIC
  2022-09-16  1:54 [PATCH 1/5] tty: remove TTY_MAGIC наб
                   ` (3 preceding siblings ...)
  2022-09-16  1:55   ` наб
@ 2022-09-16  6:51 ` Jiri Slaby
  2022-09-16  7:33 ` Theodore Ts'o
  2022-09-22 14:12 ` Greg Kroah-Hartman
  6 siblings, 0 replies; 14+ messages in thread
From: Jiri Slaby @ 2022-09-16  6:51 UTC (permalink / raw)
  To: наб
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Greg Kroah-Hartman, linux-doc, linux-kernel,
	linux-doc-tw-discuss

On 16. 09. 22, 3:54, наб wrote:
> 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"
> 
> Ref: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>

What a good riddance! We have by far better debugging techniques nowadays.

Acked-by: Jiri Slaby <jirislaby@kernel.org>

> ---
> Whole series: amd64 allyesconfig builds; amd64 Debian config boots and
> appears to work; naturally, the HVC stuff is S/390 only, but it's a
> constant offset
> 
>   Documentation/process/magic-number.rst                    | 1 -
>   Documentation/translations/it_IT/process/magic-number.rst | 1 -
>   Documentation/translations/zh_CN/process/magic-number.rst | 1 -
>   Documentation/translations/zh_TW/process/magic-number.rst | 1 -
>   drivers/tty/tty_io.c                                      | 8 --------
>   drivers/tty/tty_mutex.c                                   | 6 ------
>   include/linux/tty.h                                       | 6 ------
>   7 files changed, 24 deletions(-)
> 
> diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
> index f5ba36e96461..b4c7ec61437e 100644
> --- a/Documentation/process/magic-number.rst
> +++ b/Documentation/process/magic-number.rst
> @@ -84,7 +84,6 @@ SLIP_MAGIC            0x5302           slip                     ``drivers/net/sl
>   STRIP_MAGIC           0x5303           strip                    ``drivers/net/strip.c``
>   SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
>   AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
> -TTY_MAGIC             0x5401           tty_struct               ``include/linux/tty.h``
>   MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
>   TTY_DRIVER_MAGIC      0x5402           tty_driver               ``include/linux/tty_driver.h``
>   MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
> diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
> index f452fafb1e84..bcb23384fefd 100644
> --- a/Documentation/translations/it_IT/process/magic-number.rst
> +++ b/Documentation/translations/it_IT/process/magic-number.rst
> @@ -90,7 +90,6 @@ SLIP_MAGIC            0x5302           slip                     ``drivers/net/sl
>   STRIP_MAGIC           0x5303           strip                    ``drivers/net/strip.c``
>   SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
>   AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
> -TTY_MAGIC             0x5401           tty_struct               ``include/linux/tty.h``
>   MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
>   TTY_DRIVER_MAGIC      0x5402           tty_driver               ``include/linux/tty_driver.h``
>   MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
> diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
> index 42f0635ca70a..6250087d36c5 100644
> --- a/Documentation/translations/zh_CN/process/magic-number.rst
> +++ b/Documentation/translations/zh_CN/process/magic-number.rst
> @@ -73,7 +73,6 @@ SLIP_MAGIC            0x5302           slip                     ``drivers/net/sl
>   STRIP_MAGIC           0x5303           strip                    ``drivers/net/strip.c``
>   SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
>   AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
> -TTY_MAGIC             0x5401           tty_struct               ``include/linux/tty.h``
>   MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
>   TTY_DRIVER_MAGIC      0x5402           tty_driver               ``include/linux/tty_driver.h``
>   MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
> diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
> index ae321a9aaece..fd169d760bbd 100644
> --- a/Documentation/translations/zh_TW/process/magic-number.rst
> +++ b/Documentation/translations/zh_TW/process/magic-number.rst
> @@ -76,7 +76,6 @@ SLIP_MAGIC            0x5302           slip                     ``drivers/net/sl
>   STRIP_MAGIC           0x5303           strip                    ``drivers/net/strip.c``
>   SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
>   AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
> -TTY_MAGIC             0x5401           tty_struct               ``include/linux/tty.h``
>   MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
>   TTY_DRIVER_MAGIC      0x5402           tty_driver               ``include/linux/tty_driver.h``
>   MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
> diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
> index 82a8855981f7..33962109bd10 100644
> --- a/drivers/tty/tty_io.c
> +++ b/drivers/tty/tty_io.c
> @@ -170,7 +170,6 @@ static void free_tty_struct(struct tty_struct *tty)
>   	tty_ldisc_deinit(tty);
>   	put_device(tty->dev);
>   	kvfree(tty->write_buf);
> -	tty->magic = 0xDEADDEAD;
>   	kfree(tty);
>   }
>   
> @@ -265,11 +264,6 @@ static int tty_paranoia_check(struct tty_struct *tty, struct inode *inode,
>   			imajor(inode), iminor(inode), routine);
>   		return 1;
>   	}
> -	if (tty->magic != TTY_MAGIC) {
> -		pr_warn("(%d:%d): %s: bad magic number\n",
> -			imajor(inode), iminor(inode), routine);
> -		return 1;
> -	}
>   #endif
>   	return 0;
>   }
> @@ -1533,7 +1527,6 @@ static void release_one_tty(struct work_struct *work)
>   	if (tty->ops->cleanup)
>   		tty->ops->cleanup(tty);
>   
> -	tty->magic = 0;
>   	tty_driver_kref_put(driver);
>   	module_put(owner);
>   
> @@ -3093,7 +3086,6 @@ struct tty_struct *alloc_tty_struct(struct tty_driver *driver, int idx)
>   		return NULL;
>   
>   	kref_init(&tty->kref);
> -	tty->magic = TTY_MAGIC;
>   	if (tty_ldisc_init(tty)) {
>   		kfree(tty);
>   		return NULL;
> diff --git a/drivers/tty/tty_mutex.c b/drivers/tty/tty_mutex.c
> index 393518a24cfe..784e46a0a3b1 100644
> --- a/drivers/tty/tty_mutex.c
> +++ b/drivers/tty/tty_mutex.c
> @@ -14,8 +14,6 @@
>   
>   void tty_lock(struct tty_struct *tty)
>   {
> -	if (WARN(tty->magic != TTY_MAGIC, "L Bad %p\n", tty))
> -		return;
>   	tty_kref_get(tty);
>   	mutex_lock(&tty->legacy_mutex);
>   }
> @@ -25,8 +23,6 @@ int tty_lock_interruptible(struct tty_struct *tty)
>   {
>   	int ret;
>   
> -	if (WARN(tty->magic != TTY_MAGIC, "L Bad %p\n", tty))
> -		return -EIO;
>   	tty_kref_get(tty);
>   	ret = mutex_lock_interruptible(&tty->legacy_mutex);
>   	if (ret)
> @@ -36,8 +32,6 @@ int tty_lock_interruptible(struct tty_struct *tty)
>   
>   void tty_unlock(struct tty_struct *tty)
>   {
> -	if (WARN(tty->magic != TTY_MAGIC, "U Bad %p\n", tty))
> -		return;
>   	mutex_unlock(&tty->legacy_mutex);
>   	tty_kref_put(tty);
>   }
> diff --git a/include/linux/tty.h b/include/linux/tty.h
> index 7b0a5d478ef6..ba65043e9029 100644
> --- a/include/linux/tty.h
> +++ b/include/linux/tty.h
> @@ -122,8 +122,6 @@ struct tty_operations;
>   /**
>    * struct tty_struct - state associated with a tty while open
>    *
> - * @magic: magic value set early in @alloc_tty_struct to %TTY_MAGIC, for
> - *	   debugging purposes
>    * @kref: reference counting by tty_kref_get() and tty_kref_put(), reaching zero
>    *	  frees the structure
>    * @dev: class device or %NULL (e.g. ptys, serdev)
> @@ -193,7 +191,6 @@ struct tty_operations;
>    * &struct tty_port.
>    */
>   struct tty_struct {
> -	int	magic;
>   	struct kref kref;
>   	struct device *dev;
>   	struct tty_driver *driver;
> @@ -260,9 +257,6 @@ struct tty_file_private {
>   	struct list_head list;
>   };
>   
> -/* tty magic number */
> -#define TTY_MAGIC		0x5401
> -
>   /**
>    * DOC: TTY Struct Flags
>    *

-- 
js
suse labs


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/5] tty: remove TTY_DRIVER_MAGIC
  2022-09-16  1:55 ` [PATCH 2/5] tty: remove TTY_DRIVER_MAGIC наб
@ 2022-09-16  6:51   ` Jiri Slaby
  0 siblings, 0 replies; 14+ messages in thread
From: Jiri Slaby @ 2022-09-16  6:51 UTC (permalink / raw)
  To: наб
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Greg Kroah-Hartman, linux-doc, linux-kernel,
	linux-doc-tw-discuss

On 16. 09. 22, 3:55, наб wrote:
> 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"
> 
> Ref: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>

Acked-by: Jiri Slaby <jirislaby@kernel.org>

> ---
>   Documentation/process/magic-number.rst                    | 1 -
>   Documentation/translations/it_IT/process/magic-number.rst | 1 -
>   Documentation/translations/zh_CN/process/magic-number.rst | 1 -
>   Documentation/translations/zh_TW/process/magic-number.rst | 1 -
>   drivers/tty/tty_io.c                                      | 1 -
>   include/linux/tty_driver.h                                | 5 -----
>   6 files changed, 10 deletions(-)
> 
> diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
> index b4c7ec61437e..d47799ba0ca4 100644
> --- a/Documentation/process/magic-number.rst
> +++ b/Documentation/process/magic-number.rst
> @@ -85,7 +85,6 @@ STRIP_MAGIC           0x5303           strip                    ``drivers/net/st
>   SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
>   AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
>   MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
> -TTY_DRIVER_MAGIC      0x5402           tty_driver               ``include/linux/tty_driver.h``
>   MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
>   USB_SERIAL_MAGIC      0x6702           usb_serial               ``drivers/usb/serial/usb-serial.h``
>   FULL_DUPLEX_MAGIC     0x6969                                    ``drivers/net/ethernet/dec/tulip/de2104x.c``
> diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
> index bcb23384fefd..24022ab52ebb 100644
> --- a/Documentation/translations/it_IT/process/magic-number.rst
> +++ b/Documentation/translations/it_IT/process/magic-number.rst
> @@ -91,7 +91,6 @@ STRIP_MAGIC           0x5303           strip                    ``drivers/net/st
>   SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
>   AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
>   MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
> -TTY_DRIVER_MAGIC      0x5402           tty_driver               ``include/linux/tty_driver.h``
>   MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
>   USB_SERIAL_MAGIC      0x6702           usb_serial               ``drivers/usb/serial/usb-serial.h``
>   FULL_DUPLEX_MAGIC     0x6969                                    ``drivers/net/ethernet/dec/tulip/de2104x.c``
> diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
> index 6250087d36c5..811804996283 100644
> --- a/Documentation/translations/zh_CN/process/magic-number.rst
> +++ b/Documentation/translations/zh_CN/process/magic-number.rst
> @@ -74,7 +74,6 @@ STRIP_MAGIC           0x5303           strip                    ``drivers/net/st
>   SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
>   AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
>   MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
> -TTY_DRIVER_MAGIC      0x5402           tty_driver               ``include/linux/tty_driver.h``
>   MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
>   USB_SERIAL_MAGIC      0x6702           usb_serial               ``drivers/usb/serial/usb-serial.h``
>   FULL_DUPLEX_MAGIC     0x6969                                    ``drivers/net/ethernet/dec/tulip/de2104x.c``
> diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
> index fd169d760bbd..8e37e00590f5 100644
> --- a/Documentation/translations/zh_TW/process/magic-number.rst
> +++ b/Documentation/translations/zh_TW/process/magic-number.rst
> @@ -77,7 +77,6 @@ STRIP_MAGIC           0x5303           strip                    ``drivers/net/st
>   SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
>   AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
>   MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
> -TTY_DRIVER_MAGIC      0x5402           tty_driver               ``include/linux/tty_driver.h``
>   MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
>   USB_SERIAL_MAGIC      0x6702           usb_serial               ``drivers/usb/serial/usb-serial.h``
>   FULL_DUPLEX_MAGIC     0x6969                                    ``drivers/net/ethernet/dec/tulip/de2104x.c``
> diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
> index 33962109bd10..d036fc59a2e8 100644
> --- a/drivers/tty/tty_io.c
> +++ b/drivers/tty/tty_io.c
> @@ -3321,7 +3321,6 @@ struct tty_driver *__tty_alloc_driver(unsigned int lines, struct module *owner,
>   		return ERR_PTR(-ENOMEM);
>   
>   	kref_init(&driver->kref);
> -	driver->magic = TTY_DRIVER_MAGIC;
>   	driver->num = lines;
>   	driver->owner = owner;
>   	driver->flags = flags;
> diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
> index 4841d8069c07..b0421f5de8a6 100644
> --- a/include/linux/tty_driver.h
> +++ b/include/linux/tty_driver.h
> @@ -396,7 +396,6 @@ struct tty_operations {
>   /**
>    * struct tty_driver -- driver for TTY devices
>    *
> - * @magic: set to %TTY_DRIVER_MAGIC in __tty_alloc_driver()
>    * @kref: reference counting. Reaching zero frees all the internals and the
>    *	  driver.
>    * @cdevs: allocated/registered character /dev devices
> @@ -432,7 +431,6 @@ struct tty_operations {
>    * @driver_name, @name, @type, @subtype, @init_termios, and @ops.
>    */
>   struct tty_driver {
> -	int	magic;
>   	struct kref kref;
>   	struct cdev **cdevs;
>   	struct module	*owner;
> @@ -489,9 +487,6 @@ static inline void tty_set_operations(struct tty_driver *driver,
>   	driver->ops = op;
>   }
>   
> -/* tty driver magic number */
> -#define TTY_DRIVER_MAGIC		0x5402
> -
>   /**
>    * DOC: TTY Driver Flags
>    *

-- 
js
suse labs


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/5] tty: n_hdlc: remove HDLC_MAGIC
  2022-09-16  1:55 ` [PATCH 3/5] tty: n_hdlc: remove HDLC_MAGIC наб
@ 2022-09-16  6:51   ` Jiri Slaby
  0 siblings, 0 replies; 14+ messages in thread
From: Jiri Slaby @ 2022-09-16  6:51 UTC (permalink / raw)
  To: наб
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Greg Kroah-Hartman, linux-doc, linux-kernel,
	linux-doc-tw-discuss

On 16. 09. 22, 3:55, наб wrote:
> 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"
> 
> Ref: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>

Acked-by: Jiri Slaby <jirislaby@kernel.org>

> ---
>   Documentation/process/magic-number.rst        |  1 -
>   .../it_IT/process/magic-number.rst            |  1 -
>   .../zh_CN/process/magic-number.rst            |  1 -
>   .../zh_TW/process/magic-number.rst            |  1 -
>   drivers/tty/n_hdlc.c                          | 27 -------------------
>   5 files changed, 31 deletions(-)
> 
> diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
> index d47799ba0ca4..fdaa3e4b1953 100644
> --- a/Documentation/process/magic-number.rst
> +++ b/Documentation/process/magic-number.rst
> @@ -71,7 +71,6 @@ Magic Name            Number           Structure                File
>   PG_MAGIC              'P'              pg_{read,write}_hdr      ``include/linux/pg.h``
>   CMAGIC                0x0111           user                     ``include/linux/a.out.h``
>   MKISS_DRIVER_MAGIC    0x04bf           mkiss_channel            ``drivers/net/mkiss.h``
> -HDLC_MAGIC            0x239e           n_hdlc                   ``drivers/char/n_hdlc.c``
>   APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kernel/apm_32.c``
>   DB_MAGIC              0x4442           fc_info                  ``drivers/net/iph5526_novram.c``
>   DL_MAGIC              0x444d           fc_info                  ``drivers/net/iph5526_novram.c``
> diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
> index 24022ab52ebb..1898f98875de 100644
> --- a/Documentation/translations/it_IT/process/magic-number.rst
> +++ b/Documentation/translations/it_IT/process/magic-number.rst
> @@ -77,7 +77,6 @@ Nome magico           Numero           Struttura                File
>   PG_MAGIC              'P'              pg_{read,write}_hdr      ``include/linux/pg.h``
>   CMAGIC                0x0111           user                     ``include/linux/a.out.h``
>   MKISS_DRIVER_MAGIC    0x04bf           mkiss_channel            ``drivers/net/mkiss.h``
> -HDLC_MAGIC            0x239e           n_hdlc                   ``drivers/char/n_hdlc.c``
>   APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kernel/apm_32.c``
>   DB_MAGIC              0x4442           fc_info                  ``drivers/net/iph5526_novram.c``
>   DL_MAGIC              0x444d           fc_info                  ``drivers/net/iph5526_novram.c``
> diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
> index 811804996283..911cdaeaf698 100644
> --- a/Documentation/translations/zh_CN/process/magic-number.rst
> +++ b/Documentation/translations/zh_CN/process/magic-number.rst
> @@ -60,7 +60,6 @@ Linux 魔术数
>   PG_MAGIC              'P'              pg_{read,write}_hdr      ``include/linux/pg.h``
>   CMAGIC                0x0111           user                     ``include/linux/a.out.h``
>   MKISS_DRIVER_MAGIC    0x04bf           mkiss_channel            ``drivers/net/mkiss.h``
> -HDLC_MAGIC            0x239e           n_hdlc                   ``drivers/char/n_hdlc.c``
>   APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kernel/apm_32.c``
>   DB_MAGIC              0x4442           fc_info                  ``drivers/net/iph5526_novram.c``
>   DL_MAGIC              0x444d           fc_info                  ``drivers/net/iph5526_novram.c``
> diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
> index 8e37e00590f5..ac87f188235f 100644
> --- a/Documentation/translations/zh_TW/process/magic-number.rst
> +++ b/Documentation/translations/zh_TW/process/magic-number.rst
> @@ -63,7 +63,6 @@ Linux 魔術數
>   PG_MAGIC              'P'              pg_{read,write}_hdr      ``include/linux/pg.h``
>   CMAGIC                0x0111           user                     ``include/linux/a.out.h``
>   MKISS_DRIVER_MAGIC    0x04bf           mkiss_channel            ``drivers/net/mkiss.h``
> -HDLC_MAGIC            0x239e           n_hdlc                   ``drivers/char/n_hdlc.c``
>   APM_BIOS_MAGIC        0x4101           apm_user                 ``arch/x86/kernel/apm_32.c``
>   DB_MAGIC              0x4442           fc_info                  ``drivers/net/iph5526_novram.c``
>   DL_MAGIC              0x444d           fc_info                  ``drivers/net/iph5526_novram.c``
> diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c
> index 94c1ec2dd754..b5aa27051119 100644
> --- a/drivers/tty/n_hdlc.c
> +++ b/drivers/tty/n_hdlc.c
> @@ -76,8 +76,6 @@
>    * OF THE POSSIBILITY OF SUCH DAMAGE.
>    */
>   
> -#define HDLC_MAGIC 0x239e
> -
>   #include <linux/module.h>
>   #include <linux/init.h>
>   #include <linux/kernel.h>
> @@ -124,7 +122,6 @@ struct n_hdlc_buf_list {
>   
>   /**
>    * struct n_hdlc - per device instance data structure
> - * @magic: magic value for structure
>    * @tbusy: reentrancy flag for tx wakeup code
>    * @woke_up: tx wakeup needs to be run again as it was called while @tbusy
>    * @tx_buf_list: list of pending transmit frame buffers
> @@ -133,7 +130,6 @@ struct n_hdlc_buf_list {
>    * @rx_free_buf_list: list unused received frame buffers
>    */
>   struct n_hdlc {
> -	int			magic;
>   	bool			tbusy;
>   	bool			woke_up;
>   	struct n_hdlc_buf_list	tx_buf_list;
> @@ -200,10 +196,6 @@ static void n_hdlc_tty_close(struct tty_struct *tty)
>   {
>   	struct n_hdlc *n_hdlc = tty->disc_data;
>   
> -	if (n_hdlc->magic != HDLC_MAGIC) {
> -		pr_warn("n_hdlc: trying to close unopened tty!\n");
> -		return;
> -	}
>   #if defined(TTY_NO_WRITE_SPLIT)
>   	clear_bit(TTY_NO_WRITE_SPLIT, &tty->flags);
>   #endif
> @@ -386,12 +378,6 @@ static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data,
>   
>   	pr_debug("%s() called count=%d\n", __func__, count);
>   
> -	/* verify line is using HDLC discipline */
> -	if (n_hdlc->magic != HDLC_MAGIC) {
> -		pr_err("line not using HDLC discipline\n");
> -		return;
> -	}
> -
>   	if (count > maxframe) {
>   		pr_debug("rx count>maxframesize, data discarded\n");
>   		return;
> @@ -542,9 +528,6 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
>   
>   	pr_debug("%s() called count=%zd\n", __func__, count);
>   
> -	if (n_hdlc->magic != HDLC_MAGIC)
> -		return -EIO;
> -
>   	/* verify frame size */
>   	if (count > maxframe) {
>   		pr_debug("%s: truncating user packet from %zu to %d\n",
> @@ -609,10 +592,6 @@ static int n_hdlc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
>   
>   	pr_debug("%s() called %d\n", __func__, cmd);
>   
> -	/* Verify the status of the device */
> -	if (n_hdlc->magic != HDLC_MAGIC)
> -		return -EBADF;
> -
>   	switch (cmd) {
>   	case FIONREAD:
>   		/* report count of read data available */
> @@ -673,9 +652,6 @@ static __poll_t n_hdlc_tty_poll(struct tty_struct *tty, struct file *filp,
>   	struct n_hdlc *n_hdlc = tty->disc_data;
>   	__poll_t mask = 0;
>   
> -	if (n_hdlc->magic != HDLC_MAGIC)
> -		return 0;
> -
>   	/*
>   	 * queue the current process into any wait queue that may awaken in the
>   	 * future (read and write)
> @@ -739,9 +715,6 @@ static struct n_hdlc *n_hdlc_alloc(void)
>   	n_hdlc_alloc_buf(&n_hdlc->rx_free_buf_list, DEFAULT_RX_BUF_COUNT, "rx");
>   	n_hdlc_alloc_buf(&n_hdlc->tx_free_buf_list, DEFAULT_TX_BUF_COUNT, "tx");
>   
> -	/* Initialize the control block */
> -	n_hdlc->magic  = HDLC_MAGIC;
> -
>   	return n_hdlc;
>   
>   }	/* end of n_hdlc_alloc() */

-- 
js
suse labs


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/5] tty: synclink_gt: remove MGSL_MAGIC
  2022-09-16  1:55 ` [PATCH 4/5] tty: synclink_gt: remove MGSL_MAGIC наб
@ 2022-09-16  6:52   ` Jiri Slaby
  0 siblings, 0 replies; 14+ messages in thread
From: Jiri Slaby @ 2022-09-16  6:52 UTC (permalink / raw)
  To: наб
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Greg Kroah-Hartman, linux-doc, linux-kernel,
	linux-doc-tw-discuss

On 16. 09. 22, 3:55, наб wrote:
> 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"
> 
> Ref: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>

Acked-by: Jiri Slaby <jirislaby@kernel.org>

> ---
>   Documentation/process/magic-number.rst                    | 1 -
>   Documentation/translations/it_IT/process/magic-number.rst | 1 -
>   Documentation/translations/zh_CN/process/magic-number.rst | 1 -
>   Documentation/translations/zh_TW/process/magic-number.rst | 1 -
>   drivers/tty/synclink_gt.c                                 | 8 --------
>   5 files changed, 12 deletions(-)
> 
> diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
> index fdaa3e4b1953..2326c3be94fc 100644
> --- a/Documentation/process/magic-number.rst
> +++ b/Documentation/process/magic-number.rst
> @@ -83,7 +83,6 @@ SLIP_MAGIC            0x5302           slip                     ``drivers/net/sl
>   STRIP_MAGIC           0x5303           strip                    ``drivers/net/strip.c``
>   SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
>   AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
> -MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
>   MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
>   USB_SERIAL_MAGIC      0x6702           usb_serial               ``drivers/usb/serial/usb-serial.h``
>   FULL_DUPLEX_MAGIC     0x6969                                    ``drivers/net/ethernet/dec/tulip/de2104x.c``
> diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
> index 1898f98875de..1803497816f1 100644
> --- a/Documentation/translations/it_IT/process/magic-number.rst
> +++ b/Documentation/translations/it_IT/process/magic-number.rst
> @@ -89,7 +89,6 @@ SLIP_MAGIC            0x5302           slip                     ``drivers/net/sl
>   STRIP_MAGIC           0x5303           strip                    ``drivers/net/strip.c``
>   SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
>   AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
> -MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
>   MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
>   USB_SERIAL_MAGIC      0x6702           usb_serial               ``drivers/usb/serial/usb-serial.h``
>   FULL_DUPLEX_MAGIC     0x6969                                    ``drivers/net/ethernet/dec/tulip/de2104x.c``
> diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
> index 911cdaeaf698..9780bf710eeb 100644
> --- a/Documentation/translations/zh_CN/process/magic-number.rst
> +++ b/Documentation/translations/zh_CN/process/magic-number.rst
> @@ -72,7 +72,6 @@ SLIP_MAGIC            0x5302           slip                     ``drivers/net/sl
>   STRIP_MAGIC           0x5303           strip                    ``drivers/net/strip.c``
>   SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
>   AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
> -MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
>   MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
>   USB_SERIAL_MAGIC      0x6702           usb_serial               ``drivers/usb/serial/usb-serial.h``
>   FULL_DUPLEX_MAGIC     0x6969                                    ``drivers/net/ethernet/dec/tulip/de2104x.c``
> diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
> index ac87f188235f..933545e92137 100644
> --- a/Documentation/translations/zh_TW/process/magic-number.rst
> +++ b/Documentation/translations/zh_TW/process/magic-number.rst
> @@ -75,7 +75,6 @@ SLIP_MAGIC            0x5302           slip                     ``drivers/net/sl
>   STRIP_MAGIC           0x5303           strip                    ``drivers/net/strip.c``
>   SIXPACK_MAGIC         0x5304           sixpack                  ``drivers/net/hamradio/6pack.h``
>   AX25_MAGIC            0x5316           ax_disp                  ``drivers/net/mkiss.h``
> -MGSL_MAGIC            0x5401           mgsl_info                ``drivers/char/synclink.c``
>   MGSLPC_MAGIC          0x5402           mgslpc_info              ``drivers/char/pcmcia/synclink_cs.c``
>   USB_SERIAL_MAGIC      0x6702           usb_serial               ``drivers/usb/serial/usb-serial.h``
>   FULL_DUPLEX_MAGIC     0x6969                                    ``drivers/net/ethernet/dec/tulip/de2104x.c``
> diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
> index 9bc2a9265277..19e3dd470fc2 100644
> --- a/drivers/tty/synclink_gt.c
> +++ b/drivers/tty/synclink_gt.c
> @@ -91,7 +91,6 @@ static char *driver_name     = "SyncLink GT";
>   static char *slgt_driver_name = "synclink_gt";
>   static char *tty_dev_prefix  = "ttySLG";
>   MODULE_LICENSE("GPL");
> -#define MGSL_MAGIC 0x5401
>   #define MAX_DEVICES 32
>   
>   static const struct pci_device_id pci_table[] = {
> @@ -215,8 +214,6 @@ struct slgt_info {
>   
>   	struct slgt_info *next_device;	/* device list link */
>   
> -	int magic;
> -
>   	char device_name[25];
>   	struct pci_dev *pdev;
>   
> @@ -554,10 +551,6 @@ static inline int sanity_check(struct slgt_info *info, char *devname, const char
>   		printk("null struct slgt_info for (%s) in %s\n", devname, name);
>   		return 1;
>   	}
> -	if (info->magic != MGSL_MAGIC) {
> -		printk("bad magic number struct slgt_info (%s) in %s\n", devname, name);
> -		return 1;
> -	}
>   #else
>   	if (!info)
>   		return 1;
> @@ -3498,7 +3491,6 @@ static struct slgt_info *alloc_dev(int adapter_num, int port_num, struct pci_dev
>   	} else {
>   		tty_port_init(&info->port);
>   		info->port.ops = &slgt_port_ops;
> -		info->magic = MGSL_MAGIC;
>   		INIT_WORK(&info->task, bh_handler);
>   		info->max_frame_size = 4096;
>   		info->base_clock = 14745600;

-- 
js
suse labs


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/5] tty: hvc: remove HVC_IUCV_MAGIC
  2022-09-16  1:55   ` наб
  (?)
@ 2022-09-16  6:52   ` Jiri Slaby
  -1 siblings, 0 replies; 14+ messages in thread
From: Jiri Slaby @ 2022-09-16  6:52 UTC (permalink / raw)
  To: наб
  Cc: Greg Kroah-Hartman, Randy Dunlap, linuxppc-dev, linux-kernel

On 16. 09. 22, 3:55, наб wrote:
> 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"
> 
> This stretches that definition slightly, since it multiplexes it with
> the terminal number as a constant offset, but is equivalent
> 
> Ref: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>

Acked-by: Jiri Slaby <jirislaby@kernel.org>

> ---
>   drivers/tty/hvc/hvc_iucv.c | 11 +++++------
>   1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/tty/hvc/hvc_iucv.c b/drivers/tty/hvc/hvc_iucv.c
> index 32366caca662..7d49a872de48 100644
> --- a/drivers/tty/hvc/hvc_iucv.c
> +++ b/drivers/tty/hvc/hvc_iucv.c
> @@ -29,7 +29,6 @@
>   
>   
>   /* General device driver settings */
> -#define HVC_IUCV_MAGIC		0xc9e4c3e5
>   #define MAX_HVC_IUCV_LINES	HVC_ALLOC_TTY_ADAPTERS
>   #define MEMPOOL_MIN_NR		(PAGE_SIZE / sizeof(struct iucv_tty_buffer)/4)
>   
> @@ -131,9 +130,9 @@ static struct iucv_handler hvc_iucv_handler = {
>    */
>   static struct hvc_iucv_private *hvc_iucv_get_private(uint32_t num)
>   {
> -	if ((num < HVC_IUCV_MAGIC) || (num - HVC_IUCV_MAGIC > hvc_iucv_devices))
> +	if (num > hvc_iucv_devices)
>   		return NULL;
> -	return hvc_iucv_table[num - HVC_IUCV_MAGIC];
> +	return hvc_iucv_table[num];
>   }
>   
>   /**
> @@ -1072,8 +1071,8 @@ static int __init hvc_iucv_alloc(int id, unsigned int is_console)
>   	priv->is_console = is_console;
>   
>   	/* allocate hvc device */
> -	priv->hvc = hvc_alloc(HVC_IUCV_MAGIC + id, /*		  PAGE_SIZE */
> -			      HVC_IUCV_MAGIC + id, &hvc_iucv_ops, 256);
> +	priv->hvc = hvc_alloc(id, /*		 PAGE_SIZE */
> +			      id, &hvc_iucv_ops, 256);
>   	if (IS_ERR(priv->hvc)) {
>   		rc = PTR_ERR(priv->hvc);
>   		goto out_error_hvc;
> @@ -1371,7 +1370,7 @@ static int __init hvc_iucv_init(void)
>   
>   	/* register the first terminal device as console
>   	 * (must be done before allocating hvc terminal devices) */
> -	rc = hvc_instantiate(HVC_IUCV_MAGIC, IUCV_HVC_CON_IDX, &hvc_iucv_ops);
> +	rc = hvc_instantiate(0, IUCV_HVC_CON_IDX, &hvc_iucv_ops);
>   	if (rc) {
>   		pr_err("Registering HVC terminal device as "
>   		       "Linux console failed\n");

-- 
js
suse labs


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/5] tty: remove TTY_MAGIC
  2022-09-16  1:54 [PATCH 1/5] tty: remove TTY_MAGIC наб
                   ` (4 preceding siblings ...)
  2022-09-16  6:51 ` [PATCH 1/5] tty: remove TTY_MAGIC Jiri Slaby
@ 2022-09-16  7:33 ` Theodore Ts'o
  2022-09-16  8:45   ` Jiri Slaby
  2022-09-22 14:12 ` Greg Kroah-Hartman
  6 siblings, 1 reply; 14+ messages in thread
From: Theodore Ts'o @ 2022-09-16  7:33 UTC (permalink / raw)
  To: наб
  Cc: Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Greg Kroah-Hartman, Jiri Slaby, linux-doc, linux-kernel,
	linux-doc-tw-discuss

On Fri, Sep 16, 2022 at 03:54:59AM +0200, наб wrote:
> 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"
> 
> Ref: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/

Well, I would disagree with Greg K-H on this --- but I haven't been
tty maintainer in well over a decade.  Assuming code is Bug-Free(tm),
sure, it's not necessary.  But there is any kind of memory bug (e.g.,
a corrupted pointer, a use-after free, some other structure
corruption), this catches the problem earlier rather than later, and
it's a light-weight to do a quick sanity check.

It has certainly caught problems in the past, and I still use this
programming technique in programs that I do maintain, such as
e2fsprogs.

But it's not a big deal either way,

						- Ted

P.S. BTW, I didn't make up this technique; it's a program pattern
first used in Multics.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/5] tty: remove TTY_MAGIC
  2022-09-16  7:33 ` Theodore Ts'o
@ 2022-09-16  8:45   ` Jiri Slaby
  0 siblings, 0 replies; 14+ messages in thread
From: Jiri Slaby @ 2022-09-16  8:45 UTC (permalink / raw)
  To: Theodore Ts'o, наб
  Cc: Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Greg Kroah-Hartman, linux-doc, linux-kernel,
	linux-doc-tw-discuss

On 16. 09. 22, 9:33, Theodore Ts'o wrote:
> On Fri, Sep 16, 2022 at 03:54:59AM +0200, наб wrote:
>> 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"
>>
>> Ref: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
> 
> Well, I would disagree with Greg K-H on this --- but I haven't been
> tty maintainer in well over a decade.  Assuming code is Bug-Free(tm),
> sure, it's not necessary.  But there is any kind of memory bug (e.g.,
> a corrupted pointer,

I don't think it can help with corrupted pointer much, but:

> a use-after free, some other structure
> corruption), this catches the problem earlier rather than later, and
> it's a light-weight to do a quick sanity check.

Although it's light-weight, it's also NOT that useful. Maybe tty 
_userspace_ functions return EIO, but that's about it (kernel does not 
check magic in any of its code paths, if I am looking correctly). I bet 
users would notice a corrupted tty structure even without this, and 
maybe earlier. And in that case, kmemcheck is next on the list. And that 
tells us much more than "we are corrupted".

> It has certainly caught problems in the past, and I still use this
> programming technique in programs that I do maintain, such as
> e2fsprogs.

Asking google about:
"tty_paranoia_check" "bad magic number"
gives ~149 results, the last one from 2008. And it seems to be the only 
report, the others are links to sources. So yes, it triggered at least 
once, but is it that useful? Looking at the results, I don't think so.

thanks,
-- 
js
suse labs


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/5] tty: remove TTY_MAGIC
  2022-09-16  1:54 [PATCH 1/5] tty: remove TTY_MAGIC наб
                   ` (5 preceding siblings ...)
  2022-09-16  7:33 ` Theodore Ts'o
@ 2022-09-22 14:12 ` Greg Kroah-Hartman
  6 siblings, 0 replies; 14+ messages in thread
From: Greg Kroah-Hartman @ 2022-09-22 14:12 UTC (permalink / raw)
  To: наб
  Cc: Jonathan Corbet, Federico Vaga, Alex Shi, Yanteng Si, Hu Haowen,
	Jiri Slaby, linux-doc, linux-kernel, linux-doc-tw-discuss

On Fri, Sep 16, 2022 at 03:54:59AM +0200, наб wrote:
> 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"
> 
> Ref: https://lore.kernel.org/linux-doc/YyMlovoskUcHLEb7@kroah.com/
> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
> ---
> Whole series: amd64 allyesconfig builds; amd64 Debian config boots and
> appears to work; naturally, the HVC stuff is S/390 only, but it's a
> constant offset

Many thanks for this cleanup, now queued up.

greg k-h

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-09-22 14:13 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-16  1:54 [PATCH 1/5] tty: remove TTY_MAGIC наб
2022-09-16  1:55 ` [PATCH 2/5] tty: remove TTY_DRIVER_MAGIC наб
2022-09-16  6:51   ` Jiri Slaby
2022-09-16  1:55 ` [PATCH 3/5] tty: n_hdlc: remove HDLC_MAGIC наб
2022-09-16  6:51   ` Jiri Slaby
2022-09-16  1:55 ` [PATCH 4/5] tty: synclink_gt: remove MGSL_MAGIC наб
2022-09-16  6:52   ` Jiri Slaby
2022-09-16  1:55 ` [PATCH 5/5] tty: hvc: remove HVC_IUCV_MAGIC наб
2022-09-16  1:55   ` наб
2022-09-16  6:52   ` Jiri Slaby
2022-09-16  6:51 ` [PATCH 1/5] tty: remove TTY_MAGIC Jiri Slaby
2022-09-16  7:33 ` Theodore Ts'o
2022-09-16  8:45   ` Jiri Slaby
2022-09-22 14:12 ` Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.