Commit 193d0c4e authored by Ricardo B. Marliere's avatar Ricardo B. Marliere Committed by Mathieu Poirier

rpmsg: core: Make rpmsg_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 rpmsg_class structure to be declared at build time
placing it into read-only memory, instead of having to be dynamically
allocated at boot time.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarRicardo B. Marliere <ricardo@marliere.net>
Link: https://lore.kernel.org/r/20240305-class_cleanup-remoteproc-v1-1-19373374e003@marliere.netSigned-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
parent 4cece764
...@@ -423,7 +423,7 @@ static struct rpmsg_eptdev *rpmsg_chrdev_eptdev_alloc(struct rpmsg_device *rpdev ...@@ -423,7 +423,7 @@ static struct rpmsg_eptdev *rpmsg_chrdev_eptdev_alloc(struct rpmsg_device *rpdev
init_waitqueue_head(&eptdev->readq); init_waitqueue_head(&eptdev->readq);
device_initialize(dev); device_initialize(dev);
dev->class = rpmsg_class; dev->class = &rpmsg_class;
dev->parent = parent; dev->parent = parent;
dev->groups = rpmsg_eptdev_groups; dev->groups = rpmsg_eptdev_groups;
dev_set_drvdata(dev, eptdev); dev_set_drvdata(dev, eptdev);
......
...@@ -20,7 +20,9 @@ ...@@ -20,7 +20,9 @@
#include "rpmsg_internal.h" #include "rpmsg_internal.h"
struct class *rpmsg_class; const struct class rpmsg_class = {
.name = "rpmsg",
};
EXPORT_SYMBOL(rpmsg_class); EXPORT_SYMBOL(rpmsg_class);
/** /**
...@@ -715,16 +717,16 @@ static int __init rpmsg_init(void) ...@@ -715,16 +717,16 @@ static int __init rpmsg_init(void)
{ {
int ret; int ret;
rpmsg_class = class_create("rpmsg"); ret = class_register(&rpmsg_class);
if (IS_ERR(rpmsg_class)) { if (ret) {
pr_err("failed to create rpmsg class\n"); pr_err("failed to register rpmsg class\n");
return PTR_ERR(rpmsg_class); return ret;
} }
ret = bus_register(&rpmsg_bus); ret = bus_register(&rpmsg_bus);
if (ret) { if (ret) {
pr_err("failed to register rpmsg bus: %d\n", ret); pr_err("failed to register rpmsg bus: %d\n", ret);
class_destroy(rpmsg_class); class_destroy(&rpmsg_class);
} }
return ret; return ret;
} }
...@@ -733,7 +735,7 @@ postcore_initcall(rpmsg_init); ...@@ -733,7 +735,7 @@ postcore_initcall(rpmsg_init);
static void __exit rpmsg_fini(void) static void __exit rpmsg_fini(void)
{ {
bus_unregister(&rpmsg_bus); bus_unregister(&rpmsg_bus);
class_destroy(rpmsg_class); class_destroy(&rpmsg_class);
} }
module_exit(rpmsg_fini); module_exit(rpmsg_fini);
......
...@@ -150,7 +150,7 @@ static int rpmsg_ctrldev_probe(struct rpmsg_device *rpdev) ...@@ -150,7 +150,7 @@ static int rpmsg_ctrldev_probe(struct rpmsg_device *rpdev)
dev = &ctrldev->dev; dev = &ctrldev->dev;
device_initialize(dev); device_initialize(dev);
dev->parent = &rpdev->dev; dev->parent = &rpdev->dev;
dev->class = rpmsg_class; dev->class = &rpmsg_class;
mutex_init(&ctrldev->ctrl_lock); mutex_init(&ctrldev->ctrl_lock);
cdev_init(&ctrldev->cdev, &rpmsg_ctrldev_fops); cdev_init(&ctrldev->cdev, &rpmsg_ctrldev_fops);
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#define to_rpmsg_device(d) container_of(d, struct rpmsg_device, dev) #define to_rpmsg_device(d) container_of(d, struct rpmsg_device, dev)
#define to_rpmsg_driver(d) container_of(d, struct rpmsg_driver, drv) #define to_rpmsg_driver(d) container_of(d, struct rpmsg_driver, drv)
extern struct class *rpmsg_class; extern const struct class rpmsg_class;
/** /**
* struct rpmsg_device_ops - indirection table for the rpmsg_device operations * struct rpmsg_device_ops - indirection table for the rpmsg_device operations
......
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