Skip to content

Commit 33b7bbd

Browse files
committed
Merge branch 'libnvdimm-for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git
2 parents eaa43d6 + 9ea459e commit 33b7bbd

File tree

7 files changed

+32
-25
lines changed

7 files changed

+32
-25
lines changed

drivers/dax/bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static ssize_t do_id_store(struct device_driver *drv, const char *buf,
103103
if (action == ID_ADD) {
104104
dax_id = kzalloc(sizeof(*dax_id), GFP_KERNEL);
105105
if (dax_id) {
106-
strncpy(dax_id->dev_name, buf, DAX_NAME_LEN);
106+
strscpy(dax_id->dev_name, buf, DAX_NAME_LEN);
107107
list_add(&dax_id->list, &dax_drv->ids);
108108
} else
109109
rc = -ENOMEM;

drivers/nvdimm/badrange.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ static void badblocks_populate(struct badrange *badrange,
257257

258258
/**
259259
* nvdimm_badblocks_populate() - Convert a list of badranges to badblocks
260-
* @region: parent region of the range to interrogate
260+
* @nd_region: parent region of the range to interrogate
261261
* @bb: badblocks instance to populate
262-
* @res: resource range to consider
262+
* @range: resource range to consider
263263
*
264264
* The badrange list generated during bus initialization may contain
265265
* multiple, possibly overlapping physical address ranges. Compare each

drivers/nvdimm/nd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ struct nd_region {
422422
struct nd_interleave_set *nd_set;
423423
struct nd_percpu_lane __percpu *lane;
424424
int (*flush)(struct nd_region *nd_region, struct bio *bio);
425-
struct nd_mapping mapping[];
425+
struct nd_mapping mapping[] __counted_by(ndr_mappings);
426426
};
427427

428428
static inline bool nsl_validate_nlabel(struct nd_region *nd_region,

drivers/nvdimm/of_pmem.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ static int of_pmem_region_probe(struct platform_device *pdev)
3030
if (!priv)
3131
return -ENOMEM;
3232

33-
priv->bus_desc.provider_name = kstrdup(pdev->name, GFP_KERNEL);
33+
priv->bus_desc.provider_name = devm_kstrdup(&pdev->dev, pdev->name,
34+
GFP_KERNEL);
35+
if (!priv->bus_desc.provider_name) {
36+
kfree(priv);
37+
return -ENOMEM;
38+
}
39+
3440
priv->bus_desc.module = THIS_MODULE;
3541
priv->bus_desc.of_node = np;
3642

drivers/nvdimm/region_devs.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,8 @@ unsigned int nd_region_acquire_lane(struct nd_region *nd_region)
939939
{
940940
unsigned int cpu, lane;
941941

942-
cpu = get_cpu();
942+
migrate_disable();
943+
cpu = smp_processor_id();
943944
if (nd_region->num_lanes < nr_cpu_ids) {
944945
struct nd_percpu_lane *ndl_lock, *ndl_count;
945946

@@ -958,16 +959,15 @@ EXPORT_SYMBOL(nd_region_acquire_lane);
958959
void nd_region_release_lane(struct nd_region *nd_region, unsigned int lane)
959960
{
960961
if (nd_region->num_lanes < nr_cpu_ids) {
961-
unsigned int cpu = get_cpu();
962+
unsigned int cpu = smp_processor_id();
962963
struct nd_percpu_lane *ndl_lock, *ndl_count;
963964

964965
ndl_count = per_cpu_ptr(nd_region->lane, cpu);
965966
ndl_lock = per_cpu_ptr(nd_region->lane, lane);
966967
if (--ndl_count->count == 0)
967968
spin_unlock(&ndl_lock->lock);
968-
put_cpu();
969969
}
970-
put_cpu();
970+
migrate_enable();
971971
}
972972
EXPORT_SYMBOL(nd_region_release_lane);
973973

@@ -1028,6 +1028,7 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus,
10281028

10291029
if (!nd_region)
10301030
return NULL;
1031+
nd_region->ndr_mappings = ndr_desc->num_mappings;
10311032
/* CXL pre-assigns memregion ids before creating nvdimm regions */
10321033
if (test_bit(ND_REGION_CXL, &ndr_desc->flags)) {
10331034
nd_region->id = ndr_desc->memregion;
@@ -1062,7 +1063,6 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus,
10621063

10631064
get_device(&nvdimm->dev);
10641065
}
1065-
nd_region->ndr_mappings = ndr_desc->num_mappings;
10661066
nd_region->provider_data = ndr_desc->provider_data;
10671067
nd_region->nd_set = ndr_desc->nd_set;
10681068
nd_region->num_lanes = ndr_desc->num_lanes;

tools/testing/nvdimm/test/ndtest.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ enum {
3838

3939
static DEFINE_SPINLOCK(ndtest_lock);
4040
static struct ndtest_priv *instances[NUM_INSTANCES];
41-
static struct class *ndtest_dimm_class;
41+
42+
static const struct class ndtest_dimm_class = {
43+
.name = "nfit_test_dimm",
44+
};
45+
4246
static struct gen_pool *ndtest_pool;
4347

4448
static struct ndtest_dimm dimm_group1[] = {
@@ -737,7 +741,7 @@ static int ndtest_dimm_register(struct ndtest_priv *priv,
737741
return -ENXIO;
738742
}
739743

740-
dimm->dev = device_create_with_groups(ndtest_dimm_class,
744+
dimm->dev = device_create_with_groups(&ndtest_dimm_class,
741745
&priv->pdev.dev,
742746
0, dimm, dimm_attribute_groups,
743747
"test_dimm%d", id);
@@ -906,8 +910,7 @@ static void cleanup_devices(void)
906910
gen_pool_destroy(ndtest_pool);
907911

908912

909-
if (ndtest_dimm_class)
910-
class_destroy(ndtest_dimm_class);
913+
class_unregister(&ndtest_dimm_class);
911914
}
912915

913916
static __init int ndtest_init(void)
@@ -921,11 +924,9 @@ static __init int ndtest_init(void)
921924

922925
nfit_test_setup(ndtest_resource_lookup, NULL);
923926

924-
ndtest_dimm_class = class_create("nfit_test_dimm");
925-
if (IS_ERR(ndtest_dimm_class)) {
926-
rc = PTR_ERR(ndtest_dimm_class);
927+
rc = class_regster(&ndtest_dimm_class);
928+
if (rc)
927929
goto err_register;
928-
}
929930

930931
ndtest_pool = gen_pool_create(ilog2(SZ_4M), NUMA_NO_NODE);
931932
if (!ndtest_pool) {

tools/testing/nvdimm/test/nfit.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,9 @@ static void put_dimms(void *data)
17121712
device_unregister(t->dimm_dev[i]);
17131713
}
17141714

1715-
static struct class *nfit_test_dimm;
1715+
static const struct class nfit_test_dimm = {
1716+
.name = "nfit_test_dimm",
1717+
};
17161718

17171719
static int dimm_name_to_id(struct device *dev)
17181720
{
@@ -1830,7 +1832,7 @@ static int nfit_test_dimm_init(struct nfit_test *t)
18301832
if (devm_add_action_or_reset(&t->pdev.dev, put_dimms, t))
18311833
return -ENOMEM;
18321834
for (i = 0; i < t->num_dcr; i++) {
1833-
t->dimm_dev[i] = device_create_with_groups(nfit_test_dimm,
1835+
t->dimm_dev[i] = device_create_with_groups(&nfit_test_dimm,
18341836
&t->pdev.dev, 0, NULL,
18351837
nfit_test_dimm_attribute_groups,
18361838
"test_dimm%d", i + t->dcr_idx);
@@ -3276,11 +3278,9 @@ static __init int nfit_test_init(void)
32763278
if (!nfit_wq)
32773279
return -ENOMEM;
32783280

3279-
nfit_test_dimm = class_create("nfit_test_dimm");
3280-
if (IS_ERR(nfit_test_dimm)) {
3281-
rc = PTR_ERR(nfit_test_dimm);
3281+
rc = class_register(&nfit_test_dimm);
3282+
if (rc)
32823283
goto err_register;
3283-
}
32843284

32853285
nfit_pool = gen_pool_create(ilog2(SZ_4M), NUMA_NO_NODE);
32863286
if (!nfit_pool) {
@@ -3377,7 +3377,7 @@ static __exit void nfit_test_exit(void)
33773377

33783378
for (i = 0; i < NUM_NFITS; i++)
33793379
put_device(&instances[i]->pdev.dev);
3380-
class_destroy(nfit_test_dimm);
3380+
class_unregister(&nfit_test_dimm);
33813381
}
33823382

33833383
module_init(nfit_test_init);

0 commit comments

Comments
 (0)