mtd: ftl: Use DIV_ROUND_UP()
authorArushi Singhal <arushisinghal19971997@gmail.com>
Sun, 25 Mar 2018 15:37:43 +0000 (21:07 +0530)
committerBoris Brezillon <boris.brezillon@bootlin.com>
Thu, 29 Mar 2018 07:36:01 +0000 (09:36 +0200)
The kernel.h macro DIV_ROUND_UP performs the computation
(((n) + (d) - 1) / (d)) but is perhaps more readable.

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
drivers/mtd/ftl.c

index 0a6adfa..ef6ad25 100644 (file)
@@ -393,8 +393,8 @@ static int prepare_xfer(partition_t *part, int i)
     }
 
     /* Write the BAM stub */
-    nbam = (part->BlocksPerUnit * sizeof(uint32_t) +
-           le32_to_cpu(part->header.BAMOffset) + SECTOR_SIZE - 1) / SECTOR_SIZE;
+    nbam = DIV_ROUND_UP(part->BlocksPerUnit * sizeof(uint32_t) +
+                       le32_to_cpu(part->header.BAMOffset), SECTOR_SIZE);
 
     offset = xfer->Offset + le32_to_cpu(part->header.BAMOffset);
     ctl = cpu_to_le32(BLOCK_CONTROL);