]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
most: replace cdev_component->class with a const struct class
authorJori Koolstra <jkoolstra@xs4all.nl>
Wed, 1 Apr 2026 17:00:43 +0000 (19:00 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Apr 2026 14:32:57 +0000 (16:32 +0200)
The class_create() call has been deprecated in favor of class_register()
as the driver core now allows for a struct class to be in read-only
memory. Replace cdev_component->class with a const struct class and drop
the class_create() call. Compile tested only.

Link: https://lore.kernel.org/all/2023040244-duffel-pushpin-f738@gregkh/
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jori Koolstra <jkoolstra@xs4all.nl>
Link: https://patch.msgid.link/20260401170043.3844117-1-jkoolstra@xs4all.nl
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/most/most_cdev.c

index b31dc824466f1f3eff6856da331eaf202956be97..5df508d8d60adb9d741f8061907350153a358330 100644 (file)
 
 #define CHRDEV_REGION_SIZE 50
 
+static const struct class most_cdev_class = {
+       .name           = "most_cdev"
+};
+
 static struct cdev_component {
        dev_t devno;
        struct ida minor_id;
        unsigned int major;
-       struct class *class;
        struct most_component cc;
 } comp;
 
@@ -91,7 +94,7 @@ static void destroy_cdev(struct comp_channel *c)
 {
        unsigned long flags;
 
-       device_destroy(comp.class, c->devno);
+       device_destroy(&most_cdev_class, c->devno);
        cdev_del(&c->cdev);
        spin_lock_irqsave(&ch_list_lock, flags);
        list_del(&c->list);
@@ -455,7 +458,7 @@ static int comp_probe(struct most_interface *iface, int channel_id,
        spin_lock_irqsave(&ch_list_lock, cl_flags);
        list_add_tail(&c->list, &channel_list);
        spin_unlock_irqrestore(&ch_list_lock, cl_flags);
-       c->dev = device_create(comp.class, NULL, c->devno, NULL, "%s", name);
+       c->dev = device_create(&most_cdev_class, NULL, c->devno, NULL, "%s", name);
 
        if (IS_ERR(c->dev)) {
                retval = PTR_ERR(c->dev);
@@ -487,13 +490,14 @@ static struct cdev_component comp = {
        },
 };
 
+
 static int __init most_cdev_init(void)
 {
        int err;
 
-       comp.class = class_create("most_cdev");
-       if (IS_ERR(comp.class))
-               return PTR_ERR(comp.class);
+       err = class_register(&most_cdev_class);
+       if (err)
+               return err;
 
        ida_init(&comp.minor_id);
 
@@ -515,7 +519,7 @@ free_cdev:
        unregister_chrdev_region(comp.devno, CHRDEV_REGION_SIZE);
 dest_ida:
        ida_destroy(&comp.minor_id);
-       class_destroy(comp.class);
+       class_unregister(&most_cdev_class);
        return err;
 }
 
@@ -532,7 +536,7 @@ static void __exit most_cdev_exit(void)
        }
        unregister_chrdev_region(comp.devno, CHRDEV_REGION_SIZE);
        ida_destroy(&comp.minor_id);
-       class_destroy(comp.class);
+       class_unregister(&most_cdev_class);
 }
 
 module_init(most_cdev_init);