Commit 5b26db95 authored by Aneesh Kumar K.V's avatar Aneesh Kumar K.V Committed by Dan Williams

libnvdimm: Use PAGE_SIZE instead of SZ_4K for align check

Architectures have different page size than 4K. Use the PAGE_SIZE
to make sure ranges are correctly aligned.
Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Link: https://lore.kernel.org/r/20190905154603.10349-7-aneesh.kumar@linux.ibm.comSigned-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 047e0eff
...@@ -1006,10 +1006,10 @@ static ssize_t __size_store(struct device *dev, unsigned long long val) ...@@ -1006,10 +1006,10 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
return -ENXIO; return -ENXIO;
} }
div_u64_rem(val, SZ_4K * nd_region->ndr_mappings, &remainder); div_u64_rem(val, PAGE_SIZE * nd_region->ndr_mappings, &remainder);
if (remainder) { if (remainder) {
dev_dbg(dev, "%llu is not %dK aligned\n", val, dev_dbg(dev, "%llu is not %ldK aligned\n", val,
(SZ_4K * nd_region->ndr_mappings) / SZ_1K); (PAGE_SIZE * nd_region->ndr_mappings) / SZ_1K);
return -EINVAL; return -EINVAL;
} }
......
...@@ -944,10 +944,10 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus, ...@@ -944,10 +944,10 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus,
struct nd_mapping_desc *mapping = &ndr_desc->mapping[i]; struct nd_mapping_desc *mapping = &ndr_desc->mapping[i];
struct nvdimm *nvdimm = mapping->nvdimm; struct nvdimm *nvdimm = mapping->nvdimm;
if ((mapping->start | mapping->size) % SZ_4K) { if ((mapping->start | mapping->size) % PAGE_SIZE) {
dev_err(&nvdimm_bus->dev, "%s: %s mapping%d is not 4K aligned\n", dev_err(&nvdimm_bus->dev,
caller, dev_name(&nvdimm->dev), i); "%s: %s mapping%d is not %ld aligned\n",
caller, dev_name(&nvdimm->dev), i, PAGE_SIZE);
return NULL; return NULL;
} }
......
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