Skip to content

Commit 69460c5

Browse files
rbmarlierehcahca
authored andcommitted
s390/raw3270: make class3270 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 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>
1 parent c8fba0c commit 69460c5

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

drivers/s390/char/fs3270.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,13 +521,13 @@ static const struct file_operations fs3270_fops = {
521521
static void fs3270_create_cb(int minor)
522522
{
523523
__register_chrdev(IBM_FS3270_MAJOR, minor, 1, "tub", &fs3270_fops);
524-
device_create(class3270, NULL, MKDEV(IBM_FS3270_MAJOR, minor),
524+
device_create(&class3270, NULL, MKDEV(IBM_FS3270_MAJOR, minor),
525525
NULL, "3270/tub%d", minor);
526526
}
527527

528528
static void fs3270_destroy_cb(int minor)
529529
{
530-
device_destroy(class3270, MKDEV(IBM_FS3270_MAJOR, minor));
530+
device_destroy(&class3270, MKDEV(IBM_FS3270_MAJOR, minor));
531531
__unregister_chrdev(IBM_FS3270_MAJOR, minor, 1, "tub");
532532
}
533533

@@ -546,7 +546,7 @@ static int __init fs3270_init(void)
546546
rc = __register_chrdev(IBM_FS3270_MAJOR, 0, 1, "fs3270", &fs3270_fops);
547547
if (rc)
548548
return rc;
549-
device_create(class3270, NULL, MKDEV(IBM_FS3270_MAJOR, 0),
549+
device_create(&class3270, NULL, MKDEV(IBM_FS3270_MAJOR, 0),
550550
NULL, "3270/tub");
551551
raw3270_register_notifier(&fs3270_notifier);
552552
return 0;
@@ -555,7 +555,7 @@ static int __init fs3270_init(void)
555555
static void __exit fs3270_exit(void)
556556
{
557557
raw3270_unregister_notifier(&fs3270_notifier);
558-
device_destroy(class3270, MKDEV(IBM_FS3270_MAJOR, 0));
558+
device_destroy(&class3270, MKDEV(IBM_FS3270_MAJOR, 0));
559559
__unregister_chrdev(IBM_FS3270_MAJOR, 0, 1, "fs3270");
560560
}
561561

drivers/s390/char/raw3270.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
#include <linux/device.h>
3030
#include <linux/mutex.h>
3131

32-
struct class *class3270;
32+
const struct class class3270 = {
33+
.name = "3270",
34+
};
3335
EXPORT_SYMBOL(class3270);
3436

3537
/* The main 3270 data structure. */
@@ -1318,9 +1320,9 @@ static int raw3270_init(void)
13181320
rc = ccw_driver_register(&raw3270_ccw_driver);
13191321
if (rc)
13201322
return rc;
1321-
class3270 = class_create("3270");
1322-
if (IS_ERR(class3270))
1323-
return PTR_ERR(class3270);
1323+
rc = class_register(&class3270);
1324+
if (rc)
1325+
return rc;
13241326
/* Create attributes for early (= console) device. */
13251327
mutex_lock(&raw3270_mutex);
13261328
list_for_each_entry(rp, &raw3270_devices, list) {
@@ -1334,7 +1336,7 @@ static int raw3270_init(void)
13341336
static void raw3270_exit(void)
13351337
{
13361338
ccw_driver_unregister(&raw3270_ccw_driver);
1337-
class_destroy(class3270);
1339+
class_unregister(&class3270);
13381340
}
13391341

13401342
MODULE_LICENSE("GPL");

drivers/s390/char/raw3270.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
struct raw3270;
1616
struct raw3270_view;
17-
extern struct class *class3270;
17+
extern const struct class class3270;
1818

1919
/* 3270 CCW request */
2020
struct raw3270_request {

0 commit comments

Comments
 (0)