From dd6cad2dcb581b2b15997b6e8d50de64644c3011 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 6 Oct 2023 16:02:12 +0200 Subject: testing: nvdimm: make struct class structures constant Now that the driver core allows for struct class to be in read-only memory, we should make all 'class' structures declared at build time placing them into read-only memory, instead of having to be dynamically allocated at runtime. Cc: Dan Williams Cc: Vishal Verma Cc: Dave Jiang Cc: Ira Weiny Signed-off-by: Greg Kroah-Hartman Tested-by: Ira Weiny Reviewed-by: Ira Weiny Link: https://lore.kernel.org/r/2023100611-platinum-galleria-ceb3@gregkh Signed-off-by: Ira Weiny --- tools/testing/nvdimm/test/ndtest.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'tools/testing/nvdimm/test/ndtest.c') diff --git a/tools/testing/nvdimm/test/ndtest.c b/tools/testing/nvdimm/test/ndtest.c index 3eba10c1e3e8..fd26189d53be 100644 --- a/tools/testing/nvdimm/test/ndtest.c +++ b/tools/testing/nvdimm/test/ndtest.c @@ -38,7 +38,11 @@ enum { static DEFINE_SPINLOCK(ndtest_lock); static struct ndtest_priv *instances[NUM_INSTANCES]; -static struct class *ndtest_dimm_class; + +static const struct class ndtest_dimm_class = { + .name = "nfit_test_dimm", +}; + static struct gen_pool *ndtest_pool; static struct ndtest_dimm dimm_group1[] = { @@ -737,7 +741,7 @@ static int ndtest_dimm_register(struct ndtest_priv *priv, return -ENXIO; } - dimm->dev = device_create_with_groups(ndtest_dimm_class, + dimm->dev = device_create_with_groups(&ndtest_dimm_class, &priv->pdev.dev, 0, dimm, dimm_attribute_groups, "test_dimm%d", id); @@ -906,8 +910,7 @@ static void cleanup_devices(void) gen_pool_destroy(ndtest_pool); - if (ndtest_dimm_class) - class_destroy(ndtest_dimm_class); + class_unregister(&ndtest_dimm_class); } static __init int ndtest_init(void) @@ -921,11 +924,9 @@ static __init int ndtest_init(void) nfit_test_setup(ndtest_resource_lookup, NULL); - ndtest_dimm_class = class_create("nfit_test_dimm"); - if (IS_ERR(ndtest_dimm_class)) { - rc = PTR_ERR(ndtest_dimm_class); + rc = class_regster(&ndtest_dimm_class); + if (rc) goto err_register; - } ndtest_pool = gen_pool_create(ilog2(SZ_4M), NUMA_NO_NODE); if (!ndtest_pool) { -- cgit v1.2.3