devfreq: change devfreq_event_class to a const struct

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>
This commit is contained in:
Jori Koolstra 2026-03-03 17:25:04 +01:00 committed by Greg Kroah-Hartman
parent b2c885b362
commit bea3649af1

View File

@ -17,7 +17,13 @@
#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)) {
int err;
err = class_register(&devfreq_event_class);
if (err)
pr_err("%s: couldn't create class\n", __FILE__);
return PTR_ERR(devfreq_event_class);
}
devfreq_event_class->dev_groups = devfreq_event_groups;
return 0;
return err;
}
subsys_initcall(devfreq_event_init);