s390/raw3270: make class3270 constant
authorRicardo B. Marliere <ricardo@marliere.net>
Tue, 5 Mar 2024 11:25:24 +0000 (08:25 -0300)
committerHeiko Carstens <hca@linux.ibm.com>
Wed, 13 Mar 2024 08:23:50 +0000 (09:23 +0100)
Since commit 43a7206b0963 ("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 class3270 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-6-c4ff1ec49ffd@marliere.net
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
drivers/s390/char/fs3270.c
drivers/s390/char/raw3270.c
drivers/s390/char/raw3270.h

index ce1f374..4d824f8 100644 (file)
@@ -521,13 +521,13 @@ static const struct file_operations fs3270_fops = {
 static void fs3270_create_cb(int minor)
 {
        __register_chrdev(IBM_FS3270_MAJOR, minor, 1, "tub", &fs3270_fops);
-       device_create(class3270, NULL, MKDEV(IBM_FS3270_MAJOR, minor),
+       device_create(&class3270, NULL, MKDEV(IBM_FS3270_MAJOR, minor),
                      NULL, "3270/tub%d", minor);
 }
 
 static void fs3270_destroy_cb(int minor)
 {
-       device_destroy(class3270, MKDEV(IBM_FS3270_MAJOR, minor));
+       device_destroy(&class3270, MKDEV(IBM_FS3270_MAJOR, minor));
        __unregister_chrdev(IBM_FS3270_MAJOR, minor, 1, "tub");
 }
 
@@ -546,7 +546,7 @@ static int __init fs3270_init(void)
        rc = __register_chrdev(IBM_FS3270_MAJOR, 0, 1, "fs3270", &fs3270_fops);
        if (rc)
                return rc;
-       device_create(class3270, NULL, MKDEV(IBM_FS3270_MAJOR, 0),
+       device_create(&class3270, NULL, MKDEV(IBM_FS3270_MAJOR, 0),
                      NULL, "3270/tub");
        raw3270_register_notifier(&fs3270_notifier);
        return 0;
@@ -555,7 +555,7 @@ static int __init fs3270_init(void)
 static void __exit fs3270_exit(void)
 {
        raw3270_unregister_notifier(&fs3270_notifier);
-       device_destroy(class3270, MKDEV(IBM_FS3270_MAJOR, 0));
+       device_destroy(&class3270, MKDEV(IBM_FS3270_MAJOR, 0));
        __unregister_chrdev(IBM_FS3270_MAJOR, 0, 1, "fs3270");
 }
 
index 899e86e..37173cb 100644 (file)
@@ -29,7 +29,9 @@
 #include <linux/device.h>
 #include <linux/mutex.h>
 
-struct class *class3270;
+const struct class class3270 = {
+       .name = "3270",
+};
 EXPORT_SYMBOL(class3270);
 
 /* The main 3270 data structure. */
@@ -1318,9 +1320,9 @@ static int raw3270_init(void)
        rc = ccw_driver_register(&raw3270_ccw_driver);
        if (rc)
                return rc;
-       class3270 = class_create("3270");
-       if (IS_ERR(class3270))
-               return PTR_ERR(class3270);
+       rc = class_register(&class3270);
+       if (rc)
+               return rc;
        /* Create attributes for early (= console) device. */
        mutex_lock(&raw3270_mutex);
        list_for_each_entry(rp, &raw3270_devices, list) {
@@ -1334,7 +1336,7 @@ static int raw3270_init(void)
 static void raw3270_exit(void)
 {
        ccw_driver_unregister(&raw3270_ccw_driver);
-       class_destroy(class3270);
+       class_unregister(&class3270);
 }
 
 MODULE_LICENSE("GPL");
index b1beecc..5040c7e 100644 (file)
@@ -14,7 +14,7 @@
 
 struct raw3270;
 struct raw3270_view;
-extern struct class *class3270;
+extern const struct class class3270;
 
 /* 3270 CCW request */
 struct raw3270_request {