Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Tobias Klauser and committed by
Linus Torvalds
25c8716c c8e5429e

+34 -38
+3 -5
arch/alpha/kernel/err_ev7.c
··· 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 } 289 287
+2 -2
arch/alpha/kernel/osf_sys.c
··· 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;
+24 -26
arch/alpha/kernel/setup.c
··· 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 *); ··· 238 240 standard_io_resources[0].start = RTC_PORT(0); 239 241 standard_io_resources[0].end = RTC_PORT(0) + 0x10; 240 242 241 - for (i = 0; i < N(standard_io_resources); ++i) 243 + for (i = 0; i < ARRAY_SIZE(standard_io_resources); ++i) 242 244 request_resource(io, standard_io_resources+i); 243 245 } 244 246 ··· 916 918 917 919 /* Search the system tables first... */ 918 920 vec = NULL; 919 - if (type < N(systype_vecs)) { 921 + if (type < ARRAY_SIZE(systype_vecs)) { 920 922 vec = systype_vecs[type]; 921 923 } else if ((type > ST_API_BIAS) && 922 - (type - ST_API_BIAS) < N(api_vecs)) { 924 + (type - ST_API_BIAS) < ARRAY_SIZE(api_vecs)) { 923 925 vec = api_vecs[type - ST_API_BIAS]; 924 926 } else if ((type > ST_UNOFFICIAL_BIAS) && 925 - (type - ST_UNOFFICIAL_BIAS) < N(unofficial_vecs)) { 927 + (type - ST_UNOFFICIAL_BIAS) < ARRAY_SIZE(unofficial_vecs)) { 926 928 vec = unofficial_vecs[type - ST_UNOFFICIAL_BIAS]; 927 929 } 928 930 ··· 936 938 937 939 switch (type) { 938 940 case ST_DEC_ALCOR: 939 - if (member < N(alcor_indices)) 941 + if (member < ARRAY_SIZE(alcor_indices)) 940 942 vec = alcor_vecs[alcor_indices[member]]; 941 943 break; 942 944 case ST_DEC_EB164: 943 - if (member < N(eb164_indices)) 945 + if (member < ARRAY_SIZE(eb164_indices)) 944 946 vec = eb164_vecs[eb164_indices[member]]; 945 947 /* PC164 may show as EB164 variation with EV56 CPU, 946 948 but, since no true EB164 had anything but EV5... */ ··· 948 950 vec = &pc164_mv; 949 951 break; 950 952 case ST_DEC_EB64P: 951 - if (member < N(eb64p_indices)) 953 + if (member < ARRAY_SIZE(eb64p_indices)) 952 954 vec = eb64p_vecs[eb64p_indices[member]]; 953 955 break; 954 956 case ST_DEC_EB66: 955 - if (member < N(eb66_indices)) 957 + if (member < ARRAY_SIZE(eb66_indices)) 956 958 vec = eb66_vecs[eb66_indices[member]]; 957 959 break; 958 960 case ST_DEC_MARVEL: 959 - if (member < N(marvel_indices)) 961 + if (member < ARRAY_SIZE(marvel_indices)) 960 962 vec = marvel_vecs[marvel_indices[member]]; 961 963 break; 962 964 case ST_DEC_TITAN: 963 965 vec = titan_vecs[0]; /* default */ 964 - if (member < N(titan_indices)) 966 + if (member < ARRAY_SIZE(titan_indices)) 965 967 vec = titan_vecs[titan_indices[member]]; 966 968 break; 967 969 case ST_DEC_TSUNAMI: 968 - if (member < N(tsunami_indices)) 970 + if (member < ARRAY_SIZE(tsunami_indices)) 969 971 vec = tsunami_vecs[tsunami_indices[member]]; 970 972 break; 971 973 case ST_DEC_1000: ··· 1037 1039 1038 1040 size_t i; 1039 1041 1040 - for (i = 0; i < N(all_vecs); ++i) { 1042 + for (i = 0; i < ARRAY_SIZE(all_vecs); ++i) { 1041 1043 struct alpha_machine_vector *mv = all_vecs[i]; 1042 1044 if (strcasecmp(mv->vector_name, name) == 0) 1043 1045 return mv; ··· 1053 1055 1054 1056 /* If not in the tables, make it UNKNOWN, 1055 1057 else set type name to family */ 1056 - if (type < N(systype_names)) { 1058 + if (type < ARRAY_SIZE(systype_names)) { 1057 1059 *type_name = systype_names[type]; 1058 1060 } else if ((type > ST_API_BIAS) && 1059 - (type - ST_API_BIAS) < N(api_names)) { 1061 + (type - ST_API_BIAS) < ARRAY_SIZE(api_names)) { 1060 1062 *type_name = api_names[type - ST_API_BIAS]; 1061 1063 } else if ((type > ST_UNOFFICIAL_BIAS) && 1062 - (type - ST_UNOFFICIAL_BIAS) < N(unofficial_names)) { 1064 + (type - ST_UNOFFICIAL_BIAS) < ARRAY_SIZE(unofficial_names)) { 1063 1065 *type_name = unofficial_names[type - ST_UNOFFICIAL_BIAS]; 1064 1066 } else { 1065 1067 *type_name = sys_unknown; ··· 1081 1083 default: /* default to variation "0" for now */ 1082 1084 break; 1083 1085 case ST_DEC_EB164: 1084 - if (member < N(eb164_indices)) 1086 + if (member < ARRAY_SIZE(eb164_indices)) 1085 1087 *variation_name = eb164_names[eb164_indices[member]]; 1086 1088 /* PC164 may show as EB164 variation, but with EV56 CPU, 1087 1089 so, since no true EB164 had anything but EV5... */ ··· 1089 1091 *variation_name = eb164_names[1]; /* make it PC164 */ 1090 1092 break; 1091 1093 case ST_DEC_ALCOR: 1092 - if (member < N(alcor_indices)) 1094 + if (member < ARRAY_SIZE(alcor_indices)) 1093 1095 *variation_name = alcor_names[alcor_indices[member]]; 1094 1096 break; 1095 1097 case ST_DEC_EB64P: 1096 - if (member < N(eb64p_indices)) 1098 + if (member < ARRAY_SIZE(eb64p_indices)) 1097 1099 *variation_name = eb64p_names[eb64p_indices[member]]; 1098 1100 break; 1099 1101 case ST_DEC_EB66: 1100 - if (member < N(eb66_indices)) 1102 + if (member < ARRAY_SIZE(eb66_indices)) 1101 1103 *variation_name = eb66_names[eb66_indices[member]]; 1102 1104 break; 1103 1105 case ST_DEC_MARVEL: 1104 - if (member < N(marvel_indices)) 1106 + if (member < ARRAY_SIZE(marvel_indices)) 1105 1107 *variation_name = marvel_names[marvel_indices[member]]; 1106 1108 break; 1107 1109 case ST_DEC_RAWHIDE: 1108 - if (member < N(rawhide_indices)) 1110 + if (member < ARRAY_SIZE(rawhide_indices)) 1109 1111 *variation_name = rawhide_names[rawhide_indices[member]]; 1110 1112 break; 1111 1113 case ST_DEC_TITAN: 1112 1114 *variation_name = titan_names[0]; /* default */ 1113 - if (member < N(titan_indices)) 1115 + if (member < ARRAY_SIZE(titan_indices)) 1114 1116 *variation_name = titan_names[titan_indices[member]]; 1115 1117 break; 1116 1118 case ST_DEC_TSUNAMI: 1117 - if (member < N(tsunami_indices)) 1119 + if (member < ARRAY_SIZE(tsunami_indices)) 1118 1120 *variation_name = tsunami_names[tsunami_indices[member]]; 1119 1121 break; 1120 1122 } ··· 1209 1211 1210 1212 cpu_index = (unsigned) (cpu->type - 1); 1211 1213 cpu_name = "Unknown"; 1212 - if (cpu_index < N(cpu_names)) 1214 + if (cpu_index < ARRAY_SIZE(cpu_names)) 1213 1215 cpu_name = cpu_names[cpu_index]; 1214 1216 1215 1217 get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
+4 -4
arch/alpha/kernel/sys_ruffian.c
··· 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 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
+1 -1
arch/alpha/kernel/time.c
··· 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. */