Commit 800bb2b0 authored by Ricardo B. Marliere's avatar Ricardo B. Marliere Committed by Keith Busch

nvme: fcloop: make fcloop_class constant

Since commit 43a7206b ("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 fcloop_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: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarRicardo B. Marliere <ricardo@marliere.net>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>
parent 3c2bcfd5
...@@ -1556,7 +1556,9 @@ static const struct attribute_group *fcloop_dev_attr_groups[] = { ...@@ -1556,7 +1556,9 @@ static const struct attribute_group *fcloop_dev_attr_groups[] = {
NULL, NULL,
}; };
static struct class *fcloop_class; static const struct class fcloop_class = {
.name = "fcloop",
};
static struct device *fcloop_device; static struct device *fcloop_device;
...@@ -1564,15 +1566,14 @@ static int __init fcloop_init(void) ...@@ -1564,15 +1566,14 @@ static int __init fcloop_init(void)
{ {
int ret; int ret;
fcloop_class = class_create("fcloop"); ret = class_register(&fcloop_class);
if (IS_ERR(fcloop_class)) { if (ret) {
pr_err("couldn't register class fcloop\n"); pr_err("couldn't register class fcloop\n");
ret = PTR_ERR(fcloop_class);
return ret; return ret;
} }
fcloop_device = device_create_with_groups( fcloop_device = device_create_with_groups(
fcloop_class, NULL, MKDEV(0, 0), NULL, &fcloop_class, NULL, MKDEV(0, 0), NULL,
fcloop_dev_attr_groups, "ctl"); fcloop_dev_attr_groups, "ctl");
if (IS_ERR(fcloop_device)) { if (IS_ERR(fcloop_device)) {
pr_err("couldn't create ctl device!\n"); pr_err("couldn't create ctl device!\n");
...@@ -1585,7 +1586,7 @@ static int __init fcloop_init(void) ...@@ -1585,7 +1586,7 @@ static int __init fcloop_init(void)
return 0; return 0;
out_destroy_class: out_destroy_class:
class_destroy(fcloop_class); class_unregister(&fcloop_class);
return ret; return ret;
} }
...@@ -1643,8 +1644,8 @@ static void __exit fcloop_exit(void) ...@@ -1643,8 +1644,8 @@ static void __exit fcloop_exit(void)
put_device(fcloop_device); put_device(fcloop_device);
device_destroy(fcloop_class, MKDEV(0, 0)); device_destroy(&fcloop_class, MKDEV(0, 0));
class_destroy(fcloop_class); class_unregister(&fcloop_class);
} }
module_init(fcloop_init); module_init(fcloop_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment