Skip to content

Commit bd31ef8

Browse files
ivanorlov2206gregkh
authored andcommitted
dsp56k: make dsp56k_class a static const structure
Now that the driver core allows for struct class to be in read-only memory, move the dsp56k_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: Arnd Bergmann <arnd@arndb.de> Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com> Link: https://lore.kernel.org/r/20230620143751.578239-11-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e55ce9f commit bd31ef8

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

drivers/char/dsp56k.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ static struct dsp56k_device {
101101
int tx_wsize, rx_wsize;
102102
} dsp56k;
103103

104-
static struct class *dsp56k_class;
104+
static const struct class dsp56k_class = {
105+
.name = "dsp56k",
106+
};
105107

106108
static int dsp56k_reset(void)
107109
{
@@ -493,7 +495,7 @@ static const char banner[] __initconst = KERN_INFO "DSP56k driver installed\n";
493495

494496
static int __init dsp56k_init_driver(void)
495497
{
496-
int err = 0;
498+
int err;
497499

498500
if(!MACH_IS_ATARI || !ATARIHW_PRESENT(DSP56K)) {
499501
printk("DSP56k driver: Hardware not present\n");
@@ -504,12 +506,10 @@ static int __init dsp56k_init_driver(void)
504506
printk("DSP56k driver: Unable to register driver\n");
505507
return -ENODEV;
506508
}
507-
dsp56k_class = class_create("dsp56k");
508-
if (IS_ERR(dsp56k_class)) {
509-
err = PTR_ERR(dsp56k_class);
509+
err = class_register(&dsp56k_class);
510+
if (err)
510511
goto out_chrdev;
511-
}
512-
device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), NULL,
512+
device_create(&dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), NULL,
513513
"dsp56k");
514514

515515
printk(banner);
@@ -524,8 +524,8 @@ module_init(dsp56k_init_driver);
524524

525525
static void __exit dsp56k_cleanup_driver(void)
526526
{
527-
device_destroy(dsp56k_class, MKDEV(DSP56K_MAJOR, 0));
528-
class_destroy(dsp56k_class);
527+
device_destroy(&dsp56k_class, MKDEV(DSP56K_MAJOR, 0));
528+
class_unregister(&dsp56k_class);
529529
unregister_chrdev(DSP56K_MAJOR, "dsp56k");
530530
}
531531
module_exit(dsp56k_cleanup_driver);

0 commit comments

Comments
 (0)