Skip to content

Commit 800bb2b

Browse files
rbmarlierekeithbusch
authored andcommitted
nvme: fcloop: make fcloop_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 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 <[email protected]> Suggested-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Ricardo B. Marliere <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 3c2bcfd commit 800bb2b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

drivers/nvme/target/fcloop.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,23 +1556,24 @@ static const struct attribute_group *fcloop_dev_attr_groups[] = {
15561556
NULL,
15571557
};
15581558

1559-
static struct class *fcloop_class;
1559+
static const struct class fcloop_class = {
1560+
.name = "fcloop",
1561+
};
15601562
static struct device *fcloop_device;
15611563

15621564

15631565
static int __init fcloop_init(void)
15641566
{
15651567
int ret;
15661568

1567-
fcloop_class = class_create("fcloop");
1568-
if (IS_ERR(fcloop_class)) {
1569+
ret = class_register(&fcloop_class);
1570+
if (ret) {
15691571
pr_err("couldn't register class fcloop\n");
1570-
ret = PTR_ERR(fcloop_class);
15711572
return ret;
15721573
}
15731574

15741575
fcloop_device = device_create_with_groups(
1575-
fcloop_class, NULL, MKDEV(0, 0), NULL,
1576+
&fcloop_class, NULL, MKDEV(0, 0), NULL,
15761577
fcloop_dev_attr_groups, "ctl");
15771578
if (IS_ERR(fcloop_device)) {
15781579
pr_err("couldn't create ctl device!\n");
@@ -1585,7 +1586,7 @@ static int __init fcloop_init(void)
15851586
return 0;
15861587

15871588
out_destroy_class:
1588-
class_destroy(fcloop_class);
1589+
class_unregister(&fcloop_class);
15891590
return ret;
15901591
}
15911592

@@ -1643,8 +1644,8 @@ static void __exit fcloop_exit(void)
16431644

16441645
put_device(fcloop_device);
16451646

1646-
device_destroy(fcloop_class, MKDEV(0, 0));
1647-
class_destroy(fcloop_class);
1647+
device_destroy(&fcloop_class, MKDEV(0, 0));
1648+
class_unregister(&fcloop_class);
16481649
}
16491650

16501651
module_init(fcloop_init);

0 commit comments

Comments
 (0)