]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tty: vc_screen: make vc_class constant
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Oct 2023 13:33:48 +0000 (15:33 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 7 Oct 2023 09:18:51 +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/2023100549-sixth-anger-ac34@gregkh
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/vt/vc_screen.c

index 99c8e39d91b4b155c3d393a045e7a747ae2b9e50..67e2cb7c96eec47e85eacc97e64109235901d373 100644 (file)
@@ -786,23 +786,22 @@ static const struct file_operations vcs_fops = {
        .release        = vcs_release,
 };
 
-static struct class *vc_class;
+static const struct class vc_class = {
+       .name = "vc",
+};
 
 void vcs_make_sysfs(int index)
 {
-       device_create(vc_class, NULL, MKDEV(VCS_MAJOR, index + 1), NULL,
-                     "vcs%u", index + 1);
-       device_create(vc_class, NULL, MKDEV(VCS_MAJOR, index + 65), NULL,
-                     "vcsu%u", index + 1);
-       device_create(vc_class, NULL, MKDEV(VCS_MAJOR, index + 129), NULL,
-                     "vcsa%u", index + 1);
+       device_create(&vc_class, NULL, MKDEV(VCS_MAJOR, index + 1), NULL, "vcs%u", index + 1);
+       device_create(&vc_class, NULL, MKDEV(VCS_MAJOR, index + 65), NULL, "vcsu%u", index + 1);
+       device_create(&vc_class, NULL, MKDEV(VCS_MAJOR, index + 129), NULL, "vcsa%u", index + 1);
 }
 
 void vcs_remove_sysfs(int index)
 {
-       device_destroy(vc_class, MKDEV(VCS_MAJOR, index + 1));
-       device_destroy(vc_class, MKDEV(VCS_MAJOR, index + 65));
-       device_destroy(vc_class, MKDEV(VCS_MAJOR, index + 129));
+       device_destroy(&vc_class, MKDEV(VCS_MAJOR, index + 1));
+       device_destroy(&vc_class, MKDEV(VCS_MAJOR, index + 65));
+       device_destroy(&vc_class, MKDEV(VCS_MAJOR, index + 129));
 }
 
 int __init vcs_init(void)
@@ -811,11 +810,12 @@ int __init vcs_init(void)
 
        if (register_chrdev(VCS_MAJOR, "vcs", &vcs_fops))
                panic("unable to get major %d for vcs device", VCS_MAJOR);
-       vc_class = class_create("vc");
+       if (class_register(&vc_class))
+               panic("unable to create vc_class");
 
-       device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
-       device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 64), NULL, "vcsu");
-       device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
+       device_create(&vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
+       device_create(&vc_class, NULL, MKDEV(VCS_MAJOR, 64), NULL, "vcsu");
+       device_create(&vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
        for (i = 0; i < MIN_NR_CONSOLES; i++)
                vcs_make_sysfs(i);
        return 0;