Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tty: vc_screen: make vc_class constant

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>

+14 -14
+14 -14
drivers/tty/vt/vc_screen.c
··· 786 786 .release = vcs_release, 787 787 }; 788 788 789 - static struct class *vc_class; 789 + static const struct class vc_class = { 790 + .name = "vc", 791 + }; 790 792 791 793 void vcs_make_sysfs(int index) 792 794 { 793 - device_create(vc_class, NULL, MKDEV(VCS_MAJOR, index + 1), NULL, 794 - "vcs%u", index + 1); 795 - device_create(vc_class, NULL, MKDEV(VCS_MAJOR, index + 65), NULL, 796 - "vcsu%u", index + 1); 797 - device_create(vc_class, NULL, MKDEV(VCS_MAJOR, index + 129), NULL, 798 - "vcsa%u", index + 1); 795 + device_create(&vc_class, NULL, MKDEV(VCS_MAJOR, index + 1), NULL, "vcs%u", index + 1); 796 + device_create(&vc_class, NULL, MKDEV(VCS_MAJOR, index + 65), NULL, "vcsu%u", index + 1); 797 + device_create(&vc_class, NULL, MKDEV(VCS_MAJOR, index + 129), NULL, "vcsa%u", index + 1); 799 798 } 800 799 801 800 void vcs_remove_sysfs(int index) 802 801 { 803 - device_destroy(vc_class, MKDEV(VCS_MAJOR, index + 1)); 804 - device_destroy(vc_class, MKDEV(VCS_MAJOR, index + 65)); 805 - device_destroy(vc_class, MKDEV(VCS_MAJOR, index + 129)); 802 + device_destroy(&vc_class, MKDEV(VCS_MAJOR, index + 1)); 803 + device_destroy(&vc_class, MKDEV(VCS_MAJOR, index + 65)); 804 + device_destroy(&vc_class, MKDEV(VCS_MAJOR, index + 129)); 806 805 } 807 806 808 807 int __init vcs_init(void) ··· 810 811 811 812 if (register_chrdev(VCS_MAJOR, "vcs", &vcs_fops)) 812 813 panic("unable to get major %d for vcs device", VCS_MAJOR); 813 - vc_class = class_create("vc"); 814 + if (class_register(&vc_class)) 815 + panic("unable to create vc_class"); 814 816 815 - device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs"); 816 - device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 64), NULL, "vcsu"); 817 - device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa"); 817 + device_create(&vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs"); 818 + device_create(&vc_class, NULL, MKDEV(VCS_MAJOR, 64), NULL, "vcsu"); 819 + device_create(&vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa"); 818 820 for (i = 0; i < MIN_NR_CONSOLES; i++) 819 821 vcs_make_sysfs(i); 820 822 return 0;