[PATCH 4/8 linux-next] libnvdimm, namespace: avoid multiple sector calculations

From: Fabian Frederick
Date: Fri Dec 02 2016 - 14:21:08 EST


add cleared_sectors variable to add more readability.

Signed-off-by: Fabian Frederick <fabf@xxxxxxxxx>
---
drivers/nvdimm/pmem.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 204912c..4da4735 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -52,16 +52,16 @@ static int pmem_clear_poison(struct pmem_device *pmem, phys_addr_t offset,
{
struct device *dev = to_dev(pmem);
sector_t sector;
- long cleared;
+ long cleared, cleared_sectors;

sector = (offset - pmem->data_offset) / 512;
cleared = nvdimm_clear_poison(dev, pmem->phys_addr + offset, len);
-
- if (cleared > 0 && cleared / 512) {
+ cleared_sectors = cleared / 512;
+ if (cleared > 0 && cleared_sectors) {
dev_dbg(dev, "%s: %#llx clear %ld sector%s\n",
- __func__, (unsigned long long) sector,
- cleared / 512, cleared / 512 > 1 ? "s" : "");
- badblocks_clear(&pmem->bb, sector, cleared / 512);
+ __func__, (unsigned long long) sector,
+ cleared_sectors, cleared_sectors > 1 ? "s" : "");
+ badblocks_clear(&pmem->bb, sector, cleared_sectors);
} else {
return -EIO;
}
--
2.7.4