Commit 12fbd67e authored by Ricardo B. Marliere's avatar Ricardo B. Marliere Committed by Jakub Kicinski

isdn: capi: make capi_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 capi_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-2-6f0edca75b61@marliere.netSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 479b4bc8
...@@ -49,7 +49,9 @@ MODULE_LICENSE("GPL"); ...@@ -49,7 +49,9 @@ MODULE_LICENSE("GPL");
/* -------- driver information -------------------------------------- */ /* -------- driver information -------------------------------------- */
static DEFINE_MUTEX(capi_mutex); static DEFINE_MUTEX(capi_mutex);
static struct class *capi_class; static const struct class capi_class = {
.name = "capi",
};
static int capi_major = 68; /* allocated */ static int capi_major = 68; /* allocated */
module_param_named(major, capi_major, uint, 0); module_param_named(major, capi_major, uint, 0);
...@@ -1393,18 +1395,19 @@ static int __init capi_init(void) ...@@ -1393,18 +1395,19 @@ static int __init capi_init(void)
kcapi_exit(); kcapi_exit();
return major_ret; return major_ret;
} }
capi_class = class_create("capi");
if (IS_ERR(capi_class)) { ret = class_register(&capi_class);
if (ret) {
unregister_chrdev(capi_major, "capi20"); unregister_chrdev(capi_major, "capi20");
kcapi_exit(); kcapi_exit();
return PTR_ERR(capi_class); return ret;
} }
device_create(capi_class, NULL, MKDEV(capi_major, 0), NULL, "capi20"); device_create(&capi_class, NULL, MKDEV(capi_major, 0), NULL, "capi20");
if (capinc_tty_init() < 0) { if (capinc_tty_init() < 0) {
device_destroy(capi_class, MKDEV(capi_major, 0)); device_destroy(&capi_class, MKDEV(capi_major, 0));
class_destroy(capi_class); class_unregister(&capi_class);
unregister_chrdev(capi_major, "capi20"); unregister_chrdev(capi_major, "capi20");
kcapi_exit(); kcapi_exit();
return -ENOMEM; return -ENOMEM;
...@@ -1427,8 +1430,8 @@ static void __exit capi_exit(void) ...@@ -1427,8 +1430,8 @@ static void __exit capi_exit(void)
{ {
proc_exit(); proc_exit();
device_destroy(capi_class, MKDEV(capi_major, 0)); device_destroy(&capi_class, MKDEV(capi_major, 0));
class_destroy(capi_class); class_unregister(&capi_class);
unregister_chrdev(capi_major, "capi20"); unregister_chrdev(capi_major, "capi20");
capinc_tty_exit(); capinc_tty_exit();
......
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