tty: n_hdlc: remove HDLC_MAGIC
authorнаб <nabijaczleweli@nabijaczleweli.xyz>
Fri, 16 Sep 2022 01:55:09 +0000 (03:55 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 Sep 2022 14:12:34 +0000 (16:12 +0200)
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/c31d228302da3f426cebf6fcff855181a5590a66.1663288066.git.nabijaczleweli@nabijaczleweli.xyz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Documentation/process/magic-number.rst
Documentation/translations/it_IT/process/magic-number.rst
Documentation/translations/zh_CN/process/magic-number.rst
Documentation/translations/zh_TW/process/magic-number.rst
drivers/tty/n_hdlc.c

index d47799ba0ca492cc9ff869927acaeb316314f2e5..fdaa3e4b195350835c25a19749ba3bbff9c71212 100644 (file)
@@ -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``
index 24022ab52ebb01e2ccf7a57b9c1bb22370865ece..1898f98875de3978df1e257aa886a0dc6c30f8f7 100644 (file)
@@ -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``
index 8118049962834e3f1ecad615adca51325a7eeaa8..911cdaeaf69840752a4b946be3be3d66b0049f94 100644 (file)
@@ -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``
index 8e37e00590f546572f205431957d43c2c5178e76..ac87f188235f3632e4a5d70960605eb125045874 100644 (file)
@@ -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``
index 5540d9be65ead8cf5b2c5f1e5e4fef7a9ac3fa05..46b09bfb6f3a1c6af3e48a738be0183c79ea46dc 100644 (file)
@@ -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>
@@ -123,7 +121,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
@@ -132,7 +129,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;
@@ -199,10 +195,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
@@ -385,12 +377,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;
@@ -541,9 +527,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",
@@ -608,10 +591,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 */
@@ -672,9 +651,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)
@@ -738,9 +714,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() */