Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] drivers/mtd: Use ARRAY_SIZE macro

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>

authored by

Tobias Klauser and committed by
Linus Torvalds
87d10f3c 54af6b46

+31 -45
+2 -2
drivers/mtd/chips/amd_flash.c
··· 664 664 printk("%s: Probing for AMD compatible flash...\n", map->name); 665 665 666 666 if ((table_pos[0] = probe_new_chip(mtd, 0, NULL, &temp, table, 667 - sizeof(table)/sizeof(table[0]))) 667 + ARRAY_SIZE(table))) 668 668 == -1) { 669 669 printk(KERN_WARNING 670 670 "%s: Found no AMD compatible device at location zero\n", ··· 696 696 base += (1 << temp.chipshift)) { 697 697 int numchips = temp.numchips; 698 698 table_pos[numchips] = probe_new_chip(mtd, base, chips, 699 - &temp, table, sizeof(table)/sizeof(table[0])); 699 + &temp, table, ARRAY_SIZE(table)); 700 700 } 701 701 702 702 mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) *
+1 -1
drivers/mtd/chips/jedec_probe.c
··· 2035 2035 DEBUG(MTD_DEBUG_LEVEL3, 2036 2036 "Search for id:(%02x %02x) interleave(%d) type(%d)\n", 2037 2037 cfi->mfr, cfi->id, cfi_interleave(cfi), cfi->device_type); 2038 - for (i=0; i<sizeof(jedec_table)/sizeof(jedec_table[0]); i++) { 2038 + for (i = 0; i < ARRAY_SIZE(jedec_table); i++) { 2039 2039 if ( jedec_match( base, map, cfi, &jedec_table[i] ) ) { 2040 2040 DEBUG( MTD_DEBUG_LEVEL3, 2041 2041 "MTD %s(): matched device 0x%x,0x%x unlock_addrs: 0x%.4x 0x%.4x\n",
+4 -6
drivers/mtd/devices/lart.c
··· 581 581 582 582 /***************************************************************************************************/ 583 583 584 - #define NB_OF(x) (sizeof (x) / sizeof (x[0])) 585 - 586 584 static struct mtd_info mtd; 587 585 588 586 static struct mtd_erase_region_info erase_regions[] = { ··· 638 640 mtd.flags = MTD_CAP_NORFLASH; 639 641 mtd.size = FLASH_BLOCKSIZE_PARAM * FLASH_NUMBLOCKS_16m_PARAM + FLASH_BLOCKSIZE_MAIN * FLASH_NUMBLOCKS_16m_MAIN; 640 642 mtd.erasesize = FLASH_BLOCKSIZE_MAIN; 641 - mtd.numeraseregions = NB_OF (erase_regions); 643 + mtd.numeraseregions = ARRAY_SIZE(erase_regions); 642 644 mtd.eraseregions = erase_regions; 643 645 mtd.erase = flash_erase; 644 646 mtd.read = flash_read; ··· 668 670 result,mtd.eraseregions[result].numblocks); 669 671 670 672 #ifdef HAVE_PARTITIONS 671 - printk ("\npartitions = %d\n",NB_OF (lart_partitions)); 673 + printk ("\npartitions = %d\n", ARRAY_SIZE(lart_partitions)); 672 674 673 - for (result = 0; result < NB_OF (lart_partitions); result++) 675 + for (result = 0; result < ARRAY_SIZE(lart_partitions); result++) 674 676 printk (KERN_DEBUG 675 677 "\n\n" 676 678 "lart_partitions[%d].name = %s\n" ··· 685 687 #ifndef HAVE_PARTITIONS 686 688 result = add_mtd_device (&mtd); 687 689 #else 688 - result = add_mtd_partitions (&mtd,lart_partitions,NB_OF (lart_partitions)); 690 + result = add_mtd_partitions (&mtd,lart_partitions, ARRAY_SIZE(lart_partitions)); 689 691 #endif 690 692 691 693 return (result);
+1 -1
drivers/mtd/devices/ms02-nv.c
··· 308 308 break; 309 309 } 310 310 311 - for (i = 0; i < (sizeof(ms02nv_addrs) / sizeof(*ms02nv_addrs)); i++) 311 + for (i = 0; i < ARRAY_SIZE(ms02nv_addrs); i++) 312 312 if (!ms02nv_init_one(ms02nv_addrs[i] << stride)) 313 313 count++; 314 314
+1 -3
drivers/mtd/maps/alchemy-flash.c
··· 126 126 } 127 127 }; 128 128 129 - #define NB_OF(x) (sizeof(x)/sizeof(x[0])) 130 - 131 129 static struct mtd_info *mymtd; 132 130 133 131 int __init alchemy_mtd_init(void) ··· 152 154 * Static partition definition selection 153 155 */ 154 156 parts = alchemy_partitions; 155 - nb_parts = NB_OF(alchemy_partitions); 157 + nb_parts = ARRAY_SIZE(alchemy_partitions); 156 158 alchemy_map.size = window_size; 157 159 158 160 /*
+1 -1
drivers/mtd/maps/cfi_flagadm.c
··· 86 86 } 87 87 }; 88 88 89 - #define PARTITION_COUNT (sizeof(flagadm_parts)/sizeof(struct mtd_partition)) 89 + #define PARTITION_COUNT ARRAY_SIZE(flagadm_parts) 90 90 91 91 static struct mtd_info *mymtd; 92 92
+1 -1
drivers/mtd/maps/dbox2-flash.c
··· 57 57 } 58 58 }; 59 59 60 - #define NUM_PARTITIONS (sizeof(partition_info) / sizeof(partition_info[0])) 60 + #define NUM_PARTITIONS ARRAY_SIZE(partition_info) 61 61 62 62 #define WINDOW_ADDR 0x10000000 63 63 #define WINDOW_SIZE 0x800000
+2 -2
drivers/mtd/maps/dilnetpc.c
··· 300 300 }, 301 301 }; 302 302 303 - #define NUM_PARTITIONS (sizeof(partition_info)/sizeof(partition_info[0])) 303 + #define NUM_PARTITIONS ARRAY_SIZE(partition_info) 304 304 305 305 static struct mtd_info *mymtd; 306 306 static struct mtd_info *lowlvl_parts[NUM_PARTITIONS]; ··· 345 345 }, 346 346 }; 347 347 348 - #define NUM_HIGHLVL_PARTITIONS (sizeof(higlvl_partition_info)/sizeof(partition_info[0])) 348 + #define NUM_HIGHLVL_PARTITIONS ARRAY_SIZE(higlvl_partition_info) 349 349 350 350 351 351 static int dnp_adnp_probe(void)
+1 -1
drivers/mtd/maps/dmv182.c
··· 99 99 static int __init init_svme182(void) 100 100 { 101 101 struct mtd_partition *partitions; 102 - int num_parts = sizeof(svme182_partitions) / sizeof(struct mtd_partition); 102 + int num_parts = ARRAY_SIZE(svme182_partitions); 103 103 104 104 partitions = svme182_partitions; 105 105
+1 -1
drivers/mtd/maps/h720x-flash.c
··· 59 59 } 60 60 }; 61 61 62 - #define NUM_PARTITIONS (sizeof(h720x_partitions)/sizeof(h720x_partitions[0])) 62 + #define NUM_PARTITIONS ARRAY_SIZE(h720x_partitions) 63 63 64 64 static int nr_mtd_parts; 65 65 static struct mtd_partition *mtd_parts;
+2 -2
drivers/mtd/maps/netsc520.c
··· 76 76 .size = 0x80000 77 77 }, 78 78 }; 79 - #define NUM_PARTITIONS (sizeof(partition_info)/sizeof(partition_info[0])) 79 + #define NUM_PARTITIONS ARRAY_SIZE(partition_info) 80 80 81 81 #define WINDOW_SIZE 0x00100000 82 82 #define WINDOW_ADDR 0x00200000 ··· 88 88 .phys = WINDOW_ADDR, 89 89 }; 90 90 91 - #define NUM_FLASH_BANKS (sizeof(netsc520_map)/sizeof(struct map_info)) 91 + #define NUM_FLASH_BANKS ARRAY_SIZE(netsc520_map) 92 92 93 93 static struct mtd_info *mymtd; 94 94
+1 -2
drivers/mtd/maps/nettel.c
··· 128 128 } 129 129 }; 130 130 131 - #define NUM_AMD_PARTITIONS \ 132 - (sizeof(nettel_amd_partitions)/sizeof(nettel_amd_partitions[0])) 131 + #define NUM_AMD_PARTITIONS ARRAY_SIZE(nettel_amd_partitions) 133 132 134 133 /****************************************************************************/ 135 134
+2 -4
drivers/mtd/maps/ocotea.c
··· 58 58 } 59 59 }; 60 60 61 - #define NB_OF(x) (sizeof(x)/sizeof(x[0])) 62 - 63 61 int __init init_ocotea(void) 64 62 { 65 63 u8 fpga0_reg; ··· 95 97 if (flash) { 96 98 flash->owner = THIS_MODULE; 97 99 add_mtd_partitions(flash, ocotea_small_partitions, 98 - NB_OF(ocotea_small_partitions)); 100 + ARRAY_SIZE(ocotea_small_partitions)); 99 101 } else { 100 102 printk("map probe failed for flash\n"); 101 103 return -ENXIO; ··· 116 118 if (flash) { 117 119 flash->owner = THIS_MODULE; 118 120 add_mtd_partitions(flash, ocotea_large_partitions, 119 - NB_OF(ocotea_large_partitions)); 121 + ARRAY_SIZE(ocotea_large_partitions)); 120 122 } else { 121 123 printk("map probe failed for flash\n"); 122 124 return -ENXIO;
+1 -1
drivers/mtd/maps/pcmciamtd.c
··· 616 616 } else if(mem_type == 2) { 617 617 mtd = do_map_probe("map_rom", &dev->pcmcia_map); 618 618 } else { 619 - for(i = 0; i < sizeof(probes) / sizeof(char *); i++) { 619 + for(i = 0; i < ARRAY_SIZE(probes); i++) { 620 620 DEBUG(1, "Trying %s", probes[i]); 621 621 mtd = do_map_probe(probes[i], &dev->pcmcia_map); 622 622 if(mtd)
+1 -2
drivers/mtd/maps/redwood.c
··· 121 121 }; 122 122 123 123 124 - #define NUM_REDWOOD_FLASH_PARTITIONS \ 125 - (sizeof(redwood_flash_partitions)/sizeof(redwood_flash_partitions[0])) 124 + #define NUM_REDWOOD_FLASH_PARTITIONS ARRAY_SIZE(redwood_flash_partitions) 126 125 127 126 static struct mtd_info *redwood_mtd; 128 127
+3 -5
drivers/mtd/maps/sbc8240.c
··· 66 66 } 67 67 }; 68 68 69 - #define NUM_FLASH_BANKS (sizeof(sbc8240_map) / sizeof(struct map_info)) 69 + #define NUM_FLASH_BANKS ARRAY_SIZE(sbc8240_map) 70 70 71 71 /* 72 72 * The following defines the partition layout of SBC8240 boards. ··· 124 124 .size = 0x00010000, /* 4 * 16KiB */ 125 125 } 126 126 }; 127 - 128 - #define NB_OF(x) (sizeof (x) / sizeof (x[0])) 129 127 130 128 /* trivial struct to describe partition information */ 131 129 struct mtd_part_def ··· 188 190 #ifdef CONFIG_MTD_PARTITIONS 189 191 sbc8240_part_banks[0].mtd_part = sbc8240_uboot_partitions; 190 192 sbc8240_part_banks[0].type = "static image"; 191 - sbc8240_part_banks[0].nums = NB_OF(sbc8240_uboot_partitions); 193 + sbc8240_part_banks[0].nums = ARRAY_SIZE(sbc8240_uboot_partitions); 192 194 sbc8240_part_banks[1].mtd_part = sbc8240_fs_partitions; 193 195 sbc8240_part_banks[1].type = "static file system"; 194 - sbc8240_part_banks[1].nums = NB_OF(sbc8240_fs_partitions); 196 + sbc8240_part_banks[1].nums = ARRAY_SIZE(sbc8240_fs_partitions); 195 197 196 198 for (i = 0; i < NUM_FLASH_BANKS; i++) { 197 199
+1 -1
drivers/mtd/maps/sc520cdp.c
··· 107 107 }, 108 108 }; 109 109 110 - #define NUM_FLASH_BANKS (sizeof(sc520cdp_map)/sizeof(struct map_info)) 110 + #define NUM_FLASH_BANKS ARRAY_SIZE(sc520cdp_map) 111 111 112 112 static struct mtd_info *mymtd[NUM_FLASH_BANKS]; 113 113 static struct mtd_info *merged_mtd;
+1 -1
drivers/mtd/maps/scx200_docflash.c
··· 70 70 .size = 0x80000 71 71 }, 72 72 }; 73 - #define NUM_PARTITIONS (sizeof(partition_info)/sizeof(partition_info[0])) 73 + #define NUM_PARTITIONS ARRAY_SIZE(partition_info) 74 74 #endif 75 75 76 76
+1 -3
drivers/mtd/maps/sharpsl-flash.c
··· 49 49 } 50 50 }; 51 51 52 - #define NB_OF(x) (sizeof(x)/sizeof(x[0])) 53 - 54 52 int __init init_sharpsl(void) 55 53 { 56 54 struct mtd_partition *parts; ··· 90 92 } 91 93 92 94 parts = sharpsl_partitions; 93 - nb_parts = NB_OF(sharpsl_partitions); 95 + nb_parts = ARRAY_SIZE(sharpsl_partitions); 94 96 95 97 printk(KERN_NOTICE "Using %s partision definition\n", part_type); 96 98 add_mtd_partitions(mymtd, parts, nb_parts);
+1 -1
drivers/mtd/maps/ts5500_flash.c
··· 64 64 } 65 65 }; 66 66 67 - #define NUM_PARTITIONS (sizeof(ts5500_partitions)/sizeof(struct mtd_partition)) 67 + #define NUM_PARTITIONS ARRAY_SIZE(ts5500_partitions) 68 68 69 69 static struct mtd_info *mymtd; 70 70
+1 -1
drivers/mtd/maps/uclinux.c
··· 37 37 { .name = "ROMfs" } 38 38 }; 39 39 40 - #define NUM_PARTITIONS (sizeof(uclinux_romfs) / sizeof(uclinux_romfs[0])) 40 + #define NUM_PARTITIONS ARRAY_SIZE(uclinux_romfs) 41 41 42 42 /****************************************************************************/ 43 43
+1 -3
drivers/mtd/nand/au1550nd.c
··· 55 55 .size = MTDPART_SIZ_FULL 56 56 } 57 57 }; 58 - #define NB_OF(x) (sizeof(x)/sizeof(x[0])) 59 - 60 58 61 59 /** 62 60 * au_read_byte - read one byte from the chip ··· 460 462 } 461 463 462 464 /* Register the partitions */ 463 - add_mtd_partitions(au1550_mtd, partition_info, NB_OF(partition_info)); 465 + add_mtd_partitions(au1550_mtd, partition_info, ARRAY_SIZE(partition_info)); 464 466 465 467 return 0; 466 468