Commit e92372c8a70d54cdba732fb9da914337e0a89d28

Authored by Heiko Schocher
Committed by Albert ARIBAUD
1 parent ee4014b005

cosmetic, post: Codingstyle cleanup

Signed-off-by: Heiko Schocher <hs@denx.de>

Showing 1 changed file with 59 additions and 68 deletions Side-by-side Diff

... ... @@ -40,7 +40,7 @@
40 40  
41 41 #define BOOTMODE_MAGIC 0xDEAD0000
42 42  
43   -int post_init_f (void)
  43 +int post_init_f(void)
44 44 {
45 45 int res = 0;
46 46 unsigned int i;
... ... @@ -55,9 +55,7 @@
55 55  
56 56 gd->post_init_f_time = post_time_ms(0);
57 57 if (!gd->post_init_f_time)
58   - {
59   - printf("post/post.c: post_time_ms seems not to be implemented\n");
60   - }
  58 + printf("%s: post_time_ms not implemented\n", __FILE__);
61 59  
62 60 return res;
63 61 }
64 62  
65 63  
66 64  
67 65  
68 66  
69 67  
70 68  
71 69  
72 70  
73 71  
74 72  
75 73  
76 74  
77 75  
78 76  
79 77  
80 78  
81 79  
... ... @@ -95,66 +93,61 @@
95 93 __attribute__((weak, alias("__post_hotkeys_pressed")));
96 94  
97 95  
98   -void post_bootmode_init (void)
  96 +void post_bootmode_init(void)
99 97 {
100   - int bootmode = post_bootmode_get (0);
  98 + int bootmode = post_bootmode_get(0);
101 99 int newword;
102 100  
103   - if (post_hotkeys_pressed() && !(bootmode & POST_POWERTEST)) {
  101 + if (post_hotkeys_pressed() && !(bootmode & POST_POWERTEST))
104 102 newword = BOOTMODE_MAGIC | POST_SLOWTEST;
105   - } else if (bootmode == 0) {
  103 + else if (bootmode == 0)
106 104 newword = BOOTMODE_MAGIC | POST_POWERON;
107   - } else if (bootmode == POST_POWERON || bootmode == POST_SLOWTEST) {
  105 + else if (bootmode == POST_POWERON || bootmode == POST_SLOWTEST)
108 106 newword = BOOTMODE_MAGIC | POST_NORMAL;
109   - } else {
  107 + else
110 108 /* Use old value */
111 109 newword = post_word_load () & ~POST_COLDBOOT;
112   - }
113 110  
114 111 if (bootmode == 0)
115   - {
116 112 /* We are booting after power-on */
117 113 newword |= POST_COLDBOOT;
118   - }
119 114  
120   - post_word_store (newword);
  115 + post_word_store(newword);
121 116  
122 117 /* Reset activity record */
123 118 gd->post_log_word = 0;
124 119 gd->post_log_res = 0;
125 120 }
126 121  
127   -int post_bootmode_get (unsigned int *last_test)
  122 +int post_bootmode_get(unsigned int *last_test)
128 123 {
129   - unsigned long word = post_word_load ();
  124 + unsigned long word = post_word_load();
130 125 int bootmode;
131 126  
132   - if ((word & 0xFFFF0000) != BOOTMODE_MAGIC) {
  127 + if ((word & 0xFFFF0000) != BOOTMODE_MAGIC)
133 128 return 0;
134   - }
135 129  
136 130 bootmode = word & 0x7F;
137 131  
138   - if (last_test && (bootmode & POST_POWERTEST)) {
  132 + if (last_test && (bootmode & POST_POWERTEST))
139 133 *last_test = (word >> 8) & 0xFF;
140   - }
141 134  
142 135 return bootmode;
143 136 }
144 137  
145 138 /* POST tests run before relocation only mark status bits .... */
146   -static void post_log_mark_start ( unsigned long testid )
  139 +static void post_log_mark_start(unsigned long testid)
147 140 {
148 141 gd->post_log_word |= testid;
149 142 }
150 143  
151   -static void post_log_mark_succ ( unsigned long testid )
  144 +static void post_log_mark_succ(unsigned long testid)
152 145 {
153 146 gd->post_log_res |= testid;
154 147 }
155 148  
156 149 /* ... and the messages are output once we are relocated */
157   -void post_output_backlog ( void )
  150 +void post_output_backlog(void)
158 151 {
159 152 int j;
160 153  
161 154  
162 155  
163 156  
164 157  
165 158  
166 159  
... ... @@ -164,31 +157,31 @@
164 157 if (gd->post_log_res & post_list[j].testid)
165 158 post_log ("PASSED\n");
166 159 else {
167   - post_log ("FAILED\n");
168   - show_boot_progress (-31);
  160 + post_log("FAILED\n");
  161 + show_boot_progress(-31);
169 162 }
170 163 }
171 164 }
172 165 }
173 166  
174   -static void post_bootmode_test_on (unsigned int last_test)
  167 +static void post_bootmode_test_on(unsigned int last_test)
175 168 {
176   - unsigned long word = post_word_load ();
  169 + unsigned long word = post_word_load();
177 170  
178 171 word |= POST_POWERTEST;
179 172  
180 173 word |= (last_test & 0xFF) << 8;
181 174  
182   - post_word_store (word);
  175 + post_word_store(word);
183 176 }
184 177  
185   -static void post_bootmode_test_off (void)
  178 +static void post_bootmode_test_off(void)
186 179 {
187   - unsigned long word = post_word_load ();
  180 + unsigned long word = post_word_load();
188 181  
189 182 word &= ~POST_POWERTEST;
190 183  
191   - post_word_store (word);
  184 + post_word_store(word);
192 185 }
193 186  
194 187 #ifndef CONFIG_POST_SKIP_ENV_FLAGS
195 188  
... ... @@ -235,9 +228,8 @@
235 228 }
236 229 }
237 230  
238   - if (j == post_list_size) {
  231 + if (j == post_list_size)
239 232 printf ("No such test: %s\n", name);
240   - }
241 233  
242 234 name = s + 1;
243 235 }
244 236  
245 237  
246 238  
247 239  
... ... @@ -256,20 +248,18 @@
256 248 post_get_env_flags(test_flags);
257 249 #endif
258 250  
259   - for (j = 0; j < post_list_size; j++) {
260   - if (test_flags[j] & POST_POWERON) {
  251 + for (j = 0; j < post_list_size; j++)
  252 + if (test_flags[j] & POST_POWERON)
261 253 test_flags[j] |= POST_SLOWTEST;
262   - }
263   - }
264 254 }
265 255  
266   -void __show_post_progress (unsigned int test_num, int before, int result)
  256 +void __show_post_progress(unsigned int test_num, int before, int result)
267 257 {
268 258 }
269   -void show_post_progress (unsigned int, int, int)
  259 +void show_post_progress(unsigned int, int, int)
270 260 __attribute__((weak, alias("__show_post_progress")));
271 261  
272   -static int post_run_single (struct post_test *test,
  262 +static int post_run_single(struct post_test *test,
273 263 int test_flags, int flags, unsigned int i)
274 264 {
275 265 if ((flags & test_flags & POST_ALWAYS) &&
276 266  
277 267  
278 268  
... ... @@ -277,23 +267,24 @@
277 267 WATCHDOG_RESET ();
278 268  
279 269 if (!(flags & POST_REBOOT)) {
280   - if ((test_flags & POST_REBOOT) && !(flags & POST_MANUAL)) {
281   - post_bootmode_test_on (
  270 + if ((test_flags & POST_REBOOT) &&
  271 + !(flags & POST_MANUAL)) {
  272 + post_bootmode_test_on(
282 273 (gd->flags & GD_FLG_POSTFAIL) ?
283 274 POST_FAIL_SAVE | i : i);
284 275 }
285 276  
286 277 if (test_flags & POST_PREREL)
287   - post_log_mark_start ( test->testid );
  278 + post_log_mark_start(test->testid);
288 279 else
289   - post_log ("POST %s ", test->cmd);
  280 + post_log("POST %s ", test->cmd);
290 281 }
291 282  
292 283 show_post_progress(i, POST_BEFORE, POST_FAILED);
293 284  
294 285 if (test_flags & POST_PREREL) {
295 286 if ((*test->test) (flags) == 0) {
296   - post_log_mark_succ ( test->testid );
  287 + post_log_mark_succ(test->testid);
297 288 show_post_progress(i, POST_AFTER, POST_PASSED);
298 289 }
299 290 else {
... ... @@ -319,7 +310,7 @@
319 310 }
320 311  
321 312 if ((test_flags & POST_REBOOT) && !(flags & POST_MANUAL)) {
322   - post_bootmode_test_off ();
  313 + post_bootmode_test_off();
323 314 }
324 315  
325 316 return 0;
... ... @@ -333,7 +324,7 @@
333 324 unsigned int i;
334 325 int test_flags[POST_MAX_NUMBER];
335 326  
336   - post_get_flags (test_flags);
  327 + post_get_flags(test_flags);
337 328  
338 329 if (name == NULL) {
339 330 unsigned int last;
... ... @@ -341,7 +332,7 @@
341 332 if (gd->flags & GD_FLG_POSTSTOP)
342 333 return 0;
343 334  
344   - if (post_bootmode_get (&last) & POST_POWERTEST) {
  335 + if (post_bootmode_get(&last) & POST_POWERTEST) {
345 336 if (last & POST_FAIL_SAVE) {
346 337 last &= ~POST_FAIL_SAVE;
347 338 gd->flags |= GD_FLG_POSTFAIL;
348 339  
... ... @@ -350,14 +341,14 @@
350 341 (flags & test_flags[last] & POST_ALWAYS) &&
351 342 (flags & test_flags[last] & POST_MEM)) {
352 343  
353   - post_run_single (post_list + last,
  344 + post_run_single(post_list + last,
354 345 test_flags[last],
355 346 flags | POST_REBOOT, last);
356 347  
357 348 for (i = last + 1; i < post_list_size; i++) {
358 349 if (gd->flags & GD_FLG_POSTSTOP)
359 350 break;
360   - post_run_single (post_list + i,
  351 + post_run_single(post_list + i,
361 352 test_flags[i],
362 353 flags, i);
363 354 }
... ... @@ -366,7 +357,7 @@
366 357 for (i = 0; i < post_list_size; i++) {
367 358 if (gd->flags & GD_FLG_POSTSTOP)
368 359 break;
369   - post_run_single (post_list + i,
  360 + post_run_single(post_list + i,
370 361 test_flags[i],
371 362 flags, i);
372 363 }
... ... @@ -381,7 +372,7 @@
381 372  
382 373 if (i < post_list_size) {
383 374 WATCHDOG_RESET();
384   - return post_run_single (post_list + i,
  375 + return post_run_single(post_list + i,
385 376 test_flags[i],
386 377 flags, i);
387 378 } else {
388 379  
389 380  
... ... @@ -390,14 +381,14 @@
390 381 }
391 382 }
392 383  
393   -static int post_info_single (struct post_test *test, int full)
  384 +static int post_info_single(struct post_test *test, int full)
394 385 {
395 386 if (test->flags & POST_MANUAL) {
396 387 if (full)
397   - printf ("%s - %s\n"
  388 + printf("%s - %s\n"
398 389 " %s\n", test->cmd, test->name, test->desc);
399 390 else
400   - printf (" %-15s - %s\n", test->cmd, test->name);
  391 + printf(" %-15s - %s\n", test->cmd, test->name);
401 392  
402 393 return 0;
403 394 } else {
... ... @@ -410,9 +401,8 @@
410 401 unsigned int i;
411 402  
412 403 if (name == NULL) {
413   - for (i = 0; i < post_list_size; i++) {
414   - post_info_single (post_list + i, 0);
415   - }
  404 + for (i = 0; i < post_list_size; i++)
  405 + post_info_single(post_list + i, 0);
416 406  
417 407 return 0;
418 408 } else {
419 409  
... ... @@ -422,14 +412,14 @@
422 412 }
423 413  
424 414 if (i < post_list_size) {
425   - return post_info_single (post_list + i, 1);
  415 + return post_info_single(post_list + i, 1);
426 416 } else {
427 417 return -1;
428 418 }
429 419 }
430 420 }
431 421  
432   -int post_log (char *format, ...)
  422 +int post_log(char *format, ...)
433 423 {
434 424 va_list args;
435 425 uint i;
436 426  
437 427  
... ... @@ -445,17 +435,17 @@
445 435  
446 436 #ifdef CONFIG_LOGBUFFER
447 437 /* Send to the logbuffer */
448   - logbuff_log (printbuffer);
  438 + logbuff_log(printbuffer);
449 439 #else
450 440 /* Send to the stdout file */
451   - puts (printbuffer);
  441 + puts(printbuffer);
452 442 #endif
453 443  
454 444 return 0;
455 445 }
456 446  
457 447 #ifdef CONFIG_NEEDS_MANUAL_RELOC
458   -void post_reloc (void)
  448 +void post_reloc(void)
459 449 {
460 450 unsigned int i;
461 451  
462 452  
463 453  
... ... @@ -468,17 +458,17 @@
468 458  
469 459 if (test->name) {
470 460 addr = (ulong) (test->name) + gd->reloc_off;
471   - test->name = (char *) addr;
  461 + test->name = (char *)addr;
472 462 }
473 463  
474 464 if (test->cmd) {
475 465 addr = (ulong) (test->cmd) + gd->reloc_off;
476   - test->cmd = (char *) addr;
  466 + test->cmd = (char *)addr;
477 467 }
478 468  
479 469 if (test->desc) {
480 470 addr = (ulong) (test->desc) + gd->reloc_off;
481   - test->desc = (char *) addr;
  471 + test->desc = (char *)addr;
482 472 }
483 473  
484 474 if (test->test) {
485 475  
... ... @@ -508,10 +498,11 @@
508 498 *
509 499 * On PowerPC we implement it using the timebase register.
510 500 */
511   -unsigned long post_time_ms (unsigned long base)
  501 +unsigned long post_time_ms(unsigned long base)
512 502 {
513 503 #ifdef CONFIG_PPC
514   - return (unsigned long)(get_ticks () / (get_tbclk () / CONFIG_SYS_HZ)) - base;
  504 + return (unsigned long)(get_ticks() / (get_tbclk() / CONFIG_SYS_HZ))
  505 + - base;
515 506 #else
516 507 #warning "Not implemented yet"
517 508 return 0; /* Not implemented yet */