Commit b5b44ac8 authored by Ricardo B. Marliere's avatar Ricardo B. Marliere Committed by Heiko Carstens

s390/vmlogrdr: make vmlogrdr_class constant

Since commit 43a7206b ("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 <gregkh@linuxfoundation.org>
Suggested-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatar"Ricardo B. Marliere" <ricardo@marliere.net>
Link: https://lore.kernel.org/r/20240305-class_cleanup-s390-v1-3-c4ff1ec49ffd@marliere.netSigned-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
parent 0ad1d9fa
...@@ -679,7 +679,9 @@ static const struct attribute_group *vmlogrdr_attr_groups[] = { ...@@ -679,7 +679,9 @@ static const struct attribute_group *vmlogrdr_attr_groups[] = {
NULL, NULL,
}; };
static struct class *vmlogrdr_class; static const struct class vmlogrdr_class = {
.name = "vmlogrdr_class",
};
static struct device_driver vmlogrdr_driver = { static struct device_driver vmlogrdr_driver = {
.name = "vmlogrdr", .name = "vmlogrdr",
.bus = &iucv_bus, .bus = &iucv_bus,
...@@ -699,12 +701,9 @@ static int vmlogrdr_register_driver(void) ...@@ -699,12 +701,9 @@ static int vmlogrdr_register_driver(void)
if (ret) if (ret)
goto out_iucv; goto out_iucv;
vmlogrdr_class = class_create("vmlogrdr"); ret = class_register(&vmlogrdr_class);
if (IS_ERR(vmlogrdr_class)) { if (ret)
ret = PTR_ERR(vmlogrdr_class);
vmlogrdr_class = NULL;
goto out_driver; goto out_driver;
}
return 0; return 0;
out_driver: out_driver:
...@@ -718,8 +717,7 @@ static int vmlogrdr_register_driver(void) ...@@ -718,8 +717,7 @@ static int vmlogrdr_register_driver(void)
static void vmlogrdr_unregister_driver(void) static void vmlogrdr_unregister_driver(void)
{ {
class_destroy(vmlogrdr_class); class_unregister(&vmlogrdr_class);
vmlogrdr_class = NULL;
driver_unregister(&vmlogrdr_driver); driver_unregister(&vmlogrdr_driver);
iucv_unregister(&vmlogrdr_iucv_handler, 1); iucv_unregister(&vmlogrdr_iucv_handler, 1);
} }
...@@ -754,7 +752,7 @@ static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv) ...@@ -754,7 +752,7 @@ static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv)
return ret; return ret;
} }
priv->class_device = device_create(vmlogrdr_class, dev, priv->class_device = device_create(&vmlogrdr_class, dev,
MKDEV(vmlogrdr_major, MKDEV(vmlogrdr_major,
priv->minor_num), priv->minor_num),
priv, "%s", dev_name(dev)); priv, "%s", dev_name(dev));
...@@ -771,7 +769,7 @@ static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv) ...@@ -771,7 +769,7 @@ static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv)
static int vmlogrdr_unregister_device(struct vmlogrdr_priv_t *priv) static int vmlogrdr_unregister_device(struct vmlogrdr_priv_t *priv)
{ {
device_destroy(vmlogrdr_class, MKDEV(vmlogrdr_major, priv->minor_num)); device_destroy(&vmlogrdr_class, MKDEV(vmlogrdr_major, priv->minor_num));
if (priv->device != NULL) { if (priv->device != NULL) {
device_unregister(priv->device); device_unregister(priv->device);
priv->device=NULL; priv->device=NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment