Skip to content

Commit 0ad1d9f

Browse files
rbmarlierehcahca
authored andcommitted
s390/vmur: make vmur_class constant
Since commit 43a7206 ("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 vmur_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 <[email protected]> Suggested-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: "Ricardo B. Marliere" <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Heiko Carstens <[email protected]>
1 parent b11cc9e commit 0ad1d9f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/s390/char/vmur.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ MODULE_DESCRIPTION("s390 z/VM virtual unit record device driver");
4848
MODULE_LICENSE("GPL");
4949

5050
static dev_t ur_first_dev_maj_min;
51-
static struct class *vmur_class;
51+
static const struct class vmur_class = {
52+
.name = "vmur",
53+
};
5254
static struct debug_info *vmur_dbf;
5355

5456
/* We put the device's record length (for writes) in the driver_info field */
@@ -912,7 +914,7 @@ static int ur_set_online(struct ccw_device *cdev)
912914
goto fail_free_cdev;
913915
}
914916

915-
urd->device = device_create(vmur_class, &cdev->dev,
917+
urd->device = device_create(&vmur_class, &cdev->dev,
916918
urd->char_device->dev, NULL, "%s", node_id);
917919
if (IS_ERR(urd->device)) {
918920
rc = PTR_ERR(urd->device);
@@ -958,7 +960,7 @@ static int ur_set_offline_force(struct ccw_device *cdev, int force)
958960
/* Work not run yet - need to release reference here */
959961
urdev_put(urd);
960962
}
961-
device_destroy(vmur_class, urd->char_device->dev);
963+
device_destroy(&vmur_class, urd->char_device->dev);
962964
cdev_del(urd->char_device);
963965
urd->char_device = NULL;
964966
rc = 0;
@@ -1022,11 +1024,9 @@ static int __init ur_init(void)
10221024

10231025
debug_set_level(vmur_dbf, 6);
10241026

1025-
vmur_class = class_create("vmur");
1026-
if (IS_ERR(vmur_class)) {
1027-
rc = PTR_ERR(vmur_class);
1027+
rc = class_register(&vmur_class);
1028+
if (rc)
10281029
goto fail_free_dbf;
1029-
}
10301030

10311031
rc = ccw_driver_register(&ur_driver);
10321032
if (rc)
@@ -1046,7 +1046,7 @@ static int __init ur_init(void)
10461046
fail_unregister_driver:
10471047
ccw_driver_unregister(&ur_driver);
10481048
fail_class_destroy:
1049-
class_destroy(vmur_class);
1049+
class_unregister(&vmur_class);
10501050
fail_free_dbf:
10511051
debug_unregister(vmur_dbf);
10521052
return rc;
@@ -1056,7 +1056,7 @@ static void __exit ur_exit(void)
10561056
{
10571057
unregister_chrdev_region(ur_first_dev_maj_min, NUM_MINORS);
10581058
ccw_driver_unregister(&ur_driver);
1059-
class_destroy(vmur_class);
1059+
class_unregister(&vmur_class);
10601060
debug_unregister(vmur_dbf);
10611061
pr_info("%s unloaded.\n", ur_banner);
10621062
}

0 commit comments

Comments
 (0)