Skip to content

Commit 5207765

Browse files
rbmarlierehcahca
authored andcommitted
s390/tape: make tape_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 tape_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/20240305-class_cleanup-s390-v1-4-c4ff1ec49ffd@marliere.net Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
1 parent b5b44ac commit 5207765

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

drivers/s390/char/tape_class.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ MODULE_DESCRIPTION(
2222
);
2323
MODULE_LICENSE("GPL");
2424

25-
static struct class *tape_class;
25+
static const struct class tape_class = {
26+
.name = "tape390",
27+
};
2628

2729
/*
2830
* Register a tape device and return a pointer to the cdev structure.
@@ -74,7 +76,7 @@ struct tape_class_device *register_tape_dev(
7476
if (rc)
7577
goto fail_with_cdev;
7678

77-
tcd->class_device = device_create(tape_class, device,
79+
tcd->class_device = device_create(&tape_class, device,
7880
tcd->char_device->dev, NULL,
7981
"%s", tcd->device_name);
8082
rc = PTR_ERR_OR_ZERO(tcd->class_device);
@@ -91,7 +93,7 @@ struct tape_class_device *register_tape_dev(
9193
return tcd;
9294

9395
fail_with_class_device:
94-
device_destroy(tape_class, tcd->char_device->dev);
96+
device_destroy(&tape_class, tcd->char_device->dev);
9597

9698
fail_with_cdev:
9799
cdev_del(tcd->char_device);
@@ -107,7 +109,7 @@ void unregister_tape_dev(struct device *device, struct tape_class_device *tcd)
107109
{
108110
if (tcd != NULL && !IS_ERR(tcd)) {
109111
sysfs_remove_link(&device->kobj, tcd->mode_name);
110-
device_destroy(tape_class, tcd->char_device->dev);
112+
device_destroy(&tape_class, tcd->char_device->dev);
111113
cdev_del(tcd->char_device);
112114
kfree(tcd);
113115
}
@@ -117,15 +119,12 @@ EXPORT_SYMBOL(unregister_tape_dev);
117119

118120
static int __init tape_init(void)
119121
{
120-
tape_class = class_create("tape390");
121-
122-
return 0;
122+
return class_register(&tape_class);
123123
}
124124

125125
static void __exit tape_exit(void)
126126
{
127-
class_destroy(tape_class);
128-
tape_class = NULL;
127+
class_unregister(&tape_class);
129128
}
130129

131130
postcore_initcall(tape_init);

0 commit comments

Comments
 (0)