diff mbox series

null_blk: fix compilation error on 32-bit arch

Message ID 20210129063316.638610-1-damien.lemoal@wdc.com (mailing list archive)
State New, archived
Headers show
Series null_blk: fix compilation error on 32-bit arch | expand

Commit Message

Damien Le Moal Jan. 29, 2021, 6:33 a.m. UTC
Calculating the total number of zones of the device using DIV_ROUND_UP()
with two 64-bit arguments causes a compilation error on 32-bit arch
(undefined reference to `__udivdi3'). Replace this macro with a call
to round_up() to round up the device capacity to the zone size and a
bit shift operation for dividing the rounded capacity by the zone size.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
 drivers/block/null_blk/zoned.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series


diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
index 535351570bb2..fce0a54df0e5 100644
--- a/drivers/block/null_blk/zoned.c
+++ b/drivers/block/null_blk/zoned.c
@@ -83,7 +83,8 @@  int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q)
 	zone_capacity_sects = mb_to_sects(dev->zone_capacity);
 	dev_capacity_sects = mb_to_sects(dev->size);
 	dev->zone_size_sects = mb_to_sects(dev->zone_size);
-	dev->nr_zones = DIV_ROUND_UP(dev_capacity_sects, dev->zone_size_sects);
+	dev->nr_zones = round_up(dev_capacity_sects, dev->zone_size_sects)
+		>> ilog2(dev->zone_size_sects);
 	dev->zones = kvmalloc_array(dev->nr_zones, sizeof(struct nullb_zone),
 				    GFP_KERNEL | __GFP_ZERO);