From: Tobias Klauser Use ARRAY_SIZE macro instead of sizeof(x)/sizeof(x[0]) and remove duplicates of the macro. Signed-off-by: Tobias Klauser Cc: Thomas Gleixner Cc: David Woodhouse Signed-off-by: Andrew Morton --- drivers/mtd/chips/amd_flash.c | 4 ++-- drivers/mtd/chips/jedec_probe.c | 2 +- drivers/mtd/devices/lart.c | 10 ++++------ drivers/mtd/devices/ms02-nv.c | 2 +- drivers/mtd/maps/alchemy-flash.c | 4 +--- drivers/mtd/maps/cfi_flagadm.c | 2 +- drivers/mtd/maps/dbox2-flash.c | 2 +- drivers/mtd/maps/dilnetpc.c | 4 ++-- drivers/mtd/maps/dmv182.c | 2 +- drivers/mtd/maps/h720x-flash.c | 2 +- drivers/mtd/maps/netsc520.c | 4 ++-- drivers/mtd/maps/nettel.c | 3 +-- drivers/mtd/maps/ocotea.c | 6 ++---- drivers/mtd/maps/pcmciamtd.c | 2 +- drivers/mtd/maps/redwood.c | 3 +-- drivers/mtd/maps/sbc8240.c | 8 +++----- drivers/mtd/maps/sc520cdp.c | 2 +- drivers/mtd/maps/scx200_docflash.c | 2 +- drivers/mtd/maps/sharpsl-flash.c | 4 +--- drivers/mtd/maps/ts5500_flash.c | 2 +- drivers/mtd/maps/uclinux.c | 2 +- drivers/mtd/nand/au1550nd.c | 4 +--- 22 files changed, 31 insertions(+), 45 deletions(-) diff -puN drivers/mtd/chips/amd_flash.c~drivers-mtd-use-array_size-macro drivers/mtd/chips/amd_flash.c --- devel/drivers/mtd/chips/amd_flash.c~drivers-mtd-use-array_size-macro 2006-03-08 00:00:17.000000000 -0800 +++ devel-akpm/drivers/mtd/chips/amd_flash.c 2006-03-08 00:00:18.000000000 -0800 @@ -664,7 +664,7 @@ static struct mtd_info *amd_flash_probe( 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( 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) * diff -puN drivers/mtd/chips/jedec_probe.c~drivers-mtd-use-array_size-macro drivers/mtd/chips/jedec_probe.c --- devel/drivers/mtd/chips/jedec_probe.c~drivers-mtd-use-array_size-macro 2006-03-08 00:00:17.000000000 -0800 +++ devel-akpm/drivers/mtd/chips/jedec_probe.c 2006-03-08 00:00:18.000000000 -0800 @@ -2035,7 +2035,7 @@ static int jedec_probe_chip(struct map_i 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; iowner = 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; diff -puN drivers/mtd/maps/pcmciamtd.c~drivers-mtd-use-array_size-macro drivers/mtd/maps/pcmciamtd.c --- devel/drivers/mtd/maps/pcmciamtd.c~drivers-mtd-use-array_size-macro 2006-03-08 00:00:18.000000000 -0800 +++ devel-akpm/drivers/mtd/maps/pcmciamtd.c 2006-03-08 00:00:18.000000000 -0800 @@ -616,7 +616,7 @@ static void pcmciamtd_config(dev_link_t } 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) diff -puN drivers/mtd/maps/redwood.c~drivers-mtd-use-array_size-macro drivers/mtd/maps/redwood.c --- devel/drivers/mtd/maps/redwood.c~drivers-mtd-use-array_size-macro 2006-03-08 00:00:18.000000000 -0800 +++ devel-akpm/drivers/mtd/maps/redwood.c 2006-03-08 00:00:18.000000000 -0800 @@ -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; diff -puN drivers/mtd/maps/sbc8240.c~drivers-mtd-use-array_size-macro drivers/mtd/maps/sbc8240.c --- devel/drivers/mtd/maps/sbc8240.c~drivers-mtd-use-array_size-macro 2006-03-08 00:00:18.000000000 -0800 +++ devel-akpm/drivers/mtd/maps/sbc8240.c 2006-03-08 00:00:18.000000000 -0800 @@ -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_p } }; -#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++) { diff -puN drivers/mtd/maps/sc520cdp.c~drivers-mtd-use-array_size-macro drivers/mtd/maps/sc520cdp.c --- devel/drivers/mtd/maps/sc520cdp.c~drivers-mtd-use-array_size-macro 2006-03-08 00:00:18.000000000 -0800 +++ devel-akpm/drivers/mtd/maps/sc520cdp.c 2006-03-08 00:00:18.000000000 -0800 @@ -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; diff -puN drivers/mtd/maps/scx200_docflash.c~drivers-mtd-use-array_size-macro drivers/mtd/maps/scx200_docflash.c --- devel/drivers/mtd/maps/scx200_docflash.c~drivers-mtd-use-array_size-macro 2006-03-08 00:00:18.000000000 -0800 +++ devel-akpm/drivers/mtd/maps/scx200_docflash.c 2006-03-08 00:00:18.000000000 -0800 @@ -70,7 +70,7 @@ static struct mtd_partition partition_in .size = 0x80000 }, }; -#define NUM_PARTITIONS (sizeof(partition_info)/sizeof(partition_info[0])) +#define NUM_PARTITIONS ARRAY_SIZE(partition_info) #endif diff -puN drivers/mtd/maps/sharpsl-flash.c~drivers-mtd-use-array_size-macro drivers/mtd/maps/sharpsl-flash.c --- devel/drivers/mtd/maps/sharpsl-flash.c~drivers-mtd-use-array_size-macro 2006-03-08 00:00:18.000000000 -0800 +++ devel-akpm/drivers/mtd/maps/sharpsl-flash.c 2006-03-08 00:00:18.000000000 -0800 @@ -49,8 +49,6 @@ static struct mtd_partition sharpsl_part } }; -#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); diff -puN drivers/mtd/maps/ts5500_flash.c~drivers-mtd-use-array_size-macro drivers/mtd/maps/ts5500_flash.c --- devel/drivers/mtd/maps/ts5500_flash.c~drivers-mtd-use-array_size-macro 2006-03-08 00:00:18.000000000 -0800 +++ devel-akpm/drivers/mtd/maps/ts5500_flash.c 2006-03-08 00:00:18.000000000 -0800 @@ -64,7 +64,7 @@ static struct mtd_partition ts5500_parti } }; -#define NUM_PARTITIONS (sizeof(ts5500_partitions)/sizeof(struct mtd_partition)) +#define NUM_PARTITIONS ARRAY_SIZE(ts5500_partitions) static struct mtd_info *mymtd; diff -puN drivers/mtd/maps/uclinux.c~drivers-mtd-use-array_size-macro drivers/mtd/maps/uclinux.c --- devel/drivers/mtd/maps/uclinux.c~drivers-mtd-use-array_size-macro 2006-03-08 00:00:18.000000000 -0800 +++ devel-akpm/drivers/mtd/maps/uclinux.c 2006-03-08 00:00:18.000000000 -0800 @@ -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) /****************************************************************************/ diff -puN drivers/mtd/nand/au1550nd.c~drivers-mtd-use-array_size-macro drivers/mtd/nand/au1550nd.c --- devel/drivers/mtd/nand/au1550nd.c~drivers-mtd-use-array_size-macro 2006-03-08 00:00:18.000000000 -0800 +++ devel-akpm/drivers/mtd/nand/au1550nd.c 2006-03-08 00:00:18.000000000 -0800 @@ -55,8 +55,6 @@ static const struct mtd_partition partit .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; _