libnvdimm: Use PAGE_SIZE instead of SZ_4K for align check
authorAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Thu, 5 Sep 2019 15:46:02 +0000 (21:16 +0530)
committerDan Williams <dan.j.williams@intel.com>
Thu, 5 Sep 2019 23:11:14 +0000 (16:11 -0700)
Architectures have different page size than 4K. Use the PAGE_SIZE
to make sure ranges are correctly aligned.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Link: https://lore.kernel.org/r/20190905154603.10349-7-aneesh.kumar@linux.ibm.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/nvdimm/namespace_devs.c
drivers/nvdimm/region_devs.c

index 3be81f7b9ed346f14adc9330742b2ce7376e723c..43401325c874440823bbbce1ade81353bc0d6a23 100644 (file)
@@ -1006,10 +1006,10 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
                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) {
-               dev_dbg(dev, "%llu is not %dK aligned\n", val,
-                               (SZ_4K * nd_region->ndr_mappings) / SZ_1K);
+               dev_dbg(dev, "%llu is not %ldK aligned\n", val,
+                               (PAGE_SIZE * nd_region->ndr_mappings) / SZ_1K);
                return -EINVAL;
        }
 
index cd6da354eae49ce2a010e61b8ef1da18c15d7477..3fd6b59abd33049293df0ddc3c98d023f1c7cd8d 100644 (file)
@@ -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 nvdimm *nvdimm = mapping->nvdimm;
 
-               if ((mapping->start | mapping->size) % SZ_4K) {
-                       dev_err(&nvdimm_bus->dev, "%s: %s mapping%d is not 4K aligned\n",
-                                       caller, dev_name(&nvdimm->dev), i);
-
+               if ((mapping->start | mapping->size) % PAGE_SIZE) {
+                       dev_err(&nvdimm_bus->dev,
+                               "%s: %s mapping%d is not %ld aligned\n",
+                               caller, dev_name(&nvdimm->dev), i, PAGE_SIZE);
                        return NULL;
                }