Commit 90a300dc authored by Linus Torvalds's avatar Linus Torvalds

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
parents e5760335 9ea459e4
...@@ -103,7 +103,7 @@ static ssize_t do_id_store(struct device_driver *drv, const char *buf, ...@@ -103,7 +103,7 @@ static ssize_t do_id_store(struct device_driver *drv, const char *buf,
if (action == ID_ADD) { if (action == ID_ADD) {
dax_id = kzalloc(sizeof(*dax_id), GFP_KERNEL); dax_id = kzalloc(sizeof(*dax_id), GFP_KERNEL);
if (dax_id) { 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); list_add(&dax_id->list, &dax_drv->ids);
} else } else
rc = -ENOMEM; rc = -ENOMEM;
......
...@@ -257,9 +257,9 @@ static void badblocks_populate(struct badrange *badrange, ...@@ -257,9 +257,9 @@ static void badblocks_populate(struct badrange *badrange,
/** /**
* nvdimm_badblocks_populate() - Convert a list of badranges to badblocks * 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 * @bb: badblocks instance to populate
* @res: resource range to consider * @range: resource range to consider
* *
* The badrange list generated during bus initialization may contain * The badrange list generated during bus initialization may contain
* multiple, possibly overlapping physical address ranges. Compare each * multiple, possibly overlapping physical address ranges. Compare each
......
...@@ -422,7 +422,7 @@ struct nd_region { ...@@ -422,7 +422,7 @@ struct nd_region {
struct nd_interleave_set *nd_set; struct nd_interleave_set *nd_set;
struct nd_percpu_lane __percpu *lane; struct nd_percpu_lane __percpu *lane;
int (*flush)(struct nd_region *nd_region, struct bio *bio); 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, static inline bool nsl_validate_nlabel(struct nd_region *nd_region,
......
...@@ -30,7 +30,13 @@ static int of_pmem_region_probe(struct platform_device *pdev) ...@@ -30,7 +30,13 @@ static int of_pmem_region_probe(struct platform_device *pdev)
if (!priv) if (!priv)
return -ENOMEM; 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.module = THIS_MODULE;
priv->bus_desc.of_node = np; priv->bus_desc.of_node = np;
......
...@@ -939,7 +939,8 @@ unsigned int nd_region_acquire_lane(struct nd_region *nd_region) ...@@ -939,7 +939,8 @@ unsigned int nd_region_acquire_lane(struct nd_region *nd_region)
{ {
unsigned int cpu, lane; unsigned int cpu, lane;
cpu = get_cpu(); migrate_disable();
cpu = smp_processor_id();
if (nd_region->num_lanes < nr_cpu_ids) { if (nd_region->num_lanes < nr_cpu_ids) {
struct nd_percpu_lane *ndl_lock, *ndl_count; struct nd_percpu_lane *ndl_lock, *ndl_count;
...@@ -958,16 +959,15 @@ EXPORT_SYMBOL(nd_region_acquire_lane); ...@@ -958,16 +959,15 @@ EXPORT_SYMBOL(nd_region_acquire_lane);
void nd_region_release_lane(struct nd_region *nd_region, unsigned int lane) void nd_region_release_lane(struct nd_region *nd_region, unsigned int lane)
{ {
if (nd_region->num_lanes < nr_cpu_ids) { 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; struct nd_percpu_lane *ndl_lock, *ndl_count;
ndl_count = per_cpu_ptr(nd_region->lane, cpu); ndl_count = per_cpu_ptr(nd_region->lane, cpu);
ndl_lock = per_cpu_ptr(nd_region->lane, lane); ndl_lock = per_cpu_ptr(nd_region->lane, lane);
if (--ndl_count->count == 0) if (--ndl_count->count == 0)
spin_unlock(&ndl_lock->lock); spin_unlock(&ndl_lock->lock);
put_cpu();
} }
put_cpu(); migrate_enable();
} }
EXPORT_SYMBOL(nd_region_release_lane); EXPORT_SYMBOL(nd_region_release_lane);
...@@ -1028,6 +1028,7 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus, ...@@ -1028,6 +1028,7 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus,
if (!nd_region) if (!nd_region)
return NULL; return NULL;
nd_region->ndr_mappings = ndr_desc->num_mappings;
/* CXL pre-assigns memregion ids before creating nvdimm regions */ /* CXL pre-assigns memregion ids before creating nvdimm regions */
if (test_bit(ND_REGION_CXL, &ndr_desc->flags)) { if (test_bit(ND_REGION_CXL, &ndr_desc->flags)) {
nd_region->id = ndr_desc->memregion; nd_region->id = ndr_desc->memregion;
...@@ -1062,7 +1063,6 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus, ...@@ -1062,7 +1063,6 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus,
get_device(&nvdimm->dev); get_device(&nvdimm->dev);
} }
nd_region->ndr_mappings = ndr_desc->num_mappings;
nd_region->provider_data = ndr_desc->provider_data; nd_region->provider_data = ndr_desc->provider_data;
nd_region->nd_set = ndr_desc->nd_set; nd_region->nd_set = ndr_desc->nd_set;
nd_region->num_lanes = ndr_desc->num_lanes; nd_region->num_lanes = ndr_desc->num_lanes;
......
...@@ -38,7 +38,11 @@ enum { ...@@ -38,7 +38,11 @@ enum {
static DEFINE_SPINLOCK(ndtest_lock); static DEFINE_SPINLOCK(ndtest_lock);
static struct ndtest_priv *instances[NUM_INSTANCES]; 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 gen_pool *ndtest_pool;
static struct ndtest_dimm dimm_group1[] = { static struct ndtest_dimm dimm_group1[] = {
...@@ -737,7 +741,7 @@ static int ndtest_dimm_register(struct ndtest_priv *priv, ...@@ -737,7 +741,7 @@ static int ndtest_dimm_register(struct ndtest_priv *priv,
return -ENXIO; return -ENXIO;
} }
dimm->dev = device_create_with_groups(ndtest_dimm_class, dimm->dev = device_create_with_groups(&ndtest_dimm_class,
&priv->pdev.dev, &priv->pdev.dev,
0, dimm, dimm_attribute_groups, 0, dimm, dimm_attribute_groups,
"test_dimm%d", id); "test_dimm%d", id);
...@@ -906,8 +910,7 @@ static void cleanup_devices(void) ...@@ -906,8 +910,7 @@ static void cleanup_devices(void)
gen_pool_destroy(ndtest_pool); gen_pool_destroy(ndtest_pool);
if (ndtest_dimm_class) class_unregister(&ndtest_dimm_class);
class_destroy(ndtest_dimm_class);
} }
static __init int ndtest_init(void) static __init int ndtest_init(void)
...@@ -921,11 +924,9 @@ static __init int ndtest_init(void) ...@@ -921,11 +924,9 @@ static __init int ndtest_init(void)
nfit_test_setup(ndtest_resource_lookup, NULL); nfit_test_setup(ndtest_resource_lookup, NULL);
ndtest_dimm_class = class_create("nfit_test_dimm"); rc = class_regster(&ndtest_dimm_class);
if (IS_ERR(ndtest_dimm_class)) { if (rc)
rc = PTR_ERR(ndtest_dimm_class);
goto err_register; goto err_register;
}
ndtest_pool = gen_pool_create(ilog2(SZ_4M), NUMA_NO_NODE); ndtest_pool = gen_pool_create(ilog2(SZ_4M), NUMA_NO_NODE);
if (!ndtest_pool) { if (!ndtest_pool) {
......
...@@ -1712,7 +1712,9 @@ static void put_dimms(void *data) ...@@ -1712,7 +1712,9 @@ static void put_dimms(void *data)
device_unregister(t->dimm_dev[i]); 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) static int dimm_name_to_id(struct device *dev)
{ {
...@@ -1830,7 +1832,7 @@ static int nfit_test_dimm_init(struct nfit_test *t) ...@@ -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)) if (devm_add_action_or_reset(&t->pdev.dev, put_dimms, t))
return -ENOMEM; return -ENOMEM;
for (i = 0; i < t->num_dcr; i++) { 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, &t->pdev.dev, 0, NULL,
nfit_test_dimm_attribute_groups, nfit_test_dimm_attribute_groups,
"test_dimm%d", i + t->dcr_idx); "test_dimm%d", i + t->dcr_idx);
...@@ -3276,11 +3278,9 @@ static __init int nfit_test_init(void) ...@@ -3276,11 +3278,9 @@ static __init int nfit_test_init(void)
if (!nfit_wq) if (!nfit_wq)
return -ENOMEM; return -ENOMEM;
nfit_test_dimm = class_create("nfit_test_dimm"); rc = class_register(&nfit_test_dimm);
if (IS_ERR(nfit_test_dimm)) { if (rc)
rc = PTR_ERR(nfit_test_dimm);
goto err_register; goto err_register;
}
nfit_pool = gen_pool_create(ilog2(SZ_4M), NUMA_NO_NODE); nfit_pool = gen_pool_create(ilog2(SZ_4M), NUMA_NO_NODE);
if (!nfit_pool) { if (!nfit_pool) {
...@@ -3377,7 +3377,7 @@ static __exit void nfit_test_exit(void) ...@@ -3377,7 +3377,7 @@ static __exit void nfit_test_exit(void)
for (i = 0; i < NUM_NFITS; i++) for (i = 0; i < NUM_NFITS; i++)
put_device(&instances[i]->pdev.dev); put_device(&instances[i]->pdev.dev);
class_destroy(nfit_test_dimm); class_unregister(&nfit_test_dimm);
} }
module_init(nfit_test_init); module_init(nfit_test_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