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,
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;
......
......@@ -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
......
......@@ -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,
......
......@@ -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;
......
......@@ -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;
......
......@@ -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) {
......
......@@ -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);
......
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