]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
net: Use ARRAY_SIZE at appropriate places
authorAxel Lin <axel.lin@ingics.com>
Wed, 3 Jul 2013 03:24:18 +0000 (11:24 +0800)
committerJoe Hershberger <joe.hershberger@ni.com>
Mon, 19 Aug 2013 17:34:18 +0000 (12:34 -0500)
Use ARRAY_SIZE instead of having similar implementation in each drivers.
The NUMELEMS defined in drivers/net/npe/include/IxOsalTypes.h is not used
at all, so this patch removes it instead of converting it to use ARRAY_SIZE.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Ben Warren <biggerbadderben@gmail.com>
Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Cc: TsiChungLiew <Tsi-Chung.Liew@freescale.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: York Sun <yorksun@freescale.com>
drivers/net/ax88180.c
drivers/net/fsl_mcdmafec.c
drivers/net/lan91c96.c
drivers/net/mcffec.c
drivers/net/mcfmii.c
drivers/net/ne2000.c
drivers/net/npe/IxEthDBFeatures.c
drivers/net/npe/IxOsalIoMem.c
drivers/net/npe/include/IxEthDBPortDefs.h
drivers/net/npe/include/IxOsalTypes.h

index f5017682d496c0f4cf004ca9893ad509515c4f2e..7f0cfe594024f07c1ad7e898da39aba7eeee3dbf 100644 (file)
@@ -157,7 +157,7 @@ static void ax88180_mac_reset (struct eth_device *dev)
        OUTW (dev, MISC_RESET_MAC, MISC);
        tmpval = INW (dev, MISC);
 
-       for (i = 0; i < (sizeof (program_seq) / sizeof (program_seq[0])); i++)
+       for (i = 0; i < ARRAY_SIZE(program_seq); i++)
                OUTW (dev, program_seq[i].value, program_seq[i].offset);
 }
 
index 1ad952d3a9a89ffb3e0a1a03337ac055099d711d..6391f9b32fb297de6ddc43cf7eb8fa041cf219db 100644 (file)
@@ -504,7 +504,7 @@ int mcdmafec_initialize(bd_t * bis)
        u32 tmp = CONFIG_SYS_INTSRAM + 0x2000;
 #endif
 
-       for (i = 0; i < sizeof(fec_info) / sizeof(fec_info[0]); i++) {
+       for (i = 0; i < ARRAY_SIZE(fec_info); i++) {
 
                dev =
                    (struct eth_device *)memalign(CONFIG_SYS_CACHELINE_SIZE,
index 2bf00685337fb7e1df4c1729e2049e5133703b83..229658abc8eaedd5ca3d502b8677e942f960928c 100644 (file)
@@ -766,7 +766,7 @@ static int lan91c96_detect_chip(struct eth_device *dev)
        SMC_SELECT_BANK(dev, 3);
        chip_id = (SMC_inw(dev, 0xA) & LAN91C96_REV_CHIPID) >> 4;
        SMC_SELECT_BANK(dev, 0);
-       for (r = 0; r < sizeof(supported_chips) / sizeof(struct id_type); r++)
+       for (r = 0; r < ARRAY_SIZE(supported_chips); r++)
                if (chip_id == supported_chips[r].id)
                        return r;
        return 0;
index 6b537d505ecb2bd8e293de1c2bc915dd919038a5..7c4b210b00111070b4b037cb944a4e1481969bd1 100644 (file)
@@ -543,7 +543,7 @@ int mcffec_initialize(bd_t * bis)
        u32 tmp = CONFIG_SYS_INIT_RAM_ADDR + 0x1000;
 #endif
 
-       for (i = 0; i < sizeof(fec_info) / sizeof(fec_info[0]); i++) {
+       for (i = 0; i < ARRAY_SIZE(fec_info); i++) {
 
                dev =
                    (struct eth_device *)memalign(CONFIG_SYS_CACHELINE_SIZE,
index 2f2269d5311e459d8734ef088590a4cf4d1f8d8f..17a780c854d8fbb8f6f393bd50083d37a92fa7d9 100644 (file)
@@ -170,7 +170,7 @@ int mii_discover_phy(struct eth_device *dev)
                        printf("PHY @ 0x%x pass %d\n", phyno, pass);
 #endif
 
-                       for (i = 0; (i < (sizeof(phyinfo) / sizeof(phy_info_t)))
+                       for (i = 0; (i < ARRAY_SIZE(phyinfo))
                                && (phyinfo[i].phyid != 0); i++) {
                                if (phyinfo[i].phyid == phytype) {
 #ifdef ET_DEBUG
index 39391580feda2e7c86b504f62787d28c8fa2a9cd..e6cd3e9ba07e23fb6f3e1893afd0cc9f828e1648 100644 (file)
@@ -228,7 +228,7 @@ int get_prom(u8* mac_addr, u8* base_addr)
 
        mdelay (10);
 
-       for (i = 0; i < sizeof (program_seq) / sizeof (program_seq[0]); i++)
+       for (i = 0; i < ARRAY_SIZE(program_seq); i++)
                n2k_outb (program_seq[i].value, program_seq[i].offset);
 
        PRINTK ("PROM:");
index c5b680a74278ac2e3bf1c24452ac8428431be067..ecabec5b1b2bb1bd181b583c9af7aec863946d4d 100644 (file)
@@ -144,7 +144,7 @@ void ixEthDBFeatureCapabilityScan(void)
 
                 /* find the traffic class definition index compatible with the current NPE A functionality ID */
                 for (trafficClassDefinitionIndex = 0 ;
-                    trafficClassDefinitionIndex < sizeof (ixEthDBTrafficClassDefinitions) / sizeof (ixEthDBTrafficClassDefinitions[0]);
+                    trafficClassDefinitionIndex < ARRAY_SIZE(ixEthDBTrafficClassDefinitions);
                     trafficClassDefinitionIndex++)
                 {
                     if (ixEthDBTrafficClassDefinitions[trafficClassDefinitionIndex][IX_ETH_DB_NPE_A_FUNCTIONALITY_ID_INDEX] == npeAImageId.functionalityId)
@@ -155,7 +155,7 @@ void ixEthDBFeatureCapabilityScan(void)
                 }
 
                 /* select the default case if we went over the array boundary */
-                if (trafficClassDefinitionIndex == sizeof (ixEthDBTrafficClassDefinitions) / sizeof (ixEthDBTrafficClassDefinitions[0]))
+                if (trafficClassDefinitionIndex == ARRAY_SIZE(ixEthDBTrafficClassDefinitions))
                 {
                     trafficClassDefinitionIndex = 0; /* the first record is the default case */
                 }
index 34df92bf79f63c6a5bab9156f321851e54d5e306..087fdf3ba1f19b6a31e829c01b65ad4c12f4e2b7 100644 (file)
@@ -66,8 +66,7 @@ ixOsalMemMapFind (UINT32 requestedAddress,
 {
     UINT32 mapIndex;
 
-    UINT32 numMapElements =
-        sizeof (ixOsalGlobalMemoryMap) / sizeof (IxOsalMemoryMap);
+    UINT32 numMapElements = ARRAY_SIZE(ixOsalGlobalMemoryMap);
 
     for (mapIndex = 0; mapIndex < numMapElements; mapIndex++)
     {
index c3acbdddef735f57b26460d0050075b82e0e2d12..eac48cbb38d3bf732521b1bc028a7b143925af20 100644 (file)
@@ -106,7 +106,7 @@ static const IxEthDBPortDefinition ixEthDBPortDefinitions[] =
  * @def IX_ETH_DB_NUMBER_OF_PORTS
  * @brief number of supported ports 
  */
-#define IX_ETH_DB_NUMBER_OF_PORTS (sizeof (ixEthDBPortDefinitions) / sizeof (ixEthDBPortDefinitions[0]))
+#define IX_ETH_DB_NUMBER_OF_PORTS ARRAY_SIZE(ixEthDBPortDefinitions)
 
 /**
  * @def IX_ETH_DB_UNKNOWN_PORT
index 06e71debfb2507987173b598eb006e073c3aaee2..00a49ada05b5d38176d491b14f0945001d5726ea 100644 (file)
@@ -91,12 +91,6 @@ typedef volatile UINT32 VUINT32;
  */
 typedef volatile INT32 VINT32;
 
-
-#ifndef NUMELEMS
-#define NUMELEMS(x) (sizeof(x) / sizeof((x)[0]))
-#endif
-
-
 /**
  * @ingroup IxOsalTypes
  *