Skip to content

Commit 8b2de74

Browse files
rbmarlieretsbogend
authored andcommitted
mips: sibyte: make tb_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 tb_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> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
1 parent e5d9592 commit 8b2de74

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

arch/mips/sibyte/common/sb_tbprof.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -535,13 +535,14 @@ static const struct file_operations sbprof_tb_fops = {
535535
.llseek = default_llseek,
536536
};
537537

538-
static struct class *tb_class;
538+
static const struct class tb_class = {
539+
.name = "sb_tracebuffer",
540+
};
539541
static struct device *tb_dev;
540542

541543
static int __init sbprof_tb_init(void)
542544
{
543545
struct device *dev;
544-
struct class *tbc;
545546
int err;
546547

547548
if (register_chrdev(SBPROF_TB_MAJOR, DEVNAME, &sbprof_tb_fops)) {
@@ -550,15 +551,11 @@ static int __init sbprof_tb_init(void)
550551
return -EIO;
551552
}
552553

553-
tbc = class_create("sb_tracebuffer");
554-
if (IS_ERR(tbc)) {
555-
err = PTR_ERR(tbc);
554+
err = class_register(&tb_class);
555+
if (err)
556556
goto out_chrdev;
557-
}
558-
559-
tb_class = tbc;
560557

561-
dev = device_create(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0), NULL, "tb");
558+
dev = device_create(&tb_class, NULL, MKDEV(SBPROF_TB_MAJOR, 0), NULL, "tb");
562559
if (IS_ERR(dev)) {
563560
err = PTR_ERR(dev);
564561
goto out_class;
@@ -573,7 +570,7 @@ static int __init sbprof_tb_init(void)
573570
return 0;
574571

575572
out_class:
576-
class_destroy(tb_class);
573+
class_unregister(&tb_class);
577574
out_chrdev:
578575
unregister_chrdev(SBPROF_TB_MAJOR, DEVNAME);
579576

@@ -582,9 +579,9 @@ static int __init sbprof_tb_init(void)
582579

583580
static void __exit sbprof_tb_cleanup(void)
584581
{
585-
device_destroy(tb_class, MKDEV(SBPROF_TB_MAJOR, 0));
582+
device_destroy(&tb_class, MKDEV(SBPROF_TB_MAJOR, 0));
586583
unregister_chrdev(SBPROF_TB_MAJOR, DEVNAME);
587-
class_destroy(tb_class);
584+
class_unregister(&tb_class);
588585
}
589586

590587
module_init(sbprof_tb_init);

0 commit comments

Comments
 (0)