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

s390/raw3270: make class3270 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 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: 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-6-c4ff1ec49ffd@marliere.netSigned-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
parent c8fba0c1
......@@ -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");
}
......
......@@ -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");
......
......@@ -14,7 +14,7 @@
struct raw3270;
struct raw3270_view;
extern struct class *class3270;
extern const struct class class3270;
/* 3270 CCW request */
struct raw3270_request {
......
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