Commit d2397817f12d246cfd88caefd6f12dfd3e2d2c17
Committed by
Wolfgang Denk
1 parent
9146d13821
Exists in
master
and in
54 other branches
post: use ARRAY_SIZE
We've got a handy dandy macro already for calculating the number of elements in an array, so use it. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Showing 25 changed files with 28 additions and 52 deletions Side-by-side Diff
- post/board/lwmon/sysmon.c
- post/cpu/mpc8xx/ether.c
- post/cpu/mpc8xx/spr.c
- post/cpu/mpc8xx/uart.c
- post/cpu/ppc4xx/spr.c
- post/drivers/memory.c
- post/lib_powerpc/andi.c
- post/lib_powerpc/cmp.c
- post/lib_powerpc/cmpi.c
- post/lib_powerpc/cr.c
- post/lib_powerpc/fpu/mul-subnormal-single-1.c
- post/lib_powerpc/load.c
- post/lib_powerpc/multi.c
- post/lib_powerpc/rlwimi.c
- post/lib_powerpc/rlwinm.c
- post/lib_powerpc/rlwnm.c
- post/lib_powerpc/srawi.c
- post/lib_powerpc/store.c
- post/lib_powerpc/three.c
- post/lib_powerpc/threei.c
- post/lib_powerpc/threex.c
- post/lib_powerpc/two.c
- post/lib_powerpc/twox.c
- post/post.c
- post/tests.c
post/board/lwmon/sysmon.c
... | ... | @@ -133,7 +133,7 @@ |
133 | 133 | {"+ 5 V standby", "V", &sysmon_pic, NULL, NULL, |
134 | 134 | 100, 1000, 0, 6040, 0xFF, 0xC8, 0xDE, 0, 0xC8, 0xDE, 0, 0x7C}, |
135 | 135 | }; |
136 | -static int sysmon_table_size = sizeof(sysmon_table) / sizeof(sysmon_table[0]); | |
136 | +static int sysmon_table_size = ARRAY_SIZE(sysmon_table); | |
137 | 137 | |
138 | 138 | static int conversion_done = 0; |
139 | 139 |
post/cpu/mpc8xx/ether.c
... | ... | @@ -67,8 +67,6 @@ |
67 | 67 | static int ctlr_list[][2] = { }; |
68 | 68 | #endif |
69 | 69 | |
70 | -#define CTRL_LIST_SIZE (sizeof(ctlr_list) / sizeof(ctlr_list[0])) | |
71 | - | |
72 | 70 | static struct { |
73 | 71 | void (*init) (int index); |
74 | 72 | void (*halt) (int index); |
... | ... | @@ -618,7 +616,7 @@ |
618 | 616 | ctlr_proc[CTLR_SCC].send = scc_send; |
619 | 617 | ctlr_proc[CTLR_SCC].recv = scc_recv; |
620 | 618 | |
621 | - for (i = 0; i < CTRL_LIST_SIZE; i++) { | |
619 | + for (i = 0; i < ARRAY_SIZE(ctlr_list); i++) { | |
622 | 620 | if (test_ctlr (ctlr_list[i][0], ctlr_list[i][1]) != 0) { |
623 | 621 | res = -1; |
624 | 622 | } |
post/cpu/mpc8xx/spr.c
... | ... | @@ -108,8 +108,7 @@ |
108 | 108 | {826, "MD_DBRAM1", 0x00000000, 0x00000000}, |
109 | 109 | }; |
110 | 110 | |
111 | -static int spr_test_list_size = | |
112 | - sizeof (spr_test_list) / sizeof (spr_test_list[0]); | |
111 | +static int spr_test_list_size = ARRAY_SIZE(spr_test_list); | |
113 | 112 | |
114 | 113 | int spr_post_test (int flags) |
115 | 114 | { |
post/cpu/mpc8xx/uart.c
... | ... | @@ -61,8 +61,6 @@ |
61 | 61 | static int ctlr_list[][2] = { }; |
62 | 62 | #endif |
63 | 63 | |
64 | -#define CTRL_LIST_SIZE (sizeof(ctlr_list) / sizeof(ctlr_list[0])) | |
65 | - | |
66 | 64 | static struct { |
67 | 65 | void (*init) (int index); |
68 | 66 | void (*halt) (int index); |
... | ... | @@ -540,7 +538,7 @@ |
540 | 538 | ctlr_proc[CTLR_SCC].putc = scc_putc; |
541 | 539 | ctlr_proc[CTLR_SCC].getc = scc_getc; |
542 | 540 | |
543 | - for (i = 0; i < CTRL_LIST_SIZE; i++) { | |
541 | + for (i = 0; i < ARRAY_SIZE(ctlr_list); i++) { | |
544 | 542 | if (test_ctlr (ctlr_list[i][0], ctlr_list[i][1]) != 0) { |
545 | 543 | res = -1; |
546 | 544 | } |
post/cpu/ppc4xx/spr.c
... | ... | @@ -156,8 +156,7 @@ |
156 | 156 | {0x3f3, "DBDR", 0x00000000, 0x00000000}, |
157 | 157 | }; |
158 | 158 | |
159 | -static int spr_test_list_size = | |
160 | - sizeof (spr_test_list) / sizeof (spr_test_list[0]); | |
159 | +static int spr_test_list_size = ARRAY_SIZE(spr_test_list); | |
161 | 160 | |
162 | 161 | int spr_post_test (int flags) |
163 | 162 | { |
post/drivers/memory.c
... | ... | @@ -225,7 +225,7 @@ |
225 | 225 | static int memory_post_dataline(unsigned long long * pmem) |
226 | 226 | { |
227 | 227 | unsigned long long temp64 = 0; |
228 | - int num_patterns = sizeof(pattern)/ sizeof(pattern[0]); | |
228 | + int num_patterns = ARRAY_SIZE(pattern); | |
229 | 229 | int i; |
230 | 230 | unsigned int hi, lo, pathi, patlo; |
231 | 231 | int ret = 0; |
post/lib_powerpc/andi.c
... | ... | @@ -61,8 +61,7 @@ |
61 | 61 | 0x80000000 |
62 | 62 | }, |
63 | 63 | }; |
64 | -static unsigned int cpu_post_andi_size = | |
65 | - sizeof (cpu_post_andi_table) / sizeof (struct cpu_post_andi_s); | |
64 | +static unsigned int cpu_post_andi_size = ARRAY_SIZE(cpu_post_andi_table); | |
66 | 65 | |
67 | 66 | int cpu_post_test_andi (void) |
68 | 67 | { |
post/lib_powerpc/cmp.c
post/lib_powerpc/cmpi.c
... | ... | @@ -95,8 +95,7 @@ |
95 | 95 | 0x04 |
96 | 96 | }, |
97 | 97 | }; |
98 | -static unsigned int cpu_post_cmpi_size = | |
99 | - sizeof (cpu_post_cmpi_table) / sizeof (struct cpu_post_cmpi_s); | |
98 | +static unsigned int cpu_post_cmpi_size = ARRAY_SIZE(cpu_post_cmpi_table); | |
100 | 99 | |
101 | 100 | int cpu_post_test_cmpi (void) |
102 | 101 | { |
post/lib_powerpc/cr.c
... | ... | @@ -59,8 +59,7 @@ |
59 | 59 | 0xaaaaaaaa, |
60 | 60 | 0x55555555, |
61 | 61 | }; |
62 | -static unsigned int cpu_post_cr_size1 = | |
63 | - sizeof (cpu_post_cr_table1) / sizeof (ulong); | |
62 | +static unsigned int cpu_post_cr_size1 = ARRAY_SIZE(cpu_post_cr_table1); | |
64 | 63 | |
65 | 64 | static struct cpu_post_cr_s2 { |
66 | 65 | ulong xer; |
... | ... | @@ -76,8 +75,7 @@ |
76 | 75 | 5 |
77 | 76 | }, |
78 | 77 | }; |
79 | -static unsigned int cpu_post_cr_size2 = | |
80 | - sizeof (cpu_post_cr_table2) / sizeof (struct cpu_post_cr_s2); | |
78 | +static unsigned int cpu_post_cr_size2 = ARRAY_SIZE(cpu_post_cr_table2); | |
81 | 79 | |
82 | 80 | static struct cpu_post_cr_s3 { |
83 | 81 | ulong cr; |
... | ... | @@ -99,8 +97,7 @@ |
99 | 97 | 0x71234567 |
100 | 98 | }, |
101 | 99 | }; |
102 | -static unsigned int cpu_post_cr_size3 = | |
103 | - sizeof (cpu_post_cr_table3) / sizeof (struct cpu_post_cr_s3); | |
100 | +static unsigned int cpu_post_cr_size3 = ARRAY_SIZE(cpu_post_cr_table3); | |
104 | 101 | |
105 | 102 | static struct cpu_post_cr_s4 { |
106 | 103 | ulong cmd; |
... | ... | @@ -240,8 +237,7 @@ |
240 | 237 | 0x0000ffff |
241 | 238 | }, |
242 | 239 | }; |
243 | -static unsigned int cpu_post_cr_size4 = | |
244 | - sizeof (cpu_post_cr_table4) / sizeof (struct cpu_post_cr_s4); | |
240 | +static unsigned int cpu_post_cr_size4 = ARRAY_SIZE(cpu_post_cr_table4); | |
245 | 241 | |
246 | 242 | int cpu_post_test_cr (void) |
247 | 243 | { |
post/lib_powerpc/fpu/mul-subnormal-single-1.c
... | ... | @@ -86,7 +86,7 @@ |
86 | 86 | { |
87 | 87 | unsigned int i; |
88 | 88 | |
89 | - for (i = 0; i < sizeof (expected) / sizeof (expected[0]); i++) | |
89 | + for (i = 0; i < ARRAY_SIZE(expected); i++) | |
90 | 90 | { |
91 | 91 | tstmul (expected[i].p1, expected[i].p2, expected[i].res); |
92 | 92 | tstmul (expected[i].p2, expected[i].p1, expected[i].res); |
post/lib_powerpc/load.c
... | ... | @@ -171,8 +171,7 @@ |
171 | 171 | 1 |
172 | 172 | }, |
173 | 173 | }; |
174 | -static unsigned int cpu_post_load_size = | |
175 | - sizeof (cpu_post_load_table) / sizeof (struct cpu_post_load_s); | |
174 | +static unsigned int cpu_post_load_size = ARRAY_SIZE(cpu_post_load_table); | |
176 | 175 | |
177 | 176 | int cpu_post_test_load (void) |
178 | 177 | { |
post/lib_powerpc/multi.c
post/lib_powerpc/rlwimi.c
... | ... | @@ -62,8 +62,7 @@ |
62 | 62 | 0xffaaffff |
63 | 63 | }, |
64 | 64 | }; |
65 | -static unsigned int cpu_post_rlwimi_size = | |
66 | - sizeof (cpu_post_rlwimi_table) / sizeof (struct cpu_post_rlwimi_s); | |
65 | +static unsigned int cpu_post_rlwimi_size = ARRAY_SIZE(cpu_post_rlwimi_table); | |
67 | 66 | |
68 | 67 | int cpu_post_test_rlwimi (void) |
69 | 68 | { |
post/lib_powerpc/rlwinm.c
... | ... | @@ -59,8 +59,7 @@ |
59 | 59 | 0x0000ff00 |
60 | 60 | }, |
61 | 61 | }; |
62 | -static unsigned int cpu_post_rlwinm_size = | |
63 | - sizeof (cpu_post_rlwinm_table) / sizeof (struct cpu_post_rlwinm_s); | |
62 | +static unsigned int cpu_post_rlwinm_size = ARRAY_SIZE(cpu_post_rlwinm_table); | |
64 | 63 | |
65 | 64 | int cpu_post_test_rlwinm (void) |
66 | 65 | { |
post/lib_powerpc/rlwnm.c
... | ... | @@ -60,8 +60,7 @@ |
60 | 60 | 0x0000ff00 |
61 | 61 | }, |
62 | 62 | }; |
63 | -static unsigned int cpu_post_rlwnm_size = | |
64 | - sizeof (cpu_post_rlwnm_table) / sizeof (struct cpu_post_rlwnm_s); | |
63 | +static unsigned int cpu_post_rlwnm_size = ARRAY_SIZE(cpu_post_rlwnm_table); | |
65 | 64 | |
66 | 65 | int cpu_post_test_rlwnm (void) |
67 | 66 | { |
post/lib_powerpc/srawi.c
... | ... | @@ -61,8 +61,7 @@ |
61 | 61 | 0xf0000000 |
62 | 62 | }, |
63 | 63 | }; |
64 | -static unsigned int cpu_post_srawi_size = | |
65 | - sizeof (cpu_post_srawi_table) / sizeof (struct cpu_post_srawi_s); | |
64 | +static unsigned int cpu_post_srawi_size = ARRAY_SIZE(cpu_post_srawi_table); | |
66 | 65 | |
67 | 66 | int cpu_post_test_srawi (void) |
68 | 67 | { |
post/lib_powerpc/store.c
... | ... | @@ -156,8 +156,7 @@ |
156 | 156 | 0xff |
157 | 157 | }, |
158 | 158 | }; |
159 | -static unsigned int cpu_post_store_size = | |
160 | - sizeof (cpu_post_store_table) / sizeof (struct cpu_post_store_s); | |
159 | +static unsigned int cpu_post_store_size = ARRAY_SIZE(cpu_post_store_table); | |
161 | 160 | |
162 | 161 | int cpu_post_test_store (void) |
163 | 162 | { |
post/lib_powerpc/three.c
... | ... | @@ -155,8 +155,7 @@ |
155 | 155 | 0x40 |
156 | 156 | }, |
157 | 157 | }; |
158 | -static unsigned int cpu_post_three_size = | |
159 | - sizeof (cpu_post_three_table) / sizeof (struct cpu_post_three_s); | |
158 | +static unsigned int cpu_post_three_size = ARRAY_SIZE(cpu_post_three_table); | |
160 | 159 | |
161 | 160 | int cpu_post_test_three (void) |
162 | 161 | { |
post/lib_powerpc/threei.c
... | ... | @@ -75,8 +75,7 @@ |
75 | 75 | 0xffff8000 |
76 | 76 | }, |
77 | 77 | }; |
78 | -static unsigned int cpu_post_threei_size = | |
79 | - sizeof (cpu_post_threei_table) / sizeof (struct cpu_post_threei_s); | |
78 | +static unsigned int cpu_post_threei_size = ARRAY_SIZE(cpu_post_threei_table); | |
80 | 79 | |
81 | 80 | int cpu_post_test_threei (void) |
82 | 81 | { |
post/lib_powerpc/threex.c
... | ... | @@ -125,8 +125,7 @@ |
125 | 125 | 0x1000 |
126 | 126 | }, |
127 | 127 | }; |
128 | -static unsigned int cpu_post_threex_size = | |
129 | - sizeof (cpu_post_threex_table) / sizeof (struct cpu_post_threex_s); | |
128 | +static unsigned int cpu_post_threex_size = ARRAY_SIZE(cpu_post_threex_table); | |
130 | 129 | |
131 | 130 | int cpu_post_test_threex (void) |
132 | 131 | { |
post/lib_powerpc/two.c
post/lib_powerpc/twox.c
post/post.c
... | ... | @@ -196,7 +196,7 @@ |
196 | 196 | POST_CRITICAL }; |
197 | 197 | char *var[] = { "post_poweron", "post_normal", "post_slowtest", |
198 | 198 | "post_critical" }; |
199 | - int varnum = sizeof (var) / sizeof (var[0]); | |
199 | + int varnum = ARRAY_SIZE(var); | |
200 | 200 | char list[128]; /* long enough for POST list */ |
201 | 201 | char *name; |
202 | 202 | char *s; |
post/tests.c