Skip to content

Commit 392fa3a

Browse files
ivanorlov2206cminyard
authored andcommitted
ipmi: make ipmi_class a static const structure
Now that the driver core allows for struct class to be in read-only memory, move the ipmi_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: Corey Minyard <[email protected]> Cc: [email protected] Suggested-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Ivan Orlov <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Message-Id: <[email protected]> Signed-off-by: Corey Minyard <[email protected]>
1 parent b8d72e3 commit 392fa3a

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

drivers/char/ipmi/ipmi_devintf.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,9 @@ struct ipmi_reg_list {
807807
static LIST_HEAD(reg_list);
808808
static DEFINE_MUTEX(reg_list_mutex);
809809

810-
static struct class *ipmi_class;
810+
static const struct class ipmi_class = {
811+
.name = "ipmi",
812+
};
811813

812814
static void ipmi_new_smi(int if_num, struct device *device)
813815
{
@@ -822,7 +824,7 @@ static void ipmi_new_smi(int if_num, struct device *device)
822824
entry->dev = dev;
823825

824826
mutex_lock(&reg_list_mutex);
825-
device_create(ipmi_class, device, dev, NULL, "ipmi%d", if_num);
827+
device_create(&ipmi_class, device, dev, NULL, "ipmi%d", if_num);
826828
list_add(&entry->link, &reg_list);
827829
mutex_unlock(&reg_list_mutex);
828830
}
@@ -840,7 +842,7 @@ static void ipmi_smi_gone(int if_num)
840842
break;
841843
}
842844
}
843-
device_destroy(ipmi_class, dev);
845+
device_destroy(&ipmi_class, dev);
844846
mutex_unlock(&reg_list_mutex);
845847
}
846848

@@ -860,15 +862,13 @@ static int __init init_ipmi_devintf(void)
860862

861863
pr_info("ipmi device interface\n");
862864

863-
ipmi_class = class_create("ipmi");
864-
if (IS_ERR(ipmi_class)) {
865-
pr_err("ipmi: can't register device class\n");
866-
return PTR_ERR(ipmi_class);
867-
}
865+
rv = class_register(&ipmi_class);
866+
if (rv)
867+
return rv;
868868

869869
rv = register_chrdev(ipmi_major, DEVICE_NAME, &ipmi_fops);
870870
if (rv < 0) {
871-
class_destroy(ipmi_class);
871+
class_unregister(&ipmi_class);
872872
pr_err("ipmi: can't get major %d\n", ipmi_major);
873873
return rv;
874874
}
@@ -880,7 +880,7 @@ static int __init init_ipmi_devintf(void)
880880
rv = ipmi_smi_watcher_register(&smi_watcher);
881881
if (rv) {
882882
unregister_chrdev(ipmi_major, DEVICE_NAME);
883-
class_destroy(ipmi_class);
883+
class_unregister(&ipmi_class);
884884
pr_warn("ipmi: can't register smi watcher\n");
885885
return rv;
886886
}
@@ -895,11 +895,11 @@ static void __exit cleanup_ipmi(void)
895895
mutex_lock(&reg_list_mutex);
896896
list_for_each_entry_safe(entry, entry2, &reg_list, link) {
897897
list_del(&entry->link);
898-
device_destroy(ipmi_class, entry->dev);
898+
device_destroy(&ipmi_class, entry->dev);
899899
kfree(entry);
900900
}
901901
mutex_unlock(&reg_list_mutex);
902-
class_destroy(ipmi_class);
902+
class_unregister(&ipmi_class);
903903
ipmi_smi_watcher_unregister(&smi_watcher);
904904
unregister_chrdev(ipmi_major, DEVICE_NAME);
905905
}

0 commit comments

Comments
 (0)