Skip to content

Commit

Permalink
s390/vmur: make vmur_class constant
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
rbmarliere authored and hcahca committed Mar 13, 2024
1 parent b11cc9e commit 0ad1d9f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions drivers/s390/char/vmur.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ MODULE_DESCRIPTION("s390 z/VM virtual unit record device driver");
MODULE_LICENSE("GPL");

static dev_t ur_first_dev_maj_min;
static struct class *vmur_class;
static const struct class vmur_class = {
.name = "vmur",
};
static struct debug_info *vmur_dbf;

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

urd->device = device_create(vmur_class, &cdev->dev,
urd->device = device_create(&vmur_class, &cdev->dev,
urd->char_device->dev, NULL, "%s", node_id);
if (IS_ERR(urd->device)) {
rc = PTR_ERR(urd->device);
Expand Down Expand Up @@ -958,7 +960,7 @@ static int ur_set_offline_force(struct ccw_device *cdev, int force)
/* Work not run yet - need to release reference here */
urdev_put(urd);
}
device_destroy(vmur_class, urd->char_device->dev);
device_destroy(&vmur_class, urd->char_device->dev);
cdev_del(urd->char_device);
urd->char_device = NULL;
rc = 0;
Expand Down Expand Up @@ -1022,11 +1024,9 @@ static int __init ur_init(void)

debug_set_level(vmur_dbf, 6);

vmur_class = class_create("vmur");
if (IS_ERR(vmur_class)) {
rc = PTR_ERR(vmur_class);
rc = class_register(&vmur_class);
if (rc)
goto fail_free_dbf;
}

rc = ccw_driver_register(&ur_driver);
if (rc)
Expand All @@ -1046,7 +1046,7 @@ static int __init ur_init(void)
fail_unregister_driver:
ccw_driver_unregister(&ur_driver);
fail_class_destroy:
class_destroy(vmur_class);
class_unregister(&vmur_class);
fail_free_dbf:
debug_unregister(vmur_dbf);
return rc;
Expand All @@ -1056,7 +1056,7 @@ static void __exit ur_exit(void)
{
unregister_chrdev_region(ur_first_dev_maj_min, NUM_MINORS);
ccw_driver_unregister(&ur_driver);
class_destroy(vmur_class);
class_unregister(&vmur_class);
debug_unregister(vmur_dbf);
pr_info("%s unloaded.\n", ur_banner);
}
Expand Down

0 comments on commit 0ad1d9f

Please sign in to comment.