Skip to content

Commit

Permalink
misc: hpilo: make ilo_class a static const structure
Browse files Browse the repository at this point in the history
Now that the driver core allows for struct class to be in read-only
memory, move the ilo_class structure to be declared at build time
placing it into read-only memory, instead of having to be dynamically
allocated at boot time.

Suggested-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Ivan Orlov <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
ivanorlov2206 authored and gregkh committed Aug 11, 2023
1 parent b5fa337 commit fd06978
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions drivers/misc/hpilo.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
#include <linux/slab.h>
#include "hpilo.h"

static struct class *ilo_class;
static const struct class ilo_class = {
.name = "iLO",
};
static unsigned int ilo_major;
static unsigned int max_ccb = 16;
static char ilo_hwdev[MAX_ILO_DEV];
Expand Down Expand Up @@ -746,7 +748,7 @@ static void ilo_remove(struct pci_dev *pdev)

minor = MINOR(ilo_hw->cdev.dev);
for (i = minor; i < minor + max_ccb; i++)
device_destroy(ilo_class, MKDEV(ilo_major, i));
device_destroy(&ilo_class, MKDEV(ilo_major, i));

cdev_del(&ilo_hw->cdev);
ilo_disable_interrupts(ilo_hw);
Expand Down Expand Up @@ -839,7 +841,7 @@ static int ilo_probe(struct pci_dev *pdev,

for (minor = 0 ; minor < max_ccb; minor++) {
struct device *dev;
dev = device_create(ilo_class, &pdev->dev,
dev = device_create(&ilo_class, &pdev->dev,
MKDEV(ilo_major, minor), NULL,
"hpilo!d%dccb%d", devnum, minor);
if (IS_ERR(dev))
Expand Down Expand Up @@ -882,11 +884,9 @@ static int __init ilo_init(void)
int error;
dev_t dev;

ilo_class = class_create("iLO");
if (IS_ERR(ilo_class)) {
error = PTR_ERR(ilo_class);
error = class_register(&ilo_class);
if (error)
goto out;
}

error = alloc_chrdev_region(&dev, 0, MAX_OPEN, ILO_NAME);
if (error)
Expand All @@ -902,7 +902,7 @@ static int __init ilo_init(void)
chr_remove:
unregister_chrdev_region(dev, MAX_OPEN);
class_destroy:
class_destroy(ilo_class);
class_unregister(&ilo_class);
out:
return error;
}
Expand All @@ -911,7 +911,7 @@ static void __exit ilo_exit(void)
{
pci_unregister_driver(&ilo_driver);
unregister_chrdev_region(MKDEV(ilo_major, 0), MAX_OPEN);
class_destroy(ilo_class);
class_unregister(&ilo_class);
}

MODULE_VERSION("1.5.0");
Expand Down

0 comments on commit fd06978

Please sign in to comment.