Skip to content

Commit ee8dda6

Browse files
rbmarlieremartinkpetersen
authored andcommitted
scsi: pmcraid: Make pmcraid_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 pmcraid_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 <[email protected]> Suggested-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Ricardo B. Marliere <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent f1fb417 commit ee8dda6

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

drivers/scsi/pmcraid.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ static atomic_t pmcraid_adapter_count = ATOMIC_INIT(0);
6161
* pmcraid_minor - minor number(s) to use
6262
*/
6363
static unsigned int pmcraid_major;
64-
static struct class *pmcraid_class;
64+
static const struct class pmcraid_class = {
65+
.name = PMCRAID_DEVFILE,
66+
};
6567
static DECLARE_BITMAP(pmcraid_minor, PMCRAID_MAX_ADAPTERS);
6668

6769
/*
@@ -4723,7 +4725,7 @@ static int pmcraid_setup_chrdev(struct pmcraid_instance *pinstance)
47234725
if (error)
47244726
pmcraid_release_minor(minor);
47254727
else
4726-
device_create(pmcraid_class, NULL, MKDEV(pmcraid_major, minor),
4728+
device_create(&pmcraid_class, NULL, MKDEV(pmcraid_major, minor),
47274729
NULL, "%s%u", PMCRAID_DEVFILE, minor);
47284730
return error;
47294731
}
@@ -4739,7 +4741,7 @@ static int pmcraid_setup_chrdev(struct pmcraid_instance *pinstance)
47394741
static void pmcraid_release_chrdev(struct pmcraid_instance *pinstance)
47404742
{
47414743
pmcraid_release_minor(MINOR(pinstance->cdev.dev));
4742-
device_destroy(pmcraid_class,
4744+
device_destroy(&pmcraid_class,
47434745
MKDEV(pmcraid_major, MINOR(pinstance->cdev.dev)));
47444746
cdev_del(&pinstance->cdev);
47454747
}
@@ -5390,10 +5392,10 @@ static int __init pmcraid_init(void)
53905392
}
53915393

53925394
pmcraid_major = MAJOR(dev);
5393-
pmcraid_class = class_create(PMCRAID_DEVFILE);
53945395

5395-
if (IS_ERR(pmcraid_class)) {
5396-
error = PTR_ERR(pmcraid_class);
5396+
error = class_register(&pmcraid_class);
5397+
5398+
if (error) {
53975399
pmcraid_err("failed to register with sysfs, error = %x\n",
53985400
error);
53995401
goto out_unreg_chrdev;
@@ -5402,7 +5404,7 @@ static int __init pmcraid_init(void)
54025404
error = pmcraid_netlink_init();
54035405

54045406
if (error) {
5405-
class_destroy(pmcraid_class);
5407+
class_unregister(&pmcraid_class);
54065408
goto out_unreg_chrdev;
54075409
}
54085410

@@ -5413,7 +5415,7 @@ static int __init pmcraid_init(void)
54135415

54145416
pmcraid_err("failed to register pmcraid driver, error = %x\n",
54155417
error);
5416-
class_destroy(pmcraid_class);
5418+
class_unregister(&pmcraid_class);
54175419
pmcraid_netlink_release();
54185420

54195421
out_unreg_chrdev:
@@ -5432,7 +5434,7 @@ static void __exit pmcraid_exit(void)
54325434
unregister_chrdev_region(MKDEV(pmcraid_major, 0),
54335435
PMCRAID_MAX_ADAPTERS);
54345436
pci_unregister_driver(&pmcraid_driver);
5435-
class_destroy(pmcraid_class);
5437+
class_unregister(&pmcraid_class);
54365438
}
54375439

54385440
module_init(pmcraid_init);

0 commit comments

Comments
 (0)