diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2023-11-02 15:06:04 -1000 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2023-11-02 15:06:04 -1000 |
commit | 90a300dc0553c5c4a3324ca6de5877c834d27af7 (patch) | |
tree | b72710b5d2a2dfe67a33f4fde4b6e7bbea503584 | |
parent | e5760335882bd91137873b8f2230b6c1f91da52b (diff) | |
parent | 9ea459e477dc09370cdd8ee13b61aefe8cd1f20a (diff) |
Merge tag 'libnvdimm-for-6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm
Pull libnvdimm updates from Ira Weiny:
- updates to deprecated and changed interfaces
- bug/kdoc fixes
* tag 'libnvdimm-for-6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm:
libnvdimm: remove kernel-doc warnings:
testing: nvdimm: make struct class structures constant
libnvdimm: Annotate struct nd_region with __counted_by
nd_btt: Make BTT lanes preemptible
libnvdimm/of_pmem: Use devm_kstrdup instead of kstrdup and check its return value
dax: refactor deprecated strncpy
-rw-r--r-- | drivers/dax/bus.c | 2 | ||||
-rw-r--r-- | drivers/nvdimm/badrange.c | 4 | ||||
-rw-r--r-- | drivers/nvdimm/nd.h | 2 | ||||
-rw-r--r-- | drivers/nvdimm/of_pmem.c | 8 | ||||
-rw-r--r-- | drivers/nvdimm/region_devs.c | 10 | ||||
-rw-r--r-- | tools/testing/nvdimm/test/ndtest.c | 17 | ||||
-rw-r--r-- | tools/testing/nvdimm/test/nfit.c | 14 |
7 files changed, 32 insertions, 25 deletions
diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c index 0ee96e6fc426..1659b787b65f 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -103,7 +103,7 @@ static ssize_t do_id_store(struct device_driver *drv, const char *buf, if (action == ID_ADD) { dax_id = kzalloc(sizeof(*dax_id), GFP_KERNEL); if (dax_id) { - strncpy(dax_id->dev_name, buf, DAX_NAME_LEN); + strscpy(dax_id->dev_name, buf, DAX_NAME_LEN); list_add(&dax_id->list, &dax_drv->ids); } else rc = -ENOMEM; diff --git a/drivers/nvdimm/badrange.c b/drivers/nvdimm/badrange.c index aaf6e215a8c6..a002ea6fdd84 100644 --- a/drivers/nvdimm/badrange.c +++ b/drivers/nvdimm/badrange.c @@ -257,9 +257,9 @@ static void badblocks_populate(struct badrange *badrange, /** * nvdimm_badblocks_populate() - Convert a list of badranges to badblocks - * @region: parent region of the range to interrogate + * @nd_region: parent region of the range to interrogate * @bb: badblocks instance to populate - * @res: resource range to consider + * @range: resource range to consider * * The badrange list generated during bus initialization may contain * multiple, possibly overlapping physical address ranges. Compare each diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h index e8b9d27dbb3c..ae2078eb6a62 100644 --- a/drivers/nvdimm/nd.h +++ b/drivers/nvdimm/nd.h @@ -422,7 +422,7 @@ struct nd_region { struct nd_interleave_set *nd_set; struct nd_percpu_lane __percpu *lane; int (*flush)(struct nd_region *nd_region, struct bio *bio); - struct nd_mapping mapping[]; + struct nd_mapping mapping[] __counted_by(ndr_mappings); }; static inline bool nsl_validate_nlabel(struct nd_region *nd_region, diff --git a/drivers/nvdimm/of_pmem.c b/drivers/nvdimm/of_pmem.c index 1b9f5b8a6167..d3fca0ab6290 100644 --- a/drivers/nvdimm/of_pmem.c +++ b/drivers/nvdimm/of_pmem.c @@ -30,7 +30,13 @@ static int of_pmem_region_probe(struct platform_device *pdev) if (!priv) return -ENOMEM; - priv->bus_desc.provider_name = kstrdup(pdev->name, GFP_KERNEL); + priv->bus_desc.provider_name = devm_kstrdup(&pdev->dev, pdev->name, + GFP_KERNEL); + if (!priv->bus_desc.provider_name) { + kfree(priv); + return -ENOMEM; + } + priv->bus_desc.module = THIS_MODULE; priv->bus_desc.of_node = np; diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c index 0a81f87f6f6c..9e4f7ff024a0 100644 --- a/drivers/nvdimm/region_devs.c +++ b/drivers/nvdimm/region_devs.c @@ -939,7 +939,8 @@ unsigned int nd_region_acquire_lane(struct nd_region *nd_region) { unsigned int cpu, lane; - cpu = get_cpu(); + migrate_disable(); + cpu = smp_processor_id(); if (nd_region->num_lanes < nr_cpu_ids) { struct nd_percpu_lane *ndl_lock, *ndl_count; @@ -958,16 +959,15 @@ EXPORT_SYMBOL(nd_region_acquire_lane); void nd_region_release_lane(struct nd_region *nd_region, unsigned int lane) { if (nd_region->num_lanes < nr_cpu_ids) { - unsigned int cpu = get_cpu(); + unsigned int cpu = smp_processor_id(); struct nd_percpu_lane *ndl_lock, *ndl_count; ndl_count = per_cpu_ptr(nd_region->lane, cpu); ndl_lock = per_cpu_ptr(nd_region->lane, lane); if (--ndl_count->count == 0) spin_unlock(&ndl_lock->lock); - put_cpu(); } - put_cpu(); + migrate_enable(); } EXPORT_SYMBOL(nd_region_release_lane); @@ -1028,6 +1028,7 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus, if (!nd_region) return NULL; + nd_region->ndr_mappings = ndr_desc->num_mappings; /* CXL pre-assigns memregion ids before creating nvdimm regions */ if (test_bit(ND_REGION_CXL, &ndr_desc->flags)) { nd_region->id = ndr_desc->memregion; @@ -1062,7 +1063,6 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus, get_device(&nvdimm->dev); } - nd_region->ndr_mappings = ndr_desc->num_mappings; nd_region->provider_data = ndr_desc->provider_data; nd_region->nd_set = ndr_desc->nd_set; nd_region->num_lanes = ndr_desc->num_lanes; 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) { diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c index 005043bd9623..a61df347a33d 100644 --- a/tools/testing/nvdimm/test/nfit.c +++ b/tools/testing/nvdimm/test/nfit.c @@ -1712,7 +1712,9 @@ static void put_dimms(void *data) device_unregister(t->dimm_dev[i]); } -static struct class *nfit_test_dimm; +static const struct class nfit_test_dimm = { + .name = "nfit_test_dimm", +}; static int dimm_name_to_id(struct device *dev) { @@ -1830,7 +1832,7 @@ static int nfit_test_dimm_init(struct nfit_test *t) if (devm_add_action_or_reset(&t->pdev.dev, put_dimms, t)) return -ENOMEM; for (i = 0; i < t->num_dcr; i++) { - t->dimm_dev[i] = device_create_with_groups(nfit_test_dimm, + t->dimm_dev[i] = device_create_with_groups(&nfit_test_dimm, &t->pdev.dev, 0, NULL, nfit_test_dimm_attribute_groups, "test_dimm%d", i + t->dcr_idx); @@ -3276,11 +3278,9 @@ static __init int nfit_test_init(void) if (!nfit_wq) return -ENOMEM; - nfit_test_dimm = class_create("nfit_test_dimm"); - if (IS_ERR(nfit_test_dimm)) { - rc = PTR_ERR(nfit_test_dimm); + rc = class_register(&nfit_test_dimm); + if (rc) goto err_register; - } nfit_pool = gen_pool_create(ilog2(SZ_4M), NUMA_NO_NODE); if (!nfit_pool) { @@ -3377,7 +3377,7 @@ static __exit void nfit_test_exit(void) for (i = 0; i < NUM_NFITS; i++) put_device(&instances[i]->pdev.dev); - class_destroy(nfit_test_dimm); + class_unregister(&nfit_test_dimm); } module_init(nfit_test_init); |