Commit 3043c045d5a9897faba7d5c7218c2f4d06cd0038

Authored by William Juul
Committed by Scott Wood
1 parent 5e1dae5c3d

Whitespace cleanup and marking broken code.

Changes requested by maintainer Stefan Roese after
posting patch to U-boot mailing list.

Signed-off-by: William Juul <william.juul@tandberg.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>

Showing 2 changed files with 57 additions and 44 deletions Side-by-side Diff

... ... @@ -14,6 +14,11 @@
14 14 #include <linux/mtd/nftl.h>
15 15 #include <linux/mtd/doc2000.h>
16 16  
  17 +/*
  18 + * ! BROKEN !
  19 + *
  20 + * TODO: must be implemented and tested by someone with HW
  21 + */
17 22 #if 0
18 23 #ifdef CFG_DOC_SUPPORT_2000
19 24 #define DoC_is_2000(doc) (doc->ChipID == DOC_ChipID_Doc2k)
... ... @@ -54,13 +54,9 @@
54 54 return 1;
55 55 }
56 56 off &= ~(nand->writesize - 1);
57   -#if 0
58   - i = nand_read_raw(nand, buf, off, nand->writesize, nand->oobsize);
59   -#else
60 57 size_t dummy;
61 58 loff_t addr = (loff_t) off;
62 59 i = nand->read(nand, addr, nand->writesize, &dummy, buf);
63   -#endif
64 60 if (i < 0) {
65 61 printf("Error (%d) reading page %08lx\n", i, off);
66 62 free(buf);
... ... @@ -199,7 +195,7 @@
199 195  
200 196 if (argc < 3) {
201 197 if ((nand_curr_device < 0) ||
202   - (nand_curr_device >= CFG_MAX_NAND_DEVICE))
  198 + (nand_curr_device >= CFG_MAX_NAND_DEVICE))
203 199 puts("\nno devices available\n");
204 200 else
205 201 printf("\nDevice %d: %s\n", nand_curr_device,
... ... @@ -226,11 +222,11 @@
226 222 }
227 223  
228 224 if (strcmp(cmd, "bad") != 0 && strcmp(cmd, "erase") != 0 &&
229   - strncmp(cmd, "dump", 4) != 0 &&
230   - strncmp(cmd, "read", 4) != 0 && strncmp(cmd, "write", 5) != 0 &&
231   - strcmp(cmd, "scrub") != 0 && strcmp(cmd, "markbad") != 0 &&
232   - strcmp(cmd, "biterr") != 0 &&
233   - strcmp(cmd, "lock") != 0 && strcmp(cmd, "unlock") != 0 )
  225 + strncmp(cmd, "dump", 4) != 0 &&
  226 + strncmp(cmd, "read", 4) != 0 && strncmp(cmd, "write", 5) != 0 &&
  227 + strcmp(cmd, "scrub") != 0 && strcmp(cmd, "markbad") != 0 &&
  228 + strcmp(cmd, "biterr") != 0 &&
  229 + strcmp(cmd, "lock") != 0 && strcmp(cmd, "unlock") != 0 )
234 230 goto usage;
235 231  
236 232 /* the following commands operate on the current device */
... ... @@ -257,7 +253,7 @@
257 253 if (strcmp(cmd, "erase") == 0 || strcmp(cmd, "scrub") == 0) {
258 254 nand_erase_options_t opts;
259 255 /* "clean" at index 2 means request to write cleanmarker */
260   - int clean = !strcmp("clean", argv[2]);
  256 + int clean = argc > 2 && !strcmp("clean", argv[2]);
261 257 int o = clean ? 3 : 2;
262 258 int scrub = !strcmp(cmd, "scrub");
263 259  
... ... @@ -267,7 +263,6 @@
267 263 return 1;
268 264  
269 265 memset(&opts, 0, sizeof(opts));
270   -
271 266 opts.offset = off;
272 267 opts.length = size;
273 268 opts.jffs2 = clean;
... ... @@ -331,7 +326,7 @@
331 326  
332 327 s = strchr(cmd, '.');
333 328 if (s != NULL &&
334   - (!strcmp(s, ".jffs2") || !strcmp(s, ".e") || !strcmp(s, ".i"))) {
  329 + (!strcmp(s, ".jffs2") || !strcmp(s, ".e") || !strcmp(s, ".i"))) {
335 330 if (read) {
336 331 /* read */
337 332 nand_read_options_t opts;
... ... @@ -340,7 +335,13 @@
340 335 opts.length = size;
341 336 opts.offset = off;
342 337 opts.quiet = quiet;
343   -/* ret = nand_read_opts(nand, &opts); */
  338 +/*
  339 + * ! BROKEN !
  340 + *
  341 + * TODO: Function must be implemented
  342 + *
  343 + * ret = nand_read_opts(nand, &opts);
  344 + */
344 345 } else {
345 346 /* write */
346 347 mtd_oob_ops_t opts;
347 348  
348 349  
349 350  
... ... @@ -404,12 +405,17 @@
404 405 if (!strcmp("status", argv[2]))
405 406 status = 1;
406 407 }
407   -
  408 +/*
  409 + * ! BROKEN !
  410 + *
  411 + * TODO: must be implemented and tested by someone with HW
  412 + */
  413 +#if 0
408 414 if (status) {
  415 + ulong block_start = 0;
409 416 ulong off;
410   -/* ulong block_start = 0;
411 417 int last_status = -1;
412   -*/
  418 +
413 419 struct nand_chip *nand_chip = nand->priv;
414 420 /* check the WP bit */
415 421 nand_chip->cmdfunc (nand, NAND_CMD_STATUS, -1, -1);
416 422  
417 423  
418 424  
419 425  
420 426  
421 427  
... ... @@ -418,37 +424,34 @@
418 424 "NOT " : ""));
419 425  
420 426 for (off = 0; off < nand->size; off += nand->writesize) {
421   -#if 0 /* must be fixed */
422 427 int s = nand_get_lock_status(nand, off);
423 428  
424 429 /* print message only if status has changed
425 430 * or at end of chip
426 431 */
427 432 if (off == nand->size - nand->writesize
428   - || (s != last_status && off != 0)) {
  433 + || (s != last_status && off != 0)) {
429 434  
430 435 printf("%08lx - %08lx: %8d pages %s%s%s\n",
431   - block_start,
432   - off-1,
433   - (off-block_start)/nand->writesize,
434   - ((last_status & NAND_LOCK_STATUS_TIGHT) ? "TIGHT " : ""),
435   - ((last_status & NAND_LOCK_STATUS_LOCK) ? "LOCK " : ""),
436   - ((last_status & NAND_LOCK_STATUS_UNLOCK) ? "UNLOCK " : ""));
  436 + block_start,
  437 + off-1,
  438 + (off-block_start)/nand->writesize,
  439 + ((last_status & NAND_LOCK_STATUS_TIGHT) ? "TIGHT " : ""),
  440 + ((last_status & NAND_LOCK_STATUS_LOCK) ? "LOCK " : ""),
  441 + ((last_status & NAND_LOCK_STATUS_UNLOCK) ? "UNLOCK " : ""));
437 442 }
438 443  
439 444 last_status = s;
440   -#endif
441 445 }
442 446 } else {
443   -#if 0 /* must be fixed */
444 447 if (!nand_lock(nand, tight)) {
445 448 puts("NAND flash successfully locked\n");
446 449 } else {
447 450 puts("Error locking NAND flash\n");
448 451 return 1;
449 452 }
450   -#endif
451 453 }
  454 +#endif
452 455 return 0;
453 456 }
454 457  
455 458  
... ... @@ -456,12 +459,17 @@
456 459 if (arg_off_size(argc - 2, argv + 2, nand, &off, &size) < 0)
457 460 return 1;
458 461  
459   -#if 0 /* must be fixed */
  462 +/*
  463 + * ! BROKEN !
  464 + *
  465 + * TODO: must be implemented and tested by someone with HW
  466 + */
  467 +#if 0
460 468 if (!nand_unlock(nand, off, size)) {
461 469 puts("NAND flash successfully unlocked\n");
462 470 } else {
463 471 puts("Error unlocking NAND flash, "
464   - "write and erase will probably fail\n");
  472 + "write and erase will probably fail\n");
465 473 return 1;
466 474 }
467 475 #endif
... ... @@ -542,6 +550,7 @@
542 550 puts ("** Unknown image type\n");
543 551 return 1;
544 552 }
  553 + show_boot_progress (57);
545 554  
546 555 r = nand_read(nand, offset, &cnt, (u_char *) addr);
547 556 if (r) {
548 557  
... ... @@ -697,10 +706,10 @@
697 706 void archflashwp(void *archdata, int wp);
698 707 #endif
699 708  
700   -#define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1)))
  709 +#define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1)))
701 710  
702   -#undef NAND_DEBUG
703   -#undef PSYCHO_DEBUG
  711 +#undef NAND_DEBUG
  712 +#undef PSYCHO_DEBUG
704 713  
705 714 /* ****************** WARNING *********************
706 715 * When ALLOW_ERASE_BAD_DEBUG is non-zero the erase command will
... ... @@ -715,7 +724,7 @@
715 724 * and attempting to program or erase bad blocks can affect
716 725 * the data in _other_ (good) blocks.
717 726 */
718   -#define ALLOW_ERASE_BAD_DEBUG 0
  727 +#define ALLOW_ERASE_BAD_DEBUG 0
719 728  
720 729 #define CONFIG_MTD_NAND_ECC /* enable ECC */
721 730 #define CONFIG_MTD_NAND_ECC_JFFS2
722 731  
... ... @@ -732,13 +741,13 @@
732 741 extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE];
733 742 extern int curr_device;
734 743 extern int nand_legacy_erase(struct nand_chip *nand, size_t ofs,
735   - size_t len, int clean);
  744 + size_t len, int clean);
736 745 extern int nand_legacy_rw(struct nand_chip *nand, int cmd, size_t start,
737 746 size_t len, size_t *retlen, u_char *buf);
738 747 extern void nand_print(struct nand_chip *nand);
739 748 extern void nand_print_bad(struct nand_chip *nand);
740 749 extern int nand_read_oob(struct nand_chip *nand, size_t ofs,
741   - size_t len, size_t *retlen, u_char *buf);
  750 + size_t len, size_t *retlen, u_char *buf);
742 751 extern int nand_write_oob(struct nand_chip *nand, size_t ofs,
743 752 size_t len, size_t *retlen, const u_char *buf);
744 753  
... ... @@ -873,7 +882,7 @@
873 882 else if (cmdtail && !strcmp (cmdtail, ".i")) {
874 883 cmd |= NANDRW_JFFS2; /* skip bad blocks (on read too) */
875 884 if (cmd & NANDRW_READ)
876   - cmd |= NANDRW_JFFS2_SKIP; /* skip bad blocks (on read too) */
  885 + cmd |= NANDRW_JFFS2_SKIP; /* skip bad blocks (on read too) */
877 886 }
878 887 #endif /* CFG_NAND_SKIP_BAD_DOT_I */
879 888 else if (cmdtail) {
... ... @@ -887,8 +896,7 @@
887 896  
888 897 ret = nand_legacy_rw (nand_dev_desc + curr_device,
889 898 cmd, off, size,
890   - &total,
891   - (u_char *) addr);
  899 + &total, (u_char *) addr);
892 900  
893 901 printf (" %d bytes %s: %s\n", total,
894 902 (cmd & NANDRW_READ) ? "read" : "written",
895 903  
896 904  
... ... @@ -923,15 +931,15 @@
923 931 }
924 932  
925 933 U_BOOT_CMD(
926   - nand, 5, 1, do_nand,
  934 + nand, 5, 1, do_nand,
927 935 "nand - legacy NAND sub-system\n",
928 936 "info - show available NAND devices\n"
929 937 "nand device [dev] - show or set current device\n"
930 938 "nand read[.jffs2[s]] addr off size\n"
931 939 "nand write[.jffs2] addr off size - read/write `size' bytes starting\n"
932   - " at offset `off' to/from memory address `addr'\n"
  940 + " at offset `off' to/from memory address `addr'\n"
933 941 "nand erase [clean] [off size] - erase `size' bytes from\n"
934   - " offset `off' (entire device if not specified)\n"
  942 + " offset `off' (entire device if not specified)\n"
935 943 "nand bad - show bad blocks\n"
936 944 "nand read.oob addr off size - read out-of-band data\n"
937 945 "nand write.oob addr off size - read out-of-band data\n"
... ... @@ -987,7 +995,7 @@
987 995 dev = simple_strtoul(boot_device, &ep, 16);
988 996  
989 997 if ((dev >= CFG_MAX_NAND_DEVICE) ||
990   - (nand_dev_desc[dev].ChipID == NAND_ChipID_UNKNOWN)) {
  998 + (nand_dev_desc[dev].ChipID == NAND_ChipID_UNKNOWN)) {
991 999 printf ("\n** Device %d not available\n", dev);
992 1000 show_boot_progress (-55);
993 1001 return 1;
... ... @@ -1072,7 +1080,7 @@
1072 1080 }
1073 1081  
1074 1082 U_BOOT_CMD(
1075   - nboot, 4, 1, do_nandboot,
  1083 + nboot, 4, 1, do_nandboot,
1076 1084 "nboot - boot from NAND device\n",
1077 1085 "loadAddr dev\n"
1078 1086 );