Commit 479b4bc8 authored by Ricardo B. Marliere's avatar Ricardo B. Marliere Committed by Jakub Kicinski

isdn: mISDN: make elements_class constant

Since commit 43a7206b ("driver core: class: make class_register() take
a const *"), the driver core allows for struct class to be in read-only
memory, so move the elements_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: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarRicardo B. Marliere <ricardo@marliere.net>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20240305-class_cleanup-isdn-v1-1-6f0edca75b61@marliere.netSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent b7241321
...@@ -31,7 +31,9 @@ struct dsp_element_entry { ...@@ -31,7 +31,9 @@ struct dsp_element_entry {
static LIST_HEAD(dsp_elements); static LIST_HEAD(dsp_elements);
/* sysfs */ /* sysfs */
static struct class *elements_class; static const struct class elements_class = {
.name = "dsp_pipeline",
};
static ssize_t static ssize_t
attr_show_args(struct device *dev, struct device_attribute *attr, char *buf) attr_show_args(struct device *dev, struct device_attribute *attr, char *buf)
...@@ -80,7 +82,7 @@ int mISDN_dsp_element_register(struct mISDN_dsp_element *elem) ...@@ -80,7 +82,7 @@ int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
INIT_LIST_HEAD(&entry->list); INIT_LIST_HEAD(&entry->list);
entry->elem = elem; entry->elem = elem;
entry->dev.class = elements_class; entry->dev.class = &elements_class;
entry->dev.release = mISDN_dsp_dev_release; entry->dev.release = mISDN_dsp_dev_release;
dev_set_drvdata(&entry->dev, elem); dev_set_drvdata(&entry->dev, elem);
dev_set_name(&entry->dev, "%s", elem->name); dev_set_name(&entry->dev, "%s", elem->name);
...@@ -131,9 +133,11 @@ EXPORT_SYMBOL(mISDN_dsp_element_unregister); ...@@ -131,9 +133,11 @@ EXPORT_SYMBOL(mISDN_dsp_element_unregister);
int dsp_pipeline_module_init(void) int dsp_pipeline_module_init(void)
{ {
elements_class = class_create("dsp_pipeline"); int err;
if (IS_ERR(elements_class))
return PTR_ERR(elements_class); err = class_register(&elements_class);
if (err)
return err;
dsp_hwec_init(); dsp_hwec_init();
...@@ -146,7 +150,7 @@ void dsp_pipeline_module_exit(void) ...@@ -146,7 +150,7 @@ void dsp_pipeline_module_exit(void)
dsp_hwec_exit(); dsp_hwec_exit();
class_destroy(elements_class); class_unregister(&elements_class);
list_for_each_entry_safe(entry, n, &dsp_elements, list) { list_for_each_entry_safe(entry, n, &dsp_elements, list) {
list_del(&entry->list); list_del(&entry->list);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment