Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 87d10f3c authored by Tobias Klauser's avatar Tobias Klauser Committed by Linus Torvalds
Browse files

[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: default avatarTobias Klauser <tklauser@nuerscht.ch>
Cc: Thomas Gleixner <tglx@linutronix.de>
Acked-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 54af6b46
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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) *
+1 −1
Original line number Diff line number Diff line
@@ -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",
+4 −6
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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++;

+1 −3
Original line number Diff line number Diff line
@@ -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;

	/*
Loading