mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-17 02:36:21 +00:00
vfio/mbochs: make mbochs_class constant
Since commit 43a7206b0963 ("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 mbochs_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: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net> Link: https://lore.kernel.org/r/20240301-class_cleanup-vfio-v1-2-9236d69083f5@marliere.net Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
parent
1f92d6a7c6
commit
626f534d77
@ -133,7 +133,9 @@ static struct mdev_type *mbochs_mdev_types[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static dev_t mbochs_devt;
|
static dev_t mbochs_devt;
|
||||||
static struct class *mbochs_class;
|
static const struct class mbochs_class = {
|
||||||
|
.name = MBOCHS_CLASS_NAME,
|
||||||
|
};
|
||||||
static struct cdev mbochs_cdev;
|
static struct cdev mbochs_cdev;
|
||||||
static struct device mbochs_dev;
|
static struct device mbochs_dev;
|
||||||
static struct mdev_parent mbochs_parent;
|
static struct mdev_parent mbochs_parent;
|
||||||
@ -1422,13 +1424,10 @@ static int __init mbochs_dev_init(void)
|
|||||||
if (ret)
|
if (ret)
|
||||||
goto err_cdev;
|
goto err_cdev;
|
||||||
|
|
||||||
mbochs_class = class_create(MBOCHS_CLASS_NAME);
|
ret = class_register(&mbochs_class);
|
||||||
if (IS_ERR(mbochs_class)) {
|
if (ret)
|
||||||
pr_err("Error: failed to register mbochs_dev class\n");
|
|
||||||
ret = PTR_ERR(mbochs_class);
|
|
||||||
goto err_driver;
|
goto err_driver;
|
||||||
}
|
mbochs_dev.class = &mbochs_class;
|
||||||
mbochs_dev.class = mbochs_class;
|
|
||||||
mbochs_dev.release = mbochs_device_release;
|
mbochs_dev.release = mbochs_device_release;
|
||||||
dev_set_name(&mbochs_dev, "%s", MBOCHS_NAME);
|
dev_set_name(&mbochs_dev, "%s", MBOCHS_NAME);
|
||||||
|
|
||||||
@ -1448,7 +1447,7 @@ err_device:
|
|||||||
device_del(&mbochs_dev);
|
device_del(&mbochs_dev);
|
||||||
err_put:
|
err_put:
|
||||||
put_device(&mbochs_dev);
|
put_device(&mbochs_dev);
|
||||||
class_destroy(mbochs_class);
|
class_unregister(&mbochs_class);
|
||||||
err_driver:
|
err_driver:
|
||||||
mdev_unregister_driver(&mbochs_driver);
|
mdev_unregister_driver(&mbochs_driver);
|
||||||
err_cdev:
|
err_cdev:
|
||||||
@ -1466,8 +1465,7 @@ static void __exit mbochs_dev_exit(void)
|
|||||||
mdev_unregister_driver(&mbochs_driver);
|
mdev_unregister_driver(&mbochs_driver);
|
||||||
cdev_del(&mbochs_cdev);
|
cdev_del(&mbochs_cdev);
|
||||||
unregister_chrdev_region(mbochs_devt, MINORMASK + 1);
|
unregister_chrdev_region(mbochs_devt, MINORMASK + 1);
|
||||||
class_destroy(mbochs_class);
|
class_unregister(&mbochs_class);
|
||||||
mbochs_class = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MODULE_IMPORT_NS(DMA_BUF);
|
MODULE_IMPORT_NS(DMA_BUF);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user