]> err.no Git - linux-2.6/commitdiff
[PATCH] drivers/mtd: Use ARRAY_SIZE macro
authorTobias Klauser <tklauser@nuerscht.ch>
Fri, 31 Mar 2006 10:29:45 +0000 (02:29 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Fri, 31 Mar 2006 20:18:48 +0000 (12:18 -0800)
Use ARRAY_SIZE macro instead of sizeof(x)/sizeof(x[0]) and remove
duplicates of the macro.

Signed-off-by: Tobias Klauser <tklauser@nuerscht.ch>
Cc: Thomas Gleixner <tglx@linutronix.de>
Acked-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
22 files changed:
drivers/mtd/chips/amd_flash.c
drivers/mtd/chips/jedec_probe.c
drivers/mtd/devices/lart.c
drivers/mtd/devices/ms02-nv.c
drivers/mtd/maps/alchemy-flash.c
drivers/mtd/maps/cfi_flagadm.c
drivers/mtd/maps/dbox2-flash.c
drivers/mtd/maps/dilnetpc.c
drivers/mtd/maps/dmv182.c
drivers/mtd/maps/h720x-flash.c
drivers/mtd/maps/netsc520.c
drivers/mtd/maps/nettel.c
drivers/mtd/maps/ocotea.c
drivers/mtd/maps/pcmciamtd.c
drivers/mtd/maps/redwood.c
drivers/mtd/maps/sbc8240.c
drivers/mtd/maps/sc520cdp.c
drivers/mtd/maps/scx200_docflash.c
drivers/mtd/maps/sharpsl-flash.c
drivers/mtd/maps/ts5500_flash.c
drivers/mtd/maps/uclinux.c
drivers/mtd/nand/au1550nd.c

index fdb91b6f1d979254e63b0256f7fbdf54fc3e1ac7..57115618c4968903e0a4d70052bc6d54c6e64e3b 100644 (file)
@@ -664,7 +664,7 @@ static struct mtd_info *amd_flash_probe(struct map_info *map)
        printk("%s: Probing for AMD compatible flash...\n", map->name);
 
        if ((table_pos[0] = probe_new_chip(mtd, 0, NULL, &temp, table,
-                                          sizeof(table)/sizeof(table[0])))
+                                          ARRAY_SIZE(table)))
            == -1) {
                printk(KERN_WARNING
                       "%s: Found no AMD compatible device at location zero\n",
@@ -696,7 +696,7 @@ static struct mtd_info *amd_flash_probe(struct map_info *map)
             base += (1 << temp.chipshift)) {
                int numchips = temp.numchips;
                table_pos[numchips] = probe_new_chip(mtd, base, chips,
-                       &temp, table, sizeof(table)/sizeof(table[0]));
+                       &temp, table, ARRAY_SIZE(table));
        }
 
        mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) *
index edb306c03c0a14b8f1e9b0f50382f05a08e5d4d2..8e24be0fae1fe21691a78b583a7560accd39731c 100644 (file)
@@ -2035,7 +2035,7 @@ static int jedec_probe_chip(struct map_info *map, __u32 base,
                DEBUG(MTD_DEBUG_LEVEL3,
                      "Search for id:(%02x %02x) interleave(%d) type(%d)\n",
                        cfi->mfr, cfi->id, cfi_interleave(cfi), cfi->device_type);
-               for (i=0; i<sizeof(jedec_table)/sizeof(jedec_table[0]); i++) {
+               for (i = 0; i < ARRAY_SIZE(jedec_table); i++) {
                        if ( jedec_match( base, map, cfi, &jedec_table[i] ) ) {
                                DEBUG( MTD_DEBUG_LEVEL3,
                                       "MTD %s(): matched device 0x%x,0x%x unlock_addrs: 0x%.4x 0x%.4x\n",
index 1e876fcb04084ca43ff366803973fad01ee9b833..29b0ddaa324e417abf153460d7d94fb67823a6ef 100644 (file)
@@ -581,8 +581,6 @@ static int flash_write (struct mtd_info *mtd,loff_t to,size_t len,size_t *retlen
 
 /***************************************************************************************************/
 
-#define NB_OF(x) (sizeof (x) / sizeof (x[0]))
-
 static struct mtd_info mtd;
 
 static struct mtd_erase_region_info erase_regions[] = {
@@ -640,7 +638,7 @@ int __init lart_flash_init (void)
    mtd.flags = MTD_CAP_NORFLASH;
    mtd.size = FLASH_BLOCKSIZE_PARAM * FLASH_NUMBLOCKS_16m_PARAM + FLASH_BLOCKSIZE_MAIN * FLASH_NUMBLOCKS_16m_MAIN;
    mtd.erasesize = FLASH_BLOCKSIZE_MAIN;
-   mtd.numeraseregions = NB_OF (erase_regions);
+   mtd.numeraseregions = ARRAY_SIZE(erase_regions);
    mtd.eraseregions = erase_regions;
    mtd.erase = flash_erase;
    mtd.read = flash_read;
@@ -670,9 +668,9 @@ int __init lart_flash_init (void)
                           result,mtd.eraseregions[result].numblocks);
 
 #ifdef HAVE_PARTITIONS
-   printk ("\npartitions = %d\n",NB_OF (lart_partitions));
+   printk ("\npartitions = %d\n", ARRAY_SIZE(lart_partitions));
 
-   for (result = 0; result < NB_OF (lart_partitions); result++)
+   for (result = 0; result < ARRAY_SIZE(lart_partitions); result++)
         printk (KERN_DEBUG
                         "\n\n"
                         "lart_partitions[%d].name = %s\n"
@@ -687,7 +685,7 @@ int __init lart_flash_init (void)
 #ifndef HAVE_PARTITIONS
    result = add_mtd_device (&mtd);
 #else
-   result = add_mtd_partitions (&mtd,lart_partitions,NB_OF (lart_partitions));
+   result = add_mtd_partitions (&mtd,lart_partitions, ARRAY_SIZE(lart_partitions));
 #endif
 
    return (result);
index 0ff2e4378244c0603a39a03bd40664d207ec7c7a..485f663493d295fc7e796507af7c774ddfba503c 100644 (file)
@@ -308,7 +308,7 @@ static int __init ms02nv_init(void)
                break;
        }
 
-       for (i = 0; i < (sizeof(ms02nv_addrs) / sizeof(*ms02nv_addrs)); i++)
+       for (i = 0; i < ARRAY_SIZE(ms02nv_addrs); i++)
                if (!ms02nv_init_one(ms02nv_addrs[i] << stride))
                        count++;
 
index a57791a6ce402a754e32f6dec0b40523ffe11eda..b933a2a27b18c3b795aa3b060488564ad84baff5 100644 (file)
@@ -126,8 +126,6 @@ static struct mtd_partition alchemy_partitions[] = {
         }
 };
 
-#define NB_OF(x)  (sizeof(x)/sizeof(x[0]))
-
 static struct mtd_info *mymtd;
 
 int __init alchemy_mtd_init(void)
@@ -154,7 +152,7 @@ int __init alchemy_mtd_init(void)
         * Static partition definition selection
         */
        parts = alchemy_partitions;
-       nb_parts = NB_OF(alchemy_partitions);
+       nb_parts = ARRAY_SIZE(alchemy_partitions);
        alchemy_map.size = window_size;
 
        /*
index 6a8c0415bde87b6c7432f5307d84e8a301f0990e..fd0f0d3187de3bb7efad5400b1d6dbc82e55b35b 100644 (file)
@@ -86,7 +86,7 @@ struct mtd_partition flagadm_parts[] = {
        }
 };
 
-#define PARTITION_COUNT (sizeof(flagadm_parts)/sizeof(struct mtd_partition))
+#define PARTITION_COUNT ARRAY_SIZE(flagadm_parts)
 
 static struct mtd_info *mymtd;
 
index 49d90542fc752859bd0f80ec083ae75044997c03..652813cd6c2d47f0dbb92113f912fd2cde2bf7ab 100644 (file)
@@ -57,7 +57,7 @@ static struct mtd_partition partition_info[]= {
        }
 };
 
-#define NUM_PARTITIONS (sizeof(partition_info) / sizeof(partition_info[0]))
+#define NUM_PARTITIONS ARRAY_SIZE(partition_info)
 
 #define WINDOW_ADDR 0x10000000
 #define WINDOW_SIZE 0x800000
index efb221692641e6ff0ae03ab444cc1d4803ef73e5..c299d10b33e6ee10de83511acb61ad8c9897626c 100644 (file)
@@ -300,7 +300,7 @@ static struct mtd_partition partition_info[]=
        },
 };
 
-#define NUM_PARTITIONS (sizeof(partition_info)/sizeof(partition_info[0]))
+#define NUM_PARTITIONS ARRAY_SIZE(partition_info)
 
 static struct mtd_info *mymtd;
 static struct mtd_info *lowlvl_parts[NUM_PARTITIONS];
@@ -345,7 +345,7 @@ static struct mtd_partition higlvl_partition_info[]=
        },
 };
 
-#define NUM_HIGHLVL_PARTITIONS (sizeof(higlvl_partition_info)/sizeof(partition_info[0]))
+#define NUM_HIGHLVL_PARTITIONS ARRAY_SIZE(higlvl_partition_info)
 
 
 static int dnp_adnp_probe(void)
index b993ac01a9a5f8b10b6048e1e9ab75454cf3cddf..2bb3c0f0f97048b4ac9485794b97193052c2250f 100644 (file)
@@ -99,7 +99,7 @@ static struct mtd_info *this_mtd;
 static int __init init_svme182(void)
 {
        struct mtd_partition *partitions;
-       int num_parts = sizeof(svme182_partitions) / sizeof(struct mtd_partition);
+       int num_parts = ARRAY_SIZE(svme182_partitions);
 
        partitions = svme182_partitions;
 
index 3190948211011b16211950cba7e7dab9c4b89251..0667101ccbe1df53ef15e8baf88655b1bdf0496f 100644 (file)
@@ -59,7 +59,7 @@ static struct mtd_partition h720x_partitions[] = {
         }
 };
 
-#define NUM_PARTITIONS  (sizeof(h720x_partitions)/sizeof(h720x_partitions[0]))
+#define NUM_PARTITIONS ARRAY_SIZE(h720x_partitions)
 
 static int                   nr_mtd_parts;
 static struct mtd_partition *mtd_parts;
index 33060a31572217b6feb25ba8d288323fbc492555..ed215470158bf808cff3e7d150715a8170c22bbd 100644 (file)
@@ -76,7 +76,7 @@ static struct mtd_partition partition_info[]={
            .size = 0x80000
     },
 };
-#define NUM_PARTITIONS (sizeof(partition_info)/sizeof(partition_info[0]))
+#define NUM_PARTITIONS ARRAY_SIZE(partition_info)
 
 #define WINDOW_SIZE    0x00100000
 #define WINDOW_ADDR    0x00200000
@@ -88,7 +88,7 @@ static struct map_info netsc520_map = {
        .phys = WINDOW_ADDR,
 };
 
-#define NUM_FLASH_BANKS        (sizeof(netsc520_map)/sizeof(struct map_info))
+#define NUM_FLASH_BANKS        ARRAY_SIZE(netsc520_map)
 
 static struct mtd_info *mymtd;
 
index 632eb2aa968f476b9686bd46cea03157ed5cb376..54a3102ab19a8868cbd18c2d1ce5cf9c92111ea6 100644 (file)
@@ -128,8 +128,7 @@ static struct mtd_partition nettel_amd_partitions[] = {
        }
 };
 
-#define NUM_AMD_PARTITIONS \
-       (sizeof(nettel_amd_partitions)/sizeof(nettel_amd_partitions[0]))
+#define NUM_AMD_PARTITIONS ARRAY_SIZE(nettel_amd_partitions)
 
 /****************************************************************************/
 
index c223514ca2ebef9a9da381ff7bfb93fc040edd7b..a21fcd195ab40ddd1b2692c889bdc473131f711c 100644 (file)
@@ -58,8 +58,6 @@ static struct mtd_partition ocotea_large_partitions[] = {
        }
 };
 
-#define NB_OF(x)  (sizeof(x)/sizeof(x[0]))
-
 int __init init_ocotea(void)
 {
        u8 fpga0_reg;
@@ -97,7 +95,7 @@ int __init init_ocotea(void)
        if (flash) {
                flash->owner = THIS_MODULE;
                add_mtd_partitions(flash, ocotea_small_partitions,
-                                       NB_OF(ocotea_small_partitions));
+                                       ARRAY_SIZE(ocotea_small_partitions));
        } else {
                printk("map probe failed for flash\n");
                return -ENXIO;
@@ -118,7 +116,7 @@ int __init init_ocotea(void)
        if (flash) {
                flash->owner = THIS_MODULE;
                add_mtd_partitions(flash, ocotea_large_partitions,
-                                       NB_OF(ocotea_large_partitions));
+                                       ARRAY_SIZE(ocotea_large_partitions));
        } else {
                printk("map probe failed for flash\n");
                return -ENXIO;
index f988c817e196c9ba3a7185817234158e06aa4398..8bbc751a60218eed3c017c87001631a62b084df2 100644 (file)
@@ -616,7 +616,7 @@ static void pcmciamtd_config(dev_link_t *link)
        } else if(mem_type == 2) {
                mtd = do_map_probe("map_rom", &dev->pcmcia_map);
        } else {
-               for(i = 0; i < sizeof(probes) / sizeof(char *); i++) {
+               for(i = 0; i < ARRAY_SIZE(probes); i++) {
                        DEBUG(1, "Trying %s", probes[i]);
                        mtd = do_map_probe(probes[i], &dev->pcmcia_map);
                        if(mtd)
index 5b76ed8861859d7ce47305de56b35ec991f4a11a..50b14033613f665554af3fc93168cfd126ab3709 100644 (file)
@@ -121,8 +121,7 @@ struct map_info redwood_flash_map = {
 };
 
 
-#define NUM_REDWOOD_FLASH_PARTITIONS \
-       (sizeof(redwood_flash_partitions)/sizeof(redwood_flash_partitions[0]))
+#define NUM_REDWOOD_FLASH_PARTITIONS ARRAY_SIZE(redwood_flash_partitions)
 
 static struct mtd_info *redwood_mtd;
 
index 225cdd9ba5b2f2d84054686d826e8cfff028b75b..350286dc1d2eeaa0d8eedf39f3a095b51f38f231 100644 (file)
@@ -66,7 +66,7 @@ static struct map_info sbc8240_map[2] = {
        }
 };
 
-#define NUM_FLASH_BANKS        (sizeof(sbc8240_map) / sizeof(struct map_info))
+#define NUM_FLASH_BANKS        ARRAY_SIZE(sbc8240_map)
 
 /*
  * The following defines the partition layout of SBC8240 boards.
@@ -125,8 +125,6 @@ static struct mtd_partition sbc8240_fs_partitions [] = {
        }
 };
 
-#define NB_OF(x) (sizeof (x) / sizeof (x[0]))
-
 /* trivial struct to describe partition information */
 struct mtd_part_def
 {
@@ -190,10 +188,10 @@ int __init init_sbc8240_mtd (void)
 #ifdef CONFIG_MTD_PARTITIONS
        sbc8240_part_banks[0].mtd_part   = sbc8240_uboot_partitions;
        sbc8240_part_banks[0].type       = "static image";
-       sbc8240_part_banks[0].nums       = NB_OF(sbc8240_uboot_partitions);
+       sbc8240_part_banks[0].nums       = ARRAY_SIZE(sbc8240_uboot_partitions);
        sbc8240_part_banks[1].mtd_part   = sbc8240_fs_partitions;
        sbc8240_part_banks[1].type       = "static file system";
-       sbc8240_part_banks[1].nums       = NB_OF(sbc8240_fs_partitions);
+       sbc8240_part_banks[1].nums       = ARRAY_SIZE(sbc8240_fs_partitions);
 
        for (i = 0; i < NUM_FLASH_BANKS; i++) {
 
index ed92afadd8a91b4e13183c314b62ea8b88085406..e8c130e1efd320aeb784d2f7fa50df9a1f7eff8e 100644 (file)
@@ -107,7 +107,7 @@ static struct map_info sc520cdp_map[] = {
        },
 };
 
-#define NUM_FLASH_BANKS        (sizeof(sc520cdp_map)/sizeof(struct map_info))
+#define NUM_FLASH_BANKS        ARRAY_SIZE(sc520cdp_map)
 
 static struct mtd_info *mymtd[NUM_FLASH_BANKS];
 static struct mtd_info *merged_mtd;
index 2c91dff8bb60c881e015d9e8e6d53b6bba3c669c..28b8a571a91a4ff60f133b5de4ed127684d5d78c 100644 (file)
@@ -70,7 +70,7 @@ static struct mtd_partition partition_info[] = {
                .size   = 0x80000
        },
 };
-#define NUM_PARTITIONS (sizeof(partition_info)/sizeof(partition_info[0]))
+#define NUM_PARTITIONS ARRAY_SIZE(partition_info)
 #endif
 
 
index 999f4bb3d845ce475322c88db98f774036dbcbfb..12fe53c0d2fc124eeb6a479f7e94713b8c773507 100644 (file)
@@ -49,8 +49,6 @@ static struct mtd_partition sharpsl_partitions[1] = {
        }
 };
 
-#define NB_OF(x)  (sizeof(x)/sizeof(x[0]))
-
 int __init init_sharpsl(void)
 {
        struct mtd_partition *parts;
@@ -92,7 +90,7 @@ int __init init_sharpsl(void)
        }
 
        parts = sharpsl_partitions;
-       nb_parts = NB_OF(sharpsl_partitions);
+       nb_parts = ARRAY_SIZE(sharpsl_partitions);
 
        printk(KERN_NOTICE "Using %s partision definition\n", part_type);
        add_mtd_partitions(mymtd, parts, nb_parts);
index 4b372bcb17f1c0b6dbd5ec3312aa59edbb97f7dd..a7422c200567d8afd583b201745b13db2c81a102 100644 (file)
@@ -64,7 +64,7 @@ static struct mtd_partition ts5500_partitions[] = {
        }
 };
 
-#define NUM_PARTITIONS (sizeof(ts5500_partitions)/sizeof(struct mtd_partition))
+#define NUM_PARTITIONS ARRAY_SIZE(ts5500_partitions)
 
 static struct mtd_info *mymtd;
 
index 79d92808b766fea1f006faedb5fb0d914d712238..f7264dc2ac9bc0dab0c9c62e904f28e380d0dfdd 100644 (file)
@@ -37,7 +37,7 @@ struct mtd_partition uclinux_romfs[] = {
        { .name = "ROMfs" }
 };
 
-#define        NUM_PARTITIONS  (sizeof(uclinux_romfs) / sizeof(uclinux_romfs[0]))
+#define        NUM_PARTITIONS  ARRAY_SIZE(uclinux_romfs)
 
 /****************************************************************************/
 
index 201e1362da14748a493dea2acd719c72fd750e83..bde3550910a2e12626b7255e23a92982776a8668 100644 (file)
@@ -55,8 +55,6 @@ static const struct mtd_partition partition_info[] = {
                .size   =    MTDPART_SIZ_FULL
        }
 };
-#define NB_OF(x)  (sizeof(x)/sizeof(x[0]))
-
 
 /**
  * au_read_byte -  read one byte from the chip
@@ -462,7 +460,7 @@ int __init au1xxx_nand_init (void)
        }
 
        /* Register the partitions */
-       add_mtd_partitions(au1550_mtd, partition_info, NB_OF(partition_info));
+       add_mtd_partitions(au1550_mtd, partition_info, ARRAY_SIZE(partition_info));
 
        return 0;