[MTD] Use DIV_ROUND_UP
authorJulia Lawall <julia@diku.dk>
Sat, 2 Aug 2008 15:14:21 +0000 (17:14 +0200)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Sat, 2 Aug 2008 17:45:18 +0000 (18:45 +0100)
The kernel.h macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) /
(d)) but is perhaps more readable.

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/chips/cfi_cmdset_0001.c
drivers/mtd/chips/gen_probe.c
drivers/mtd/ssfdc.c

index 5f1b472137a024b96fcff3ea3f9bcd654c7389f8..d49cbe2738a89a7c33f8996b6be433868c9584e1 100644 (file)
@@ -1640,7 +1640,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
 
        /* Figure out the number of words to write */
        word_gap = (-adr & (map_bankwidth(map)-1));
-       words = (len - word_gap + map_bankwidth(map) - 1) / map_bankwidth(map);
+       words = DIV_ROUND_UP(len - word_gap, map_bankwidth(map));
        if (!word_gap) {
                words--;
        } else {
index f061885b2812dc5d04bba96f488aa6fa18a9ae49..e2dc96441e05e0a6affa6c5fa2611fef0f545d9e 100644 (file)
@@ -111,7 +111,7 @@ static struct cfi_private *genprobe_ident_chips(struct map_info *map, struct chi
                max_chips = 1;
        }
 
-       mapsize = sizeof(long) * ( (max_chips + BITS_PER_LONG-1) / BITS_PER_LONG );
+       mapsize = sizeof(long) * DIV_ROUND_UP(max_chips, BITS_PER_LONG);
        chip_map = kzalloc(mapsize, GFP_KERNEL);
        if (!chip_map) {
                printk(KERN_WARNING "%s: kmalloc failed for CFI chip map\n", map->name);
index a5f3d60047d47f50da60ce7b8569ef326542173d..33a5d6ed6f18aa66181feb4ac84774343e68d5d3 100644 (file)
@@ -321,8 +321,7 @@ static void ssfdcr_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
        DEBUG(MTD_DEBUG_LEVEL1,
                "SSFDC_RO: cis_block=%d,erase_size=%d,map_len=%d,n_zones=%d\n",
                ssfdc->cis_block, ssfdc->erase_size, ssfdc->map_len,
-               (ssfdc->map_len + MAX_PHYS_BLK_PER_ZONE - 1) /
-               MAX_PHYS_BLK_PER_ZONE);
+               DIV_ROUND_UP(ssfdc->map_len, MAX_PHYS_BLK_PER_ZONE));
 
        /* Set geometry */
        ssfdc->heads = 16;