]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tty: vt: make vtconsole_class constant
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Oct 2023 13:33:47 +0000 (15:33 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 7 Oct 2023 09:18:48 +0000 (11:18 +0200)
Now that the driver core allows for struct class to be in read-only
memory, making all 'class' structures to be declared at build time
placing them into read-only memory, instead of having to be dynamically
allocated at load time.

Cc: Jiri Slaby <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/2023100546-humbly-prologue-e58c@gregkh
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/vt/vt.c

index e3bb498a7036cf93fcf2ed03257d045d5a2890a8..156efda7c80d64b3c512d8cc84f228521aefec11 100644 (file)
@@ -3571,7 +3571,9 @@ int __init vty_init(const struct file_operations *console_fops)
        return 0;
 }
 
-static struct class *vtconsole_class;
+static const struct class vtconsole_class = {
+       .name = "vtconsole",
+};
 
 static int do_bind_con_driver(const struct consw *csw, int first, int last,
                           int deflt)
@@ -4098,7 +4100,7 @@ static int do_register_con_driver(const struct consw *csw, int first, int last)
                goto err;
 
        con_driver->dev =
-               device_create_with_groups(vtconsole_class, NULL,
+               device_create_with_groups(&vtconsole_class, NULL,
                                          MKDEV(0, con_driver->node),
                                          con_driver, con_dev_groups,
                                          "vtcon%i", con_driver->node);
@@ -4179,7 +4181,7 @@ static void con_driver_unregister_callback(struct work_struct *ignored)
                console_unlock();
 
                vtconsole_deinit_device(con_driver);
-               device_destroy(vtconsole_class, MKDEV(0, con_driver->node));
+               device_destroy(&vtconsole_class, MKDEV(0, con_driver->node));
 
                console_lock();
 
@@ -4240,12 +4242,9 @@ static int __init vtconsole_class_init(void)
 {
        int i;
 
-       vtconsole_class = class_create("vtconsole");
-       if (IS_ERR(vtconsole_class)) {
-               pr_warn("Unable to create vt console class; errno = %ld\n",
-                       PTR_ERR(vtconsole_class));
-               vtconsole_class = NULL;
-       }
+       i = class_register(&vtconsole_class);
+       if (i)
+               pr_warn("Unable to create vt console class; errno = %d\n", i);
 
        /* Add system drivers to sysfs */
        for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
@@ -4253,7 +4252,7 @@ static int __init vtconsole_class_init(void)
 
                if (con->con && !con->dev) {
                        con->dev =
-                               device_create_with_groups(vtconsole_class, NULL,
+                               device_create_with_groups(&vtconsole_class, NULL,
                                                          MKDEV(0, con->node),
                                                          con, con_dev_groups,
                                                          "vtcon%i", con->node);