Skip to content

Commit b5b44ac

Browse files
rbmarlierehcahca
authored andcommitted
s390/vmlogrdr: make vmlogrdr_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 vmlogrdr_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 0ad1d9f commit b5b44ac

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

drivers/s390/char/vmlogrdr.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,9 @@ static const struct attribute_group *vmlogrdr_attr_groups[] = {
679679
NULL,
680680
};
681681

682-
static struct class *vmlogrdr_class;
682+
static const struct class vmlogrdr_class = {
683+
.name = "vmlogrdr_class",
684+
};
683685
static struct device_driver vmlogrdr_driver = {
684686
.name = "vmlogrdr",
685687
.bus = &iucv_bus,
@@ -699,12 +701,9 @@ static int vmlogrdr_register_driver(void)
699701
if (ret)
700702
goto out_iucv;
701703

702-
vmlogrdr_class = class_create("vmlogrdr");
703-
if (IS_ERR(vmlogrdr_class)) {
704-
ret = PTR_ERR(vmlogrdr_class);
705-
vmlogrdr_class = NULL;
704+
ret = class_register(&vmlogrdr_class);
705+
if (ret)
706706
goto out_driver;
707-
}
708707
return 0;
709708

710709
out_driver:
@@ -718,8 +717,7 @@ static int vmlogrdr_register_driver(void)
718717

719718
static void vmlogrdr_unregister_driver(void)
720719
{
721-
class_destroy(vmlogrdr_class);
722-
vmlogrdr_class = NULL;
720+
class_unregister(&vmlogrdr_class);
723721
driver_unregister(&vmlogrdr_driver);
724722
iucv_unregister(&vmlogrdr_iucv_handler, 1);
725723
}
@@ -754,7 +752,7 @@ static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv)
754752
return ret;
755753
}
756754

757-
priv->class_device = device_create(vmlogrdr_class, dev,
755+
priv->class_device = device_create(&vmlogrdr_class, dev,
758756
MKDEV(vmlogrdr_major,
759757
priv->minor_num),
760758
priv, "%s", dev_name(dev));
@@ -771,7 +769,7 @@ static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv)
771769

772770
static int vmlogrdr_unregister_device(struct vmlogrdr_priv_t *priv)
773771
{
774-
device_destroy(vmlogrdr_class, MKDEV(vmlogrdr_major, priv->minor_num));
772+
device_destroy(&vmlogrdr_class, MKDEV(vmlogrdr_major, priv->minor_num));
775773
if (priv->device != NULL) {
776774
device_unregister(priv->device);
777775
priv->device=NULL;

0 commit comments

Comments
 (0)