]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
arch/powerpc: Simplify some calculations using ARRAY_SIZE() macro.
authorRobert P. J. Day <rpjday@crashcourse.ca>
Mon, 23 May 2016 10:49:21 +0000 (06:49 -0400)
committerYork Sun <york.sun@nxp.com>
Sat, 4 Jun 2016 05:13:12 +0000 (22:13 -0700)
Replace a number of array length calculations with the ARRAY_SIZE()
macro, for clarity.

Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
Reviewed-by: York Sun <york.sun@nxp.com>
arch/powerpc/cpu/mpc512x/fixed_sdram.c
arch/powerpc/cpu/mpc8260/cpu_init.c
arch/powerpc/cpu/mpc8260/ether_fcc.c
arch/powerpc/cpu/mpc83xx/cpu_init.c
arch/powerpc/cpu/mpc83xx/speed.c
arch/powerpc/cpu/mpc85xx/ether_fcc.c
arch/powerpc/cpu/mpc8xx/fec.c
arch/powerpc/cpu/ppc4xx/reginfo.c
arch/powerpc/cpu/ppc4xx/sdram.c

index 6451ea9a4aa5abef6712cc1359ca2db9a052e33f..68c5f8a27b31097cef00a8c52dee40cd6063a2fb 100644 (file)
@@ -70,7 +70,7 @@ long int fixed_sdram(ddr512x_config_t *mddrc_config,
                mddrc_config = &default_mddrc_config;
        if (dram_init_seq == NULL) {
                dram_init_seq = default_init_seq;
-               seq_sz = sizeof(default_init_seq)/sizeof(u32);
+               seq_sz = ARRAY_SIZE(default_init_seq);
        }
 
        /* Initialize IO Control */
index a9bb5adeb2095493613da12c449218167279df65..55130f7831ef7ff7a4b5a2aa35c40fbce6918b90 100644 (file)
@@ -253,7 +253,7 @@ int prt_8260_rsr (void)
                RSR_ESRS, "External Soft"}, {
                RSR_EHRS, "External Hard"}
        };
-       static int n = sizeof bits / sizeof bits[0];
+       static int n = ARRAY_SIZE(bits);
        ulong rsr = gd->arch.reset_status;
        int i;
        char *sep;
index 9bb395e6a2621d317439fe5be68ebb4247874af2..a11ad1e9d06be650266fc48ee1d1402c853f15e8 100644 (file)
@@ -362,7 +362,7 @@ int fec_initialize(bd_t *bis)
        struct eth_device* dev;
        int i;
 
-       for (i = 0; i < sizeof(ether_fcc_info) / sizeof(ether_fcc_info[0]); i++)
+       for (i = 0; i < ARRAY_SIZE(ether_fcc_info); i++)
        {
                dev = (struct eth_device*) malloc(sizeof *dev);
                memset(dev, 0, sizeof *dev);
@@ -432,7 +432,7 @@ static elbt_prdesc rxeacc_descs[] = {
        { offsetof(elbt_rxeacc, badlen),        "Bad Frame Length"      },
        { offsetof(elbt_rxeacc, badbit),        "Data Compare Errors"   },
 };
-static int rxeacc_ndesc = sizeof (rxeacc_descs) / sizeof (rxeacc_descs[0]);
+static int rxeacc_ndesc = ARRAY_SIZE(rxeacc_descs);
 
 typedef
        struct {
@@ -449,7 +449,7 @@ static elbt_prdesc txeacc_descs[] = {
        { offsetof(elbt_txeacc, un),            "Underrun"              },
        { offsetof(elbt_txeacc, csl),           "Carrier Sense Lost"    },
 };
-static int txeacc_ndesc = sizeof (txeacc_descs) / sizeof (txeacc_descs[0]);
+static int txeacc_ndesc = ARRAY_SIZE(txeacc_descs);
 
 typedef
        struct {
@@ -500,7 +500,7 @@ static elbt_prdesc epram_descs[] = {
        { offsetof(fcc_enet_t, fen_p512c),      "512-1023 Octet Frames" },
        { offsetof(fcc_enet_t, fen_p1024c),     "1024-1518 Octet Frames"},
 };
-static int epram_ndesc = sizeof (epram_descs) / sizeof (epram_descs[0]);
+static int epram_ndesc = ARRAY_SIZE(epram_descs);
 
 /*
  * given an elbt_prdesc array and an array of base addresses, print
index 0791043ee174e5ec4a38dda05ef2edb4bf3d171a..f911275b25f92e7c698dfc4c9238d816065a480a 100644 (file)
@@ -484,7 +484,7 @@ int prt_83xx_rsr(void)
                RSR_SRS,  "External/Internal Soft"}, {
                RSR_HRS,  "External/Internal Hard"}
        };
-       static int n = sizeof bits / sizeof bits[0];
+       static int n = ARRAY_SIZE(bits);
        ulong rsr = gd->arch.reset_status;
        int i;
        char *sep;
index 2e91f51fcee9e7ce9e77dffbdaedf7cb7513543d..5498c19e253d84e3a53b67a6f6fc7d2ec0af6206 100644 (file)
@@ -412,7 +412,7 @@ int get_clocks(void)
 #endif
 
        corecnf_tab_index = ((corepll & 0x1F) << 2) | ((corepll & 0x60) >> 5);
-       if (corecnf_tab_index > (sizeof(corecnf_tab) / sizeof(corecnf_t))) {
+       if (corecnf_tab_index > (ARRAY_SIZE(corecnf_tab))) {
                /* corecnf_tab_index is too high, possibly wrong value */
                return -11;
        }
index 14358aeb03d8f3f6f7751aa6f4d57bc0e7650dd0..51f1beef5196a21f70067b1c3ae8a06c844ed9f6 100644 (file)
@@ -424,7 +424,7 @@ int fec_initialize(bd_t *bis)
        struct eth_device* dev;
        int i;
 
-       for (i = 0; i < sizeof(ether_fcc_info) / sizeof(ether_fcc_info[0]); i++)
+       for (i = 0; i < ARRAY_SIZE(ether_fcc_info); i++)
        {
                dev = (struct eth_device*) malloc(sizeof *dev);
                memset(dev, 0, sizeof *dev);
index ea4ab3a04237837b4cb76480be9f79782e8d0e9c..f1ae3584660b33c39fa9802d53537b577ecbafef 100644 (file)
@@ -137,7 +137,7 @@ int fec_initialize(bd_t *bis)
        struct ether_fcc_info_s *efis;
        int             i;
 
-       for (i = 0; i < sizeof(ether_fcc_info) / sizeof(ether_fcc_info[0]); i++) {
+       for (i = 0; i < ARRAY_SIZE(ether_fcc_info); i++) {
 
                dev = malloc(sizeof(*dev));
                if (dev == NULL)
@@ -879,7 +879,7 @@ void mii_init (void)
 
        /* Setup the pin configuration of the FEC(s)
        */
-       for (i = 0; i < sizeof(ether_fcc_info) / sizeof(ether_fcc_info[0]); i++)
+       for (i = 0; i < ARRAY_SIZE(ether_fcc_info); i++)
                fec_pin_init(ether_fcc_info[i].ether_index);
 }
 
index 339d38aa998f522a1c059479e456809364de0931..a42327eb3dab7045e1ecc89105a33f2d21bc2aff 100644 (file)
@@ -321,7 +321,7 @@ void ppc4xx_reginfo(void)
        PRINT_DCR(OPB2PLB40_BCTRL);
        PRINT_DCR(P4P3BO0_CFG);
 #endif
-       n = sizeof(ppc4xx_reg) / sizeof(ppc4xx_reg[0]);
+       n = ARRAY_SIZE(ppc4xx_reg);
        for (i = 0; i < n; i++) {
                value = 0;
                type = ppc4xx_reg[i].type;
index d4ef36d39ffc6f335e34ff7a2ec5c9089326579d..cd63456e700a32e5b532115f719638fba6954089 100644 (file)
@@ -33,7 +33,7 @@ sdram_conf_t mb0cf[] = {
 sdram_conf_t mb0cf[] = CONFIG_SYS_SDRAM_TABLE;
 #endif
 
-#define N_MB0CF (sizeof(mb0cf) / sizeof(mb0cf[0]))
+#define N_MB0CF (ARRAY_SIZE(mb0cf))
 
 #ifdef CONFIG_SYS_SDRAM_CASL
 static ulong ns2clks(ulong ns)
@@ -266,7 +266,7 @@ sdram_conf_t mb0cf[] = CONFIG_SYS_SDRAM_TABLE;
 #define CONFIG_SYS_SDRAM0_CFG0         0x82000000 /* DCEN=1, PMUD=0, 64-bit */
 #endif
 
-#define N_MB0CF (sizeof(mb0cf) / sizeof(mb0cf[0]))
+#define N_MB0CF (ARRAY_SIZE(mb0cf))
 
 #define NUM_TRIES 64
 #define NUM_READS 10