Commit 25c8716cb08dea386c7d6220b82eba732ccbf976

Authored by Tobias Klauser
Committed by Linus Torvalds
1 parent c8e5429e49

[PATCH] arch/alpha: Use ARRAY_SIZE macro

Use ARRAY_SIZE macro instead of sizeof(x)/sizeof(x[0]) and remove a
duplicate of the macro.  Also remove some trailing whitespaces and needless
braces.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 5 changed files with 34 additions and 38 deletions Side-by-side Diff

arch/alpha/kernel/err_ev7.c
... ... @@ -274,16 +274,14 @@
274 274 struct el_subpacket_handler ev7_pal_subpacket_handler =
275 275 SUBPACKET_HANDLER_INIT(EL_CLASS__PAL, ev7_process_pal_subpacket);
276 276  
277   -void
  277 +void
278 278 ev7_register_error_handlers(void)
279 279 {
280 280 int i;
281 281  
282   - for(i = 0;
283   - i<sizeof(el_ev7_pal_annotations)/sizeof(el_ev7_pal_annotations[1]);
284   - i++) {
  282 + for (i = 0; i < ARRAY_SIZE(el_ev7_pal_annotations); i++)
285 283 cdl_register_subpacket_annotation(&el_ev7_pal_annotations[i]);
286   - }
  284 +
287 285 cdl_register_subpacket_handler(&ev7_pal_subpacket_handler);
288 286 }
arch/alpha/kernel/osf_sys.c
... ... @@ -623,12 +623,12 @@
623 623 long len, err = -EINVAL;
624 624  
625 625 offset = command-1;
626   - if (offset >= sizeof(sysinfo_table)/sizeof(char *)) {
  626 + if (offset >= ARRAY_SIZE(sysinfo_table)) {
627 627 /* Digital UNIX has a few unpublished interfaces here */
628 628 printk("sysinfo(%d)", command);
629 629 goto out;
630 630 }
631   -
  631 +
632 632 down_read(&uts_sem);
633 633 res = sysinfo_table[offset];
634 634 len = strlen(res)+1;
arch/alpha/kernel/setup.c
... ... @@ -114,8 +114,6 @@
114 114 int alpha_using_srm;
115 115 #endif
116 116  
117   -#define N(a) (sizeof(a)/sizeof(a[0]))
118   -
119 117 static struct alpha_machine_vector *get_sysvec(unsigned long, unsigned long,
120 118 unsigned long);
121 119 static struct alpha_machine_vector *get_sysvec_byname(const char *);
... ... @@ -240,7 +238,7 @@
240 238 standard_io_resources[0].start = RTC_PORT(0);
241 239 standard_io_resources[0].end = RTC_PORT(0) + 0x10;
242 240  
243   - for (i = 0; i < N(standard_io_resources); ++i)
  241 + for (i = 0; i < ARRAY_SIZE(standard_io_resources); ++i)
244 242 request_resource(io, standard_io_resources+i);
245 243 }
246 244  
247 245  
248 246  
... ... @@ -918,13 +916,13 @@
918 916  
919 917 /* Search the system tables first... */
920 918 vec = NULL;
921   - if (type < N(systype_vecs)) {
  919 + if (type < ARRAY_SIZE(systype_vecs)) {
922 920 vec = systype_vecs[type];
923 921 } else if ((type > ST_API_BIAS) &&
924   - (type - ST_API_BIAS) < N(api_vecs)) {
  922 + (type - ST_API_BIAS) < ARRAY_SIZE(api_vecs)) {
925 923 vec = api_vecs[type - ST_API_BIAS];
926 924 } else if ((type > ST_UNOFFICIAL_BIAS) &&
927   - (type - ST_UNOFFICIAL_BIAS) < N(unofficial_vecs)) {
  925 + (type - ST_UNOFFICIAL_BIAS) < ARRAY_SIZE(unofficial_vecs)) {
928 926 vec = unofficial_vecs[type - ST_UNOFFICIAL_BIAS];
929 927 }
930 928  
931 929  
... ... @@ -938,11 +936,11 @@
938 936  
939 937 switch (type) {
940 938 case ST_DEC_ALCOR:
941   - if (member < N(alcor_indices))
  939 + if (member < ARRAY_SIZE(alcor_indices))
942 940 vec = alcor_vecs[alcor_indices[member]];
943 941 break;
944 942 case ST_DEC_EB164:
945   - if (member < N(eb164_indices))
  943 + if (member < ARRAY_SIZE(eb164_indices))
946 944 vec = eb164_vecs[eb164_indices[member]];
947 945 /* PC164 may show as EB164 variation with EV56 CPU,
948 946 but, since no true EB164 had anything but EV5... */
949 947  
950 948  
951 949  
952 950  
... ... @@ -950,24 +948,24 @@
950 948 vec = &pc164_mv;
951 949 break;
952 950 case ST_DEC_EB64P:
953   - if (member < N(eb64p_indices))
  951 + if (member < ARRAY_SIZE(eb64p_indices))
954 952 vec = eb64p_vecs[eb64p_indices[member]];
955 953 break;
956 954 case ST_DEC_EB66:
957   - if (member < N(eb66_indices))
  955 + if (member < ARRAY_SIZE(eb66_indices))
958 956 vec = eb66_vecs[eb66_indices[member]];
959 957 break;
960 958 case ST_DEC_MARVEL:
961   - if (member < N(marvel_indices))
  959 + if (member < ARRAY_SIZE(marvel_indices))
962 960 vec = marvel_vecs[marvel_indices[member]];
963 961 break;
964 962 case ST_DEC_TITAN:
965 963 vec = titan_vecs[0]; /* default */
966   - if (member < N(titan_indices))
  964 + if (member < ARRAY_SIZE(titan_indices))
967 965 vec = titan_vecs[titan_indices[member]];
968 966 break;
969 967 case ST_DEC_TSUNAMI:
970   - if (member < N(tsunami_indices))
  968 + if (member < ARRAY_SIZE(tsunami_indices))
971 969 vec = tsunami_vecs[tsunami_indices[member]];
972 970 break;
973 971 case ST_DEC_1000:
... ... @@ -1039,7 +1037,7 @@
1039 1037  
1040 1038 size_t i;
1041 1039  
1042   - for (i = 0; i < N(all_vecs); ++i) {
  1040 + for (i = 0; i < ARRAY_SIZE(all_vecs); ++i) {
1043 1041 struct alpha_machine_vector *mv = all_vecs[i];
1044 1042 if (strcasecmp(mv->vector_name, name) == 0)
1045 1043 return mv;
1046 1044  
1047 1045  
... ... @@ -1055,13 +1053,13 @@
1055 1053  
1056 1054 /* If not in the tables, make it UNKNOWN,
1057 1055 else set type name to family */
1058   - if (type < N(systype_names)) {
  1056 + if (type < ARRAY_SIZE(systype_names)) {
1059 1057 *type_name = systype_names[type];
1060 1058 } else if ((type > ST_API_BIAS) &&
1061   - (type - ST_API_BIAS) < N(api_names)) {
  1059 + (type - ST_API_BIAS) < ARRAY_SIZE(api_names)) {
1062 1060 *type_name = api_names[type - ST_API_BIAS];
1063 1061 } else if ((type > ST_UNOFFICIAL_BIAS) &&
1064   - (type - ST_UNOFFICIAL_BIAS) < N(unofficial_names)) {
  1062 + (type - ST_UNOFFICIAL_BIAS) < ARRAY_SIZE(unofficial_names)) {
1065 1063 *type_name = unofficial_names[type - ST_UNOFFICIAL_BIAS];
1066 1064 } else {
1067 1065 *type_name = sys_unknown;
... ... @@ -1083,7 +1081,7 @@
1083 1081 default: /* default to variation "0" for now */
1084 1082 break;
1085 1083 case ST_DEC_EB164:
1086   - if (member < N(eb164_indices))
  1084 + if (member < ARRAY_SIZE(eb164_indices))
1087 1085 *variation_name = eb164_names[eb164_indices[member]];
1088 1086 /* PC164 may show as EB164 variation, but with EV56 CPU,
1089 1087 so, since no true EB164 had anything but EV5... */
1090 1088  
1091 1089  
1092 1090  
1093 1091  
1094 1092  
1095 1093  
... ... @@ -1091,32 +1089,32 @@
1091 1089 *variation_name = eb164_names[1]; /* make it PC164 */
1092 1090 break;
1093 1091 case ST_DEC_ALCOR:
1094   - if (member < N(alcor_indices))
  1092 + if (member < ARRAY_SIZE(alcor_indices))
1095 1093 *variation_name = alcor_names[alcor_indices[member]];
1096 1094 break;
1097 1095 case ST_DEC_EB64P:
1098   - if (member < N(eb64p_indices))
  1096 + if (member < ARRAY_SIZE(eb64p_indices))
1099 1097 *variation_name = eb64p_names[eb64p_indices[member]];
1100 1098 break;
1101 1099 case ST_DEC_EB66:
1102   - if (member < N(eb66_indices))
  1100 + if (member < ARRAY_SIZE(eb66_indices))
1103 1101 *variation_name = eb66_names[eb66_indices[member]];
1104 1102 break;
1105 1103 case ST_DEC_MARVEL:
1106   - if (member < N(marvel_indices))
  1104 + if (member < ARRAY_SIZE(marvel_indices))
1107 1105 *variation_name = marvel_names[marvel_indices[member]];
1108 1106 break;
1109 1107 case ST_DEC_RAWHIDE:
1110   - if (member < N(rawhide_indices))
  1108 + if (member < ARRAY_SIZE(rawhide_indices))
1111 1109 *variation_name = rawhide_names[rawhide_indices[member]];
1112 1110 break;
1113 1111 case ST_DEC_TITAN:
1114 1112 *variation_name = titan_names[0]; /* default */
1115   - if (member < N(titan_indices))
  1113 + if (member < ARRAY_SIZE(titan_indices))
1116 1114 *variation_name = titan_names[titan_indices[member]];
1117 1115 break;
1118 1116 case ST_DEC_TSUNAMI:
1119   - if (member < N(tsunami_indices))
  1117 + if (member < ARRAY_SIZE(tsunami_indices))
1120 1118 *variation_name = tsunami_names[tsunami_indices[member]];
1121 1119 break;
1122 1120 }
... ... @@ -1211,7 +1209,7 @@
1211 1209  
1212 1210 cpu_index = (unsigned) (cpu->type - 1);
1213 1211 cpu_name = "Unknown";
1214   - if (cpu_index < N(cpu_names))
  1212 + if (cpu_index < ARRAY_SIZE(cpu_names))
1215 1213 cpu_name = cpu_names[cpu_index];
1216 1214  
1217 1215 get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
arch/alpha/kernel/sys_ruffian.c
... ... @@ -182,16 +182,16 @@
182 182 ruffian_get_bank_size(unsigned long offset)
183 183 {
184 184 unsigned long bank_addr, bank, ret = 0;
185   -
  185 +
186 186 /* Valid offsets are: 0x800, 0x840 and 0x880
187 187 since Ruffian only uses three banks. */
188 188 bank_addr = (unsigned long)PYXIS_MCR + offset;
189 189 bank = *(vulp)bank_addr;
190   -
  190 +
191 191 /* Check BANK_ENABLE */
192 192 if (bank & 0x01) {
193 193 static unsigned long size[] __initdata = {
194   - 0x40000000UL, /* 0x00, 1G */
  194 + 0x40000000UL, /* 0x00, 1G */
195 195 0x20000000UL, /* 0x02, 512M */
196 196 0x10000000UL, /* 0x04, 256M */
197 197 0x08000000UL, /* 0x06, 128M */
... ... @@ -203,7 +203,7 @@
203 203 };
204 204  
205 205 bank = (bank & 0x1e) >> 1;
206   - if (bank < sizeof(size)/sizeof(*size))
  206 + if (bank < ARRAY_SIZE(size))
207 207 ret = size[bank];
208 208 }
209 209  
arch/alpha/kernel/time.c
... ... @@ -233,7 +233,7 @@
233 233 index = cpu->type & 0xffffffff;
234 234  
235 235 /* If index out of bounds, no way to validate. */
236   - if (index >= sizeof(cpu_hz)/sizeof(cpu_hz[0]))
  236 + if (index >= ARRAY_SIZE(cpu_hz))
237 237 return cc;
238 238  
239 239 /* If index contains no data, no way to validate. */