Skip to content

Commit 5b26db9

Browse files
kvaneeshdjbw
authored andcommitted
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: Aneesh Kumar K.V <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dan Williams <[email protected]>
1 parent 047e0ef commit 5b26db9

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

drivers/nvdimm/namespace_devs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,10 +1006,10 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
10061006
return -ENXIO;
10071007
}
10081008

1009-
div_u64_rem(val, SZ_4K * nd_region->ndr_mappings, &remainder);
1009+
div_u64_rem(val, PAGE_SIZE * nd_region->ndr_mappings, &remainder);
10101010
if (remainder) {
1011-
dev_dbg(dev, "%llu is not %dK aligned\n", val,
1012-
(SZ_4K * nd_region->ndr_mappings) / SZ_1K);
1011+
dev_dbg(dev, "%llu is not %ldK aligned\n", val,
1012+
(PAGE_SIZE * nd_region->ndr_mappings) / SZ_1K);
10131013
return -EINVAL;
10141014
}
10151015

drivers/nvdimm/region_devs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -944,10 +944,10 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus,
944944
struct nd_mapping_desc *mapping = &ndr_desc->mapping[i];
945945
struct nvdimm *nvdimm = mapping->nvdimm;
946946

947-
if ((mapping->start | mapping->size) % SZ_4K) {
948-
dev_err(&nvdimm_bus->dev, "%s: %s mapping%d is not 4K aligned\n",
949-
caller, dev_name(&nvdimm->dev), i);
950-
947+
if ((mapping->start | mapping->size) % PAGE_SIZE) {
948+
dev_err(&nvdimm_bus->dev,
949+
"%s: %s mapping%d is not %ld aligned\n",
950+
caller, dev_name(&nvdimm->dev), i, PAGE_SIZE);
951951
return NULL;
952952
}
953953

0 commit comments

Comments
 (0)