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

misc: hpilo: make ilo_class a static const structure

Now that the driver core allows for struct class to be in read-only
memory, move the ilo_class structure to be declared at build time
placing it into read-only memory, instead of having to be dynamically
allocated at boot time.

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Link: https://lore.kernel.org/r/20230810194239.26892-1-ivan.orlov0322@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ivan Orlov and committed by
Greg Kroah-Hartman
fd06978b b5fa3379

+9 -9
+9 -9
drivers/misc/hpilo.c
··· 25 25 #include <linux/slab.h> 26 26 #include "hpilo.h" 27 27 28 - static struct class *ilo_class; 28 + static const struct class ilo_class = { 29 + .name = "iLO", 30 + }; 29 31 static unsigned int ilo_major; 30 32 static unsigned int max_ccb = 16; 31 33 static char ilo_hwdev[MAX_ILO_DEV]; ··· 748 746 749 747 minor = MINOR(ilo_hw->cdev.dev); 750 748 for (i = minor; i < minor + max_ccb; i++) 751 - device_destroy(ilo_class, MKDEV(ilo_major, i)); 749 + device_destroy(&ilo_class, MKDEV(ilo_major, i)); 752 750 753 751 cdev_del(&ilo_hw->cdev); 754 752 ilo_disable_interrupts(ilo_hw); ··· 841 839 842 840 for (minor = 0 ; minor < max_ccb; minor++) { 843 841 struct device *dev; 844 - dev = device_create(ilo_class, &pdev->dev, 842 + dev = device_create(&ilo_class, &pdev->dev, 845 843 MKDEV(ilo_major, minor), NULL, 846 844 "hpilo!d%dccb%d", devnum, minor); 847 845 if (IS_ERR(dev)) ··· 884 882 int error; 885 883 dev_t dev; 886 884 887 - ilo_class = class_create("iLO"); 888 - if (IS_ERR(ilo_class)) { 889 - error = PTR_ERR(ilo_class); 885 + error = class_register(&ilo_class); 886 + if (error) 890 887 goto out; 891 - } 892 888 893 889 error = alloc_chrdev_region(&dev, 0, MAX_OPEN, ILO_NAME); 894 890 if (error) ··· 902 902 chr_remove: 903 903 unregister_chrdev_region(dev, MAX_OPEN); 904 904 class_destroy: 905 - class_destroy(ilo_class); 905 + class_unregister(&ilo_class); 906 906 out: 907 907 return error; 908 908 } ··· 911 911 { 912 912 pci_unregister_driver(&ilo_driver); 913 913 unregister_chrdev_region(MKDEV(ilo_major, 0), MAX_OPEN); 914 - class_destroy(ilo_class); 914 + class_unregister(&ilo_class); 915 915 } 916 916 917 917 MODULE_VERSION("1.5.0");