summaryrefslogtreecommitdiff
path: root/drivers/rapidio/rio_cm.c
diff options
context:
space:
mode:
authorIvan Orlov <ivan.orlov0322@gmail.com>2023-08-10 22:51:03 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-10-05 14:51:35 +0300
commitd712d205210c494c29f33dc1d1f2ce4d7448faa9 (patch)
treecd18e099535e29c5043809ca552aeb9f35695c27 /drivers/rapidio/rio_cm.c
parent4f01342464a8a99bf0cbb45a3ce4cf44a8baa1c5 (diff)
downloadlinux-d712d205210c494c29f33dc1d1f2ce4d7448faa9.tar.xz
rapidio: make all 'class' structures const
Now that the driver core allows for struct class to be in read-only memory, making all 'class' structures to be declared at build time placing them into read-only memory, instead of having to be dynamically allocated at load time. Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com> Link: https://lore.kernel.org/r/20230810195103.27069-1-ivan.orlov0322@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/rapidio/rio_cm.c')
-rw-r--r--drivers/rapidio/rio_cm.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/rapidio/rio_cm.c b/drivers/rapidio/rio_cm.c
index 49f8d111e546..9135227301c8 100644
--- a/drivers/rapidio/rio_cm.c
+++ b/drivers/rapidio/rio_cm.c
@@ -233,7 +233,9 @@ static DEFINE_IDR(ch_idr);
static LIST_HEAD(cm_dev_list);
static DECLARE_RWSEM(rdev_sem);
-static struct class *dev_class;
+static const struct class dev_class = {
+ .name = DRV_NAME,
+};
static unsigned int dev_major;
static unsigned int dev_minor_base;
static dev_t dev_number;
@@ -2072,7 +2074,7 @@ static int riocm_cdev_add(dev_t devno)
return ret;
}
- riocm_cdev.dev = device_create(dev_class, NULL, devno, NULL, DEV_NAME);
+ riocm_cdev.dev = device_create(&dev_class, NULL, devno, NULL, DEV_NAME);
if (IS_ERR(riocm_cdev.dev)) {
cdev_del(&riocm_cdev.cdev);
return PTR_ERR(riocm_cdev.dev);
@@ -2293,15 +2295,15 @@ static int __init riocm_init(void)
int ret;
/* Create device class needed by udev */
- dev_class = class_create(DRV_NAME);
- if (IS_ERR(dev_class)) {
+ ret = class_register(&dev_class);
+ if (ret) {
riocm_error("Cannot create " DRV_NAME " class");
- return PTR_ERR(dev_class);
+ return ret;
}
ret = alloc_chrdev_region(&dev_number, 0, 1, DRV_NAME);
if (ret) {
- class_destroy(dev_class);
+ class_unregister(&dev_class);
return ret;
}
@@ -2349,7 +2351,7 @@ err_cl:
class_interface_unregister(&rio_mport_interface);
err_reg:
unregister_chrdev_region(dev_number, 1);
- class_destroy(dev_class);
+ class_unregister(&dev_class);
return ret;
}
@@ -2364,7 +2366,7 @@ static void __exit riocm_exit(void)
device_unregister(riocm_cdev.dev);
cdev_del(&(riocm_cdev.cdev));
- class_destroy(dev_class);
+ class_unregister(&dev_class);
unregister_chrdev_region(dev_number, 1);
}