tty: hvc: remove HVC_IUCV_MAGIC
authorнаб <nabijaczleweli@nabijaczleweli.xyz>
Fri, 16 Sep 2022 01:55:18 +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"

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

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/8c8a2c9dfc1bfbe6ef3f3237368e483865fc1c29.1663288066.git.nabijaczleweli@nabijaczleweli.xyz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/hvc/hvc_iucv.c

index 32366caca6623e23ffb19a8d40108fbf6daeb896..7d49a872de48ab89033063492622165180afda78 100644 (file)
@@ -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");