diff mbox series

libnvdimm, badrange: replace div_u64_rem with DIV_ROUND_UP

Message ID f08656fd-ba11-a556-dacd-cc573ac2e069@huawei.com (mailing list archive)
State Superseded
Headers show
Series libnvdimm, badrange: replace div_u64_rem with DIV_ROUND_UP | expand

Commit Message

Kemeng Shi June 26, 2021, 3:29 a.m. UTC
__add_badblock_range use div_u64_rem to round up end_sector and it will
introduces unnecessary rem define and costly '%' operation. So clean it
with DIV_ROUND_UP.

Signed-off-by: Kemeng Shi <shikemeng@huawei.com>
---
 drivers/nvdimm/badrange.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/nvdimm/badrange.c b/drivers/nvdimm/badrange.c
index aaf6e215a8c6..28e73506d85e 100644
--- a/drivers/nvdimm/badrange.c
+++ b/drivers/nvdimm/badrange.c
@@ -187,12 +187,9 @@  static void __add_badblock_range(struct badblocks *bb, u64 ns_offset, u64 len)
 	const unsigned int sector_size = 512;
 	sector_t start_sector, end_sector;
 	u64 num_sectors;
-	u32 rem;

 	start_sector = div_u64(ns_offset, sector_size);
-	end_sector = div_u64_rem(ns_offset + len, sector_size, &rem);
-	if (rem)
-		end_sector++;
+	end_sector = end_sector = DIV_ROUND_UP(ns_offset + len, sector_size);
 	num_sectors = end_sector - start_sector;

 	if (unlikely(num_sectors > (u64)INT_MAX)) {