Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nvdimm: make nd_class constant

Now that the driver core allows for struct class to be in read-only
memory, it is possible to make all 'class' structures be declared at
build time. Move the class to a 'static const' declaration and register
it rather than dynamically create it."

Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: nvdimm@lists.linux.dev
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Link: https://lore.kernel.org/r/2024061041-grandkid-coherence-19b0@gregkh
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+10 -9
+10 -9
drivers/nvdimm/bus.c
··· 25 25 26 26 int nvdimm_major; 27 27 static int nvdimm_bus_major; 28 - static struct class *nd_class; 29 28 static DEFINE_IDA(nd_ida); 29 + 30 + static const struct class nd_class = { 31 + .name = "nd", 32 + }; 30 33 31 34 static int to_nd_device_type(const struct device *dev) 32 35 { ··· 745 742 device_initialize(dev); 746 743 lockdep_set_class(&dev->mutex, &nvdimm_ndctl_key); 747 744 device_set_pm_not_required(dev); 748 - dev->class = nd_class; 745 + dev->class = &nd_class; 749 746 dev->parent = &nvdimm_bus->dev; 750 747 dev->devt = devt; 751 748 dev->release = ndctl_release; ··· 768 765 769 766 void nvdimm_bus_destroy_ndctl(struct nvdimm_bus *nvdimm_bus) 770 767 { 771 - device_destroy(nd_class, MKDEV(nvdimm_bus_major, nvdimm_bus->id)); 768 + device_destroy(&nd_class, MKDEV(nvdimm_bus_major, nvdimm_bus->id)); 772 769 } 773 770 774 771 static const struct nd_cmd_desc __nd_cmd_dimm_descs[] = { ··· 1323 1320 goto err_dimm_chrdev; 1324 1321 nvdimm_major = rc; 1325 1322 1326 - nd_class = class_create("nd"); 1327 - if (IS_ERR(nd_class)) { 1328 - rc = PTR_ERR(nd_class); 1323 + rc = class_register(&nd_class); 1324 + if (rc) 1329 1325 goto err_class; 1330 - } 1331 1326 1332 1327 rc = driver_register(&nd_bus_driver.drv); 1333 1328 if (rc) ··· 1334 1333 return 0; 1335 1334 1336 1335 err_nd_bus: 1337 - class_destroy(nd_class); 1336 + class_unregister(&nd_class); 1338 1337 err_class: 1339 1338 unregister_chrdev(nvdimm_major, "dimmctl"); 1340 1339 err_dimm_chrdev: ··· 1348 1347 void nvdimm_bus_exit(void) 1349 1348 { 1350 1349 driver_unregister(&nd_bus_driver.drv); 1351 - class_destroy(nd_class); 1350 + class_unregister(&nd_class); 1352 1351 unregister_chrdev(nvdimm_bus_major, "ndctl"); 1353 1352 unregister_chrdev(nvdimm_major, "dimmctl"); 1354 1353 bus_unregister(&nvdimm_bus_type);