Commit 608edd96 authored by Arnaud Pouliquen's avatar Arnaud Pouliquen Committed by Bjorn Andersson

rpmsg: Create the rpmsg class in core instead of in rpmsg char

Migrate the creation of the rpmsg class from the rpmsg_char
to the core that the class is usable by the rpmsg_char and
the future rpmsg_ctrl module.
Suggested-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: default avatarArnaud Pouliquen <arnaud.pouliquen@foss.st.com>
Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20220124102524.295783-3-arnaud.pouliquen@foss.st.com
parent 69265bc1
...@@ -27,11 +27,11 @@ ...@@ -27,11 +27,11 @@
#include <uapi/linux/rpmsg.h> #include <uapi/linux/rpmsg.h>
#include "rpmsg_char.h" #include "rpmsg_char.h"
#include "rpmsg_internal.h"
#define RPMSG_DEV_MAX (MINORMASK + 1) #define RPMSG_DEV_MAX (MINORMASK + 1)
static dev_t rpmsg_major; static dev_t rpmsg_major;
static struct class *rpmsg_class;
static DEFINE_IDA(rpmsg_ctrl_ida); static DEFINE_IDA(rpmsg_ctrl_ida);
static DEFINE_IDA(rpmsg_ept_ida); static DEFINE_IDA(rpmsg_ept_ida);
...@@ -550,17 +550,9 @@ static int rpmsg_chrdev_init(void) ...@@ -550,17 +550,9 @@ static int rpmsg_chrdev_init(void)
return ret; return ret;
} }
rpmsg_class = class_create(THIS_MODULE, "rpmsg");
if (IS_ERR(rpmsg_class)) {
pr_err("failed to create rpmsg class\n");
unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX);
return PTR_ERR(rpmsg_class);
}
ret = register_rpmsg_driver(&rpmsg_chrdev_driver); ret = register_rpmsg_driver(&rpmsg_chrdev_driver);
if (ret < 0) { if (ret < 0) {
pr_err("failed to register rpmsg driver\n"); pr_err("failed to register rpmsg driver\n");
class_destroy(rpmsg_class);
unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX);
} }
...@@ -571,7 +563,6 @@ postcore_initcall(rpmsg_chrdev_init); ...@@ -571,7 +563,6 @@ postcore_initcall(rpmsg_chrdev_init);
static void rpmsg_chrdev_exit(void) static void rpmsg_chrdev_exit(void)
{ {
unregister_rpmsg_driver(&rpmsg_chrdev_driver); unregister_rpmsg_driver(&rpmsg_chrdev_driver);
class_destroy(rpmsg_class);
unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX);
} }
module_exit(rpmsg_chrdev_exit); module_exit(rpmsg_chrdev_exit);
......
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
#include "rpmsg_internal.h" #include "rpmsg_internal.h"
struct class *rpmsg_class;
EXPORT_SYMBOL(rpmsg_class);
/** /**
* rpmsg_create_channel() - create a new rpmsg channel * rpmsg_create_channel() - create a new rpmsg channel
* using its name and address info. * using its name and address info.
...@@ -662,10 +665,17 @@ static int __init rpmsg_init(void) ...@@ -662,10 +665,17 @@ static int __init rpmsg_init(void)
{ {
int ret; int ret;
rpmsg_class = class_create(THIS_MODULE, "rpmsg");
if (IS_ERR(rpmsg_class)) {
pr_err("failed to create rpmsg class\n");
return PTR_ERR(rpmsg_class);
}
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);
}
return ret; return ret;
} }
postcore_initcall(rpmsg_init); postcore_initcall(rpmsg_init);
...@@ -673,6 +683,7 @@ postcore_initcall(rpmsg_init); ...@@ -673,6 +683,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);
} }
module_exit(rpmsg_fini); module_exit(rpmsg_fini);
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#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;
/** /**
* struct rpmsg_device_ops - indirection table for the rpmsg_device operations * struct rpmsg_device_ops - indirection table for the rpmsg_device operations
* @create_channel: create backend-specific channel, optional * @create_channel: create backend-specific channel, optional
......
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