]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
devfreq: change devfreq_event_class to a const struct
authorJori Koolstra <jkoolstra@xs4all.nl>
Tue, 3 Mar 2026 16:25:04 +0000 (17:25 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 22 May 2026 11:28:46 +0000 (13:28 +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. Change devfreq_event_class to be a const struct class and drop
the class_create() call. Compile tested.

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/20260303162505.3748001-1-jkoolstra@xs4all.nl
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/devfreq/devfreq-event.c

index 179de3cf6d6ccef13e7afdee8d8227f4a0cb2de8..9e183cd8818c178501d0faf6fce30122adf2fb56 100644 (file)
 #include <linux/list.h>
 #include <linux/of.h>
 
-static struct class *devfreq_event_class;
+static struct attribute *devfreq_event_attrs[];
+ATTRIBUTE_GROUPS(devfreq_event);
+
+static const struct class devfreq_event_class = {
+       .name           = "devfreq-event",
+       .dev_groups     = devfreq_event_groups
+};
 
 /* The list of all devfreq event list */
 static LIST_HEAD(devfreq_event_list);
@@ -321,7 +327,7 @@ struct devfreq_event_dev *devfreq_event_add_edev(struct device *dev,
        edev->desc = desc;
        edev->enable_count = 0;
        edev->dev.parent = dev;
-       edev->dev.class = devfreq_event_class;
+       edev->dev.class = &devfreq_event_class;
        edev->dev.release = devfreq_event_release_edev;
 
        dev_set_name(&edev->dev, "event%d", atomic_inc_return(&event_no));
@@ -461,18 +467,15 @@ static struct attribute *devfreq_event_attrs[] = {
        &dev_attr_enable_count.attr,
        NULL,
 };
-ATTRIBUTE_GROUPS(devfreq_event);
 
 static int __init devfreq_event_init(void)
 {
-       devfreq_event_class = class_create("devfreq-event");
-       if (IS_ERR(devfreq_event_class)) {
-               pr_err("%s: couldn't create class\n", __FILE__);
-               return PTR_ERR(devfreq_event_class);
-       }
+       int err;
 
-       devfreq_event_class->dev_groups = devfreq_event_groups;
+       err = class_register(&devfreq_event_class);
+       if (err)
+               pr_err("%s: couldn't create class\n", __FILE__);
 
-       return 0;
+       return err;
 }
 subsys_initcall(devfreq_event_init);