diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2005-11-07 06:16:07 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@mtd.linutronix.de> | 2005-11-07 08:18:56 -0500 |
commit | 182ec4eee397543101a6db8906ed88727d3f7e53 (patch) | |
tree | 0f6dd2c52697123702bdf0c3a7143537f947b060 /fs/jffs2/wbuf.c | |
parent | 97894cda5773e59bd13e87b72077751099419a9f (diff) |
[JFFS2] Clean up trailing white spaces
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'fs/jffs2/wbuf.c')
-rw-r--r-- | fs/jffs2/wbuf.c | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c index 44d8a894a41b..242cd53a970c 100644 --- a/fs/jffs2/wbuf.c +++ b/fs/jffs2/wbuf.c | |||
@@ -188,7 +188,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
188 | /* Find the first node to be recovered, by skipping over every | 188 | /* Find the first node to be recovered, by skipping over every |
189 | node which ends before the wbuf starts, or which is obsolete. */ | 189 | node which ends before the wbuf starts, or which is obsolete. */ |
190 | first_raw = &jeb->first_node; | 190 | first_raw = &jeb->first_node; |
191 | while (*first_raw && | 191 | while (*first_raw && |
192 | (ref_obsolete(*first_raw) || | 192 | (ref_obsolete(*first_raw) || |
193 | (ref_offset(*first_raw)+ref_totlen(c, jeb, *first_raw)) < c->wbuf_ofs)) { | 193 | (ref_offset(*first_raw)+ref_totlen(c, jeb, *first_raw)) < c->wbuf_ofs)) { |
194 | D1(printk(KERN_DEBUG "Skipping node at 0x%08x(%d)-0x%08x which is either before 0x%08x or obsolete\n", | 194 | D1(printk(KERN_DEBUG "Skipping node at 0x%08x(%d)-0x%08x which is either before 0x%08x or obsolete\n", |
@@ -237,7 +237,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
237 | ret = c->mtd->read_ecc(c->mtd, start, c->wbuf_ofs - start, &retlen, buf, NULL, c->oobinfo); | 237 | ret = c->mtd->read_ecc(c->mtd, start, c->wbuf_ofs - start, &retlen, buf, NULL, c->oobinfo); |
238 | else | 238 | else |
239 | ret = c->mtd->read(c->mtd, start, c->wbuf_ofs - start, &retlen, buf); | 239 | ret = c->mtd->read(c->mtd, start, c->wbuf_ofs - start, &retlen, buf); |
240 | 240 | ||
241 | if (ret == -EBADMSG && retlen == c->wbuf_ofs - start) { | 241 | if (ret == -EBADMSG && retlen == c->wbuf_ofs - start) { |
242 | /* ECC recovered */ | 242 | /* ECC recovered */ |
243 | ret = 0; | 243 | ret = 0; |
@@ -274,15 +274,15 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
274 | if (end-start >= c->wbuf_pagesize) { | 274 | if (end-start >= c->wbuf_pagesize) { |
275 | /* Need to do another write immediately, but it's possible | 275 | /* Need to do another write immediately, but it's possible |
276 | that this is just because the wbuf itself is completely | 276 | that this is just because the wbuf itself is completely |
277 | full, and there's nothing earlier read back from the | 277 | full, and there's nothing earlier read back from the |
278 | flash. Hence 'buf' isn't necessarily what we're writing | 278 | flash. Hence 'buf' isn't necessarily what we're writing |
279 | from. */ | 279 | from. */ |
280 | unsigned char *rewrite_buf = buf?:c->wbuf; | 280 | unsigned char *rewrite_buf = buf?:c->wbuf; |
281 | uint32_t towrite = (end-start) - ((end-start)%c->wbuf_pagesize); | 281 | uint32_t towrite = (end-start) - ((end-start)%c->wbuf_pagesize); |
282 | 282 | ||
283 | D1(printk(KERN_DEBUG "Write 0x%x bytes at 0x%08x in wbuf recover\n", | 283 | D1(printk(KERN_DEBUG "Write 0x%x bytes at 0x%08x in wbuf recover\n", |
284 | towrite, ofs)); | 284 | towrite, ofs)); |
285 | 285 | ||
286 | #ifdef BREAKMEHEADER | 286 | #ifdef BREAKMEHEADER |
287 | static int breakme; | 287 | static int breakme; |
288 | if (breakme++ == 20) { | 288 | if (breakme++ == 20) { |
@@ -434,7 +434,7 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
434 | this happens, if we have a change to a new block, | 434 | this happens, if we have a change to a new block, |
435 | or if fsync forces us to flush the writebuffer. | 435 | or if fsync forces us to flush the writebuffer. |
436 | if we have a switch to next page, we will not have | 436 | if we have a switch to next page, we will not have |
437 | enough remaining space for this. | 437 | enough remaining space for this. |
438 | */ | 438 | */ |
439 | if (pad ) { | 439 | if (pad ) { |
440 | c->wbuf_len = PAD(c->wbuf_len); | 440 | c->wbuf_len = PAD(c->wbuf_len); |
@@ -442,7 +442,7 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
442 | /* Pad with JFFS2_DIRTY_BITMASK initially. this helps out ECC'd NOR | 442 | /* Pad with JFFS2_DIRTY_BITMASK initially. this helps out ECC'd NOR |
443 | with 8 byte page size */ | 443 | with 8 byte page size */ |
444 | memset(c->wbuf + c->wbuf_len, 0, c->wbuf_pagesize - c->wbuf_len); | 444 | memset(c->wbuf + c->wbuf_len, 0, c->wbuf_pagesize - c->wbuf_len); |
445 | 445 | ||
446 | if ( c->wbuf_len + sizeof(struct jffs2_unknown_node) < c->wbuf_pagesize) { | 446 | if ( c->wbuf_len + sizeof(struct jffs2_unknown_node) < c->wbuf_pagesize) { |
447 | struct jffs2_unknown_node *padnode = (void *)(c->wbuf + c->wbuf_len); | 447 | struct jffs2_unknown_node *padnode = (void *)(c->wbuf + c->wbuf_len); |
448 | padnode->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); | 448 | padnode->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); |
@@ -453,7 +453,7 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
453 | } | 453 | } |
454 | /* else jffs2_flash_writev has actually filled in the rest of the | 454 | /* else jffs2_flash_writev has actually filled in the rest of the |
455 | buffer for us, and will deal with the node refs etc. later. */ | 455 | buffer for us, and will deal with the node refs etc. later. */ |
456 | 456 | ||
457 | #ifdef BREAKME | 457 | #ifdef BREAKME |
458 | static int breakme; | 458 | static int breakme; |
459 | if (breakme++ == 20) { | 459 | if (breakme++ == 20) { |
@@ -462,9 +462,9 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
462 | c->mtd->write_ecc(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, | 462 | c->mtd->write_ecc(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, |
463 | &retlen, brokenbuf, NULL, c->oobinfo); | 463 | &retlen, brokenbuf, NULL, c->oobinfo); |
464 | ret = -EIO; | 464 | ret = -EIO; |
465 | } else | 465 | } else |
466 | #endif | 466 | #endif |
467 | 467 | ||
468 | if (jffs2_cleanmarker_oob(c)) | 468 | if (jffs2_cleanmarker_oob(c)) |
469 | ret = c->mtd->write_ecc(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, &retlen, c->wbuf, NULL, c->oobinfo); | 469 | ret = c->mtd->write_ecc(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, &retlen, c->wbuf, NULL, c->oobinfo); |
470 | else | 470 | else |
@@ -485,7 +485,7 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
485 | } | 485 | } |
486 | 486 | ||
487 | spin_lock(&c->erase_completion_lock); | 487 | spin_lock(&c->erase_completion_lock); |
488 | 488 | ||
489 | /* Adjust free size of the block if we padded. */ | 489 | /* Adjust free size of the block if we padded. */ |
490 | if (pad) { | 490 | if (pad) { |
491 | struct jffs2_eraseblock *jeb; | 491 | struct jffs2_eraseblock *jeb; |
@@ -495,7 +495,7 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
495 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf() adjusting free_size of %sblock at %08x\n", | 495 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf() adjusting free_size of %sblock at %08x\n", |
496 | (jeb==c->nextblock)?"next":"", jeb->offset)); | 496 | (jeb==c->nextblock)?"next":"", jeb->offset)); |
497 | 497 | ||
498 | /* wbuf_pagesize - wbuf_len is the amount of space that's to be | 498 | /* wbuf_pagesize - wbuf_len is the amount of space that's to be |
499 | padded. If there is less free space in the block than that, | 499 | padded. If there is less free space in the block than that, |
500 | something screwed up */ | 500 | something screwed up */ |
501 | if (jeb->free_size < (c->wbuf_pagesize - c->wbuf_len)) { | 501 | if (jeb->free_size < (c->wbuf_pagesize - c->wbuf_len)) { |
@@ -523,9 +523,9 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
523 | return 0; | 523 | return 0; |
524 | } | 524 | } |
525 | 525 | ||
526 | /* Trigger garbage collection to flush the write-buffer. | 526 | /* Trigger garbage collection to flush the write-buffer. |
527 | If ino arg is zero, do it if _any_ real (i.e. not GC) writes are | 527 | If ino arg is zero, do it if _any_ real (i.e. not GC) writes are |
528 | outstanding. If ino arg non-zero, do it only if a write for the | 528 | outstanding. If ino arg non-zero, do it only if a write for the |
529 | given inode is outstanding. */ | 529 | given inode is outstanding. */ |
530 | int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | 530 | int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) |
531 | { | 531 | { |
@@ -620,13 +620,13 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, unsig | |||
620 | /* If not NAND flash, don't bother */ | 620 | /* If not NAND flash, don't bother */ |
621 | if (!jffs2_is_writebuffered(c)) | 621 | if (!jffs2_is_writebuffered(c)) |
622 | return jffs2_flash_direct_writev(c, invecs, count, to, retlen); | 622 | return jffs2_flash_direct_writev(c, invecs, count, to, retlen); |
623 | 623 | ||
624 | down_write(&c->wbuf_sem); | 624 | down_write(&c->wbuf_sem); |
625 | 625 | ||
626 | /* If wbuf_ofs is not initialized, set it to target address */ | 626 | /* If wbuf_ofs is not initialized, set it to target address */ |
627 | if (c->wbuf_ofs == 0xFFFFFFFF) { | 627 | if (c->wbuf_ofs == 0xFFFFFFFF) { |
628 | c->wbuf_ofs = PAGE_DIV(to); | 628 | c->wbuf_ofs = PAGE_DIV(to); |
629 | c->wbuf_len = PAGE_MOD(to); | 629 | c->wbuf_len = PAGE_MOD(to); |
630 | memset(c->wbuf,0xff,c->wbuf_pagesize); | 630 | memset(c->wbuf,0xff,c->wbuf_pagesize); |
631 | } | 631 | } |
632 | 632 | ||
@@ -640,10 +640,10 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, unsig | |||
640 | memset(c->wbuf,0xff,c->wbuf_pagesize); | 640 | memset(c->wbuf,0xff,c->wbuf_pagesize); |
641 | } | 641 | } |
642 | } | 642 | } |
643 | 643 | ||
644 | /* Sanity checks on target address. | 644 | /* Sanity checks on target address. |
645 | It's permitted to write at PAD(c->wbuf_len+c->wbuf_ofs), | 645 | It's permitted to write at PAD(c->wbuf_len+c->wbuf_ofs), |
646 | and it's permitted to write at the beginning of a new | 646 | and it's permitted to write at the beginning of a new |
647 | erase block. Anything else, and you die. | 647 | erase block. Anything else, and you die. |
648 | New block starts at xxx000c (0-b = block header) | 648 | New block starts at xxx000c (0-b = block header) |
649 | */ | 649 | */ |
@@ -661,8 +661,8 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, unsig | |||
661 | } | 661 | } |
662 | /* set pointer to new block */ | 662 | /* set pointer to new block */ |
663 | c->wbuf_ofs = PAGE_DIV(to); | 663 | c->wbuf_ofs = PAGE_DIV(to); |
664 | c->wbuf_len = PAGE_MOD(to); | 664 | c->wbuf_len = PAGE_MOD(to); |
665 | } | 665 | } |
666 | 666 | ||
667 | if (to != PAD(c->wbuf_ofs + c->wbuf_len)) { | 667 | if (to != PAD(c->wbuf_ofs + c->wbuf_len)) { |
668 | /* We're not writing immediately after the writebuffer. Bad. */ | 668 | /* We're not writing immediately after the writebuffer. Bad. */ |
@@ -682,21 +682,21 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, unsig | |||
682 | invec = 0; | 682 | invec = 0; |
683 | outvec = 0; | 683 | outvec = 0; |
684 | 684 | ||
685 | /* Fill writebuffer first, if already in use */ | 685 | /* Fill writebuffer first, if already in use */ |
686 | if (c->wbuf_len) { | 686 | if (c->wbuf_len) { |
687 | uint32_t invec_ofs = 0; | 687 | uint32_t invec_ofs = 0; |
688 | 688 | ||
689 | /* adjust alignment offset */ | 689 | /* adjust alignment offset */ |
690 | if (c->wbuf_len != PAGE_MOD(to)) { | 690 | if (c->wbuf_len != PAGE_MOD(to)) { |
691 | c->wbuf_len = PAGE_MOD(to); | 691 | c->wbuf_len = PAGE_MOD(to); |
692 | /* take care of alignment to next page */ | 692 | /* take care of alignment to next page */ |
693 | if (!c->wbuf_len) | 693 | if (!c->wbuf_len) |
694 | c->wbuf_len = c->wbuf_pagesize; | 694 | c->wbuf_len = c->wbuf_pagesize; |
695 | } | 695 | } |
696 | 696 | ||
697 | while(c->wbuf_len < c->wbuf_pagesize) { | 697 | while(c->wbuf_len < c->wbuf_pagesize) { |
698 | uint32_t thislen; | 698 | uint32_t thislen; |
699 | 699 | ||
700 | if (invec == count) | 700 | if (invec == count) |
701 | goto alldone; | 701 | goto alldone; |
702 | 702 | ||
@@ -704,17 +704,17 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, unsig | |||
704 | 704 | ||
705 | if (thislen >= invecs[invec].iov_len) | 705 | if (thislen >= invecs[invec].iov_len) |
706 | thislen = invecs[invec].iov_len; | 706 | thislen = invecs[invec].iov_len; |
707 | 707 | ||
708 | invec_ofs = thislen; | 708 | invec_ofs = thislen; |
709 | 709 | ||
710 | memcpy(c->wbuf + c->wbuf_len, invecs[invec].iov_base, thislen); | 710 | memcpy(c->wbuf + c->wbuf_len, invecs[invec].iov_base, thislen); |
711 | c->wbuf_len += thislen; | 711 | c->wbuf_len += thislen; |
712 | donelen += thislen; | 712 | donelen += thislen; |
713 | /* Get next invec, if actual did not fill the buffer */ | 713 | /* Get next invec, if actual did not fill the buffer */ |
714 | if (c->wbuf_len < c->wbuf_pagesize) | 714 | if (c->wbuf_len < c->wbuf_pagesize) |
715 | invec++; | 715 | invec++; |
716 | } | 716 | } |
717 | 717 | ||
718 | /* write buffer is full, flush buffer */ | 718 | /* write buffer is full, flush buffer */ |
719 | ret = __jffs2_flush_wbuf(c, NOPAD); | 719 | ret = __jffs2_flush_wbuf(c, NOPAD); |
720 | if (ret) { | 720 | if (ret) { |
@@ -773,10 +773,10 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, unsig | |||
773 | 773 | ||
774 | /* We did cross a page boundary, so we write some now */ | 774 | /* We did cross a page boundary, so we write some now */ |
775 | if (jffs2_cleanmarker_oob(c)) | 775 | if (jffs2_cleanmarker_oob(c)) |
776 | ret = c->mtd->writev_ecc(c->mtd, outvecs, splitvec+1, outvec_to, &wbuf_retlen, NULL, c->oobinfo); | 776 | ret = c->mtd->writev_ecc(c->mtd, outvecs, splitvec+1, outvec_to, &wbuf_retlen, NULL, c->oobinfo); |
777 | else | 777 | else |
778 | ret = jffs2_flash_direct_writev(c, outvecs, splitvec+1, outvec_to, &wbuf_retlen); | 778 | ret = jffs2_flash_direct_writev(c, outvecs, splitvec+1, outvec_to, &wbuf_retlen); |
779 | 779 | ||
780 | if (ret < 0 || wbuf_retlen != PAGE_DIV(totlen)) { | 780 | if (ret < 0 || wbuf_retlen != PAGE_DIV(totlen)) { |
781 | /* At this point we have no problem, | 781 | /* At this point we have no problem, |
782 | c->wbuf is empty. However refile nextblock to avoid | 782 | c->wbuf is empty. However refile nextblock to avoid |
@@ -793,7 +793,7 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, unsig | |||
793 | spin_unlock(&c->erase_completion_lock); | 793 | spin_unlock(&c->erase_completion_lock); |
794 | goto exit; | 794 | goto exit; |
795 | } | 795 | } |
796 | 796 | ||
797 | donelen += wbuf_retlen; | 797 | donelen += wbuf_retlen; |
798 | c->wbuf_ofs = PAGE_DIV(outvec_to) + PAGE_DIV(totlen); | 798 | c->wbuf_ofs = PAGE_DIV(outvec_to) + PAGE_DIV(totlen); |
799 | 799 | ||
@@ -837,7 +837,7 @@ alldone: | |||
837 | jffs2_wbuf_dirties_inode(c, ino); | 837 | jffs2_wbuf_dirties_inode(c, ino); |
838 | 838 | ||
839 | ret = 0; | 839 | ret = 0; |
840 | 840 | ||
841 | exit: | 841 | exit: |
842 | up_write(&c->wbuf_sem); | 842 | up_write(&c->wbuf_sem); |
843 | return ret; | 843 | return ret; |
@@ -880,18 +880,18 @@ int jffs2_flash_read(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *re | |||
880 | if ( (ret == -EBADMSG) && (*retlen == len) ) { | 880 | if ( (ret == -EBADMSG) && (*retlen == len) ) { |
881 | printk(KERN_WARNING "mtd->read(0x%zx bytes from 0x%llx) returned ECC error\n", | 881 | printk(KERN_WARNING "mtd->read(0x%zx bytes from 0x%llx) returned ECC error\n", |
882 | len, ofs); | 882 | len, ofs); |
883 | /* | 883 | /* |
884 | * We have the raw data without ECC correction in the buffer, maybe | 884 | * We have the raw data without ECC correction in the buffer, maybe |
885 | * we are lucky and all data or parts are correct. We check the node. | 885 | * we are lucky and all data or parts are correct. We check the node. |
886 | * If data are corrupted node check will sort it out. | 886 | * If data are corrupted node check will sort it out. |
887 | * We keep this block, it will fail on write or erase and the we | 887 | * We keep this block, it will fail on write or erase and the we |
888 | * mark it bad. Or should we do that now? But we should give him a chance. | 888 | * mark it bad. Or should we do that now? But we should give him a chance. |
889 | * Maybe we had a system crash or power loss before the ecc write or | 889 | * Maybe we had a system crash or power loss before the ecc write or |
890 | * a erase was completed. | 890 | * a erase was completed. |
891 | * So we return success. :) | 891 | * So we return success. :) |
892 | */ | 892 | */ |
893 | ret = 0; | 893 | ret = 0; |
894 | } | 894 | } |
895 | 895 | ||
896 | /* if no writebuffer available or write buffer empty, return */ | 896 | /* if no writebuffer available or write buffer empty, return */ |
897 | if (!c->wbuf_pagesize || !c->wbuf_len) | 897 | if (!c->wbuf_pagesize || !c->wbuf_len) |
@@ -906,16 +906,16 @@ int jffs2_flash_read(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *re | |||
906 | if (owbf > c->wbuf_len) /* is read beyond write buffer ? */ | 906 | if (owbf > c->wbuf_len) /* is read beyond write buffer ? */ |
907 | goto exit; | 907 | goto exit; |
908 | lwbf = c->wbuf_len - owbf; /* number of bytes to copy */ | 908 | lwbf = c->wbuf_len - owbf; /* number of bytes to copy */ |
909 | if (lwbf > len) | 909 | if (lwbf > len) |
910 | lwbf = len; | 910 | lwbf = len; |
911 | } else { | 911 | } else { |
912 | orbf = (c->wbuf_ofs - ofs); /* offset in read buffer */ | 912 | orbf = (c->wbuf_ofs - ofs); /* offset in read buffer */ |
913 | if (orbf > len) /* is write beyond write buffer ? */ | 913 | if (orbf > len) /* is write beyond write buffer ? */ |
914 | goto exit; | 914 | goto exit; |
915 | lwbf = len - orbf; /* number of bytes to copy */ | 915 | lwbf = len - orbf; /* number of bytes to copy */ |
916 | if (lwbf > c->wbuf_len) | 916 | if (lwbf > c->wbuf_len) |
917 | lwbf = c->wbuf_len; | 917 | lwbf = c->wbuf_len; |
918 | } | 918 | } |
919 | if (lwbf > 0) | 919 | if (lwbf > 0) |
920 | memcpy(buf+orbf,c->wbuf+owbf,lwbf); | 920 | memcpy(buf+orbf,c->wbuf+owbf,lwbf); |
921 | 921 | ||
@@ -943,7 +943,7 @@ int jffs2_check_oob_empty( struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb | |||
943 | printk(KERN_NOTICE "jffs2_check_oob_empty(): allocation of temporary data buffer for oob check failed\n"); | 943 | printk(KERN_NOTICE "jffs2_check_oob_empty(): allocation of temporary data buffer for oob check failed\n"); |
944 | return -ENOMEM; | 944 | return -ENOMEM; |
945 | } | 945 | } |
946 | /* | 946 | /* |
947 | * if mode = 0, we scan for a total empty oob area, else we have | 947 | * if mode = 0, we scan for a total empty oob area, else we have |
948 | * to take care of the cleanmarker in the first page of the block | 948 | * to take care of the cleanmarker in the first page of the block |
949 | */ | 949 | */ |
@@ -952,41 +952,41 @@ int jffs2_check_oob_empty( struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb | |||
952 | D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Read OOB failed %d for block at %08x\n", ret, jeb->offset)); | 952 | D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Read OOB failed %d for block at %08x\n", ret, jeb->offset)); |
953 | goto out; | 953 | goto out; |
954 | } | 954 | } |
955 | 955 | ||
956 | if (retlen < len) { | 956 | if (retlen < len) { |
957 | D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Read OOB return short read " | 957 | D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Read OOB return short read " |
958 | "(%zd bytes not %d) for block at %08x\n", retlen, len, jeb->offset)); | 958 | "(%zd bytes not %d) for block at %08x\n", retlen, len, jeb->offset)); |
959 | ret = -EIO; | 959 | ret = -EIO; |
960 | goto out; | 960 | goto out; |
961 | } | 961 | } |
962 | 962 | ||
963 | /* Special check for first page */ | 963 | /* Special check for first page */ |
964 | for(i = 0; i < oob_size ; i++) { | 964 | for(i = 0; i < oob_size ; i++) { |
965 | /* Yeah, we know about the cleanmarker. */ | 965 | /* Yeah, we know about the cleanmarker. */ |
966 | if (mode && i >= c->fsdata_pos && | 966 | if (mode && i >= c->fsdata_pos && |
967 | i < c->fsdata_pos + c->fsdata_len) | 967 | i < c->fsdata_pos + c->fsdata_len) |
968 | continue; | 968 | continue; |
969 | 969 | ||
970 | if (buf[i] != 0xFF) { | 970 | if (buf[i] != 0xFF) { |
971 | D2(printk(KERN_DEBUG "Found %02x at %x in OOB for %08x\n", | 971 | D2(printk(KERN_DEBUG "Found %02x at %x in OOB for %08x\n", |
972 | buf[i], i, jeb->offset)); | 972 | buf[i], i, jeb->offset)); |
973 | ret = 1; | 973 | ret = 1; |
974 | goto out; | 974 | goto out; |
975 | } | 975 | } |
976 | } | 976 | } |
977 | 977 | ||
978 | /* we know, we are aligned :) */ | 978 | /* we know, we are aligned :) */ |
979 | for (page = oob_size; page < len; page += sizeof(long)) { | 979 | for (page = oob_size; page < len; page += sizeof(long)) { |
980 | unsigned long dat = *(unsigned long *)(&buf[page]); | 980 | unsigned long dat = *(unsigned long *)(&buf[page]); |
981 | if(dat != -1) { | 981 | if(dat != -1) { |
982 | ret = 1; | 982 | ret = 1; |
983 | goto out; | 983 | goto out; |
984 | } | 984 | } |
985 | } | 985 | } |
986 | 986 | ||
987 | out: | 987 | out: |
988 | kfree(buf); | 988 | kfree(buf); |
989 | 989 | ||
990 | return ret; | 990 | return ret; |
991 | } | 991 | } |
992 | 992 | ||
@@ -1068,7 +1068,7 @@ int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c, struct jffs2_erasebloc | |||
1068 | n.totlen = cpu_to_je32(8); | 1068 | n.totlen = cpu_to_je32(8); |
1069 | 1069 | ||
1070 | ret = jffs2_flash_write_oob(c, jeb->offset + c->fsdata_pos, c->fsdata_len, &retlen, (unsigned char *)&n); | 1070 | ret = jffs2_flash_write_oob(c, jeb->offset + c->fsdata_pos, c->fsdata_len, &retlen, (unsigned char *)&n); |
1071 | 1071 | ||
1072 | if (ret) { | 1072 | if (ret) { |
1073 | D1(printk(KERN_WARNING "jffs2_write_nand_cleanmarker(): Write failed for block at %08x: error %d\n", jeb->offset, ret)); | 1073 | D1(printk(KERN_WARNING "jffs2_write_nand_cleanmarker(): Write failed for block at %08x: error %d\n", jeb->offset, ret)); |
1074 | return ret; | 1074 | return ret; |
@@ -1080,7 +1080,7 @@ int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c, struct jffs2_erasebloc | |||
1080 | return 0; | 1080 | return 0; |
1081 | } | 1081 | } |
1082 | 1082 | ||
1083 | /* | 1083 | /* |
1084 | * On NAND we try to mark this block bad. If the block was erased more | 1084 | * On NAND we try to mark this block bad. If the block was erased more |
1085 | * than MAX_ERASE_FAILURES we mark it finaly bad. | 1085 | * than MAX_ERASE_FAILURES we mark it finaly bad. |
1086 | * Don't care about failures. This block remains on the erase-pending | 1086 | * Don't care about failures. This block remains on the erase-pending |
@@ -1101,7 +1101,7 @@ int jffs2_write_nand_badblock(struct jffs2_sb_info *c, struct jffs2_eraseblock * | |||
1101 | 1101 | ||
1102 | D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Marking bad block at %08x\n", bad_offset)); | 1102 | D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Marking bad block at %08x\n", bad_offset)); |
1103 | ret = c->mtd->block_markbad(c->mtd, bad_offset); | 1103 | ret = c->mtd->block_markbad(c->mtd, bad_offset); |
1104 | 1104 | ||
1105 | if (ret) { | 1105 | if (ret) { |
1106 | D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Write failed for block at %08x: error %d\n", jeb->offset, ret)); | 1106 | D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Write failed for block at %08x: error %d\n", jeb->offset, ret)); |
1107 | return ret; | 1107 | return ret; |
@@ -1125,7 +1125,7 @@ static int jffs2_nand_set_oobinfo(struct jffs2_sb_info *c) | |||
1125 | /* Do this only, if we have an oob buffer */ | 1125 | /* Do this only, if we have an oob buffer */ |
1126 | if (!c->mtd->oobsize) | 1126 | if (!c->mtd->oobsize) |
1127 | return 0; | 1127 | return 0; |
1128 | 1128 | ||
1129 | /* Cleanmarker is out-of-band, so inline size zero */ | 1129 | /* Cleanmarker is out-of-band, so inline size zero */ |
1130 | c->cleanmarker_size = 0; | 1130 | c->cleanmarker_size = 0; |
1131 | 1131 | ||
@@ -1151,7 +1151,7 @@ static int jffs2_nand_set_oobinfo(struct jffs2_sb_info *c) | |||
1151 | c->fsdata_len = NAND_JFFS2_OOB16_FSDALEN; | 1151 | c->fsdata_len = NAND_JFFS2_OOB16_FSDALEN; |
1152 | c->badblock_pos = 15; | 1152 | c->badblock_pos = 15; |
1153 | break; | 1153 | break; |
1154 | 1154 | ||
1155 | default: | 1155 | default: |
1156 | D1(printk(KERN_DEBUG "JFFS2 on NAND. No autoplacment info found\n")); | 1156 | D1(printk(KERN_DEBUG "JFFS2 on NAND. No autoplacment info found\n")); |
1157 | return -EINVAL; | 1157 | return -EINVAL; |
@@ -1168,7 +1168,7 @@ int jffs2_nand_flash_setup(struct jffs2_sb_info *c) | |||
1168 | init_rwsem(&c->wbuf_sem); | 1168 | init_rwsem(&c->wbuf_sem); |
1169 | c->wbuf_pagesize = c->mtd->oobblock; | 1169 | c->wbuf_pagesize = c->mtd->oobblock; |
1170 | c->wbuf_ofs = 0xFFFFFFFF; | 1170 | c->wbuf_ofs = 0xFFFFFFFF; |
1171 | 1171 | ||
1172 | c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL); | 1172 | c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL); |
1173 | if (!c->wbuf) | 1173 | if (!c->wbuf) |
1174 | return -ENOMEM; | 1174 | return -ENOMEM; |
@@ -1194,13 +1194,13 @@ void jffs2_nand_flash_cleanup(struct jffs2_sb_info *c) | |||
1194 | 1194 | ||
1195 | int jffs2_dataflash_setup(struct jffs2_sb_info *c) { | 1195 | int jffs2_dataflash_setup(struct jffs2_sb_info *c) { |
1196 | c->cleanmarker_size = 0; /* No cleanmarkers needed */ | 1196 | c->cleanmarker_size = 0; /* No cleanmarkers needed */ |
1197 | 1197 | ||
1198 | /* Initialize write buffer */ | 1198 | /* Initialize write buffer */ |
1199 | init_rwsem(&c->wbuf_sem); | 1199 | init_rwsem(&c->wbuf_sem); |
1200 | 1200 | ||
1201 | 1201 | ||
1202 | c->wbuf_pagesize = c->mtd->erasesize; | 1202 | c->wbuf_pagesize = c->mtd->erasesize; |
1203 | 1203 | ||
1204 | /* Find a suitable c->sector_size | 1204 | /* Find a suitable c->sector_size |
1205 | * - Not too much sectors | 1205 | * - Not too much sectors |
1206 | * - Sectors have to be at least 4 K + some bytes | 1206 | * - Sectors have to be at least 4 K + some bytes |
@@ -1210,11 +1210,11 @@ int jffs2_dataflash_setup(struct jffs2_sb_info *c) { | |||
1210 | */ | 1210 | */ |
1211 | 1211 | ||
1212 | c->sector_size = 8 * c->mtd->erasesize; | 1212 | c->sector_size = 8 * c->mtd->erasesize; |
1213 | 1213 | ||
1214 | while (c->sector_size < 8192) { | 1214 | while (c->sector_size < 8192) { |
1215 | c->sector_size *= 2; | 1215 | c->sector_size *= 2; |
1216 | } | 1216 | } |
1217 | 1217 | ||
1218 | /* It may be necessary to adjust the flash size */ | 1218 | /* It may be necessary to adjust the flash size */ |
1219 | c->flash_size = c->mtd->size; | 1219 | c->flash_size = c->mtd->size; |
1220 | 1220 | ||
@@ -1222,7 +1222,7 @@ int jffs2_dataflash_setup(struct jffs2_sb_info *c) { | |||
1222 | c->flash_size = (c->flash_size / c->sector_size) * c->sector_size; | 1222 | c->flash_size = (c->flash_size / c->sector_size) * c->sector_size; |
1223 | printk(KERN_WARNING "JFFS2 flash size adjusted to %dKiB\n", c->flash_size); | 1223 | printk(KERN_WARNING "JFFS2 flash size adjusted to %dKiB\n", c->flash_size); |
1224 | }; | 1224 | }; |
1225 | 1225 | ||
1226 | c->wbuf_ofs = 0xFFFFFFFF; | 1226 | c->wbuf_ofs = 0xFFFFFFFF; |
1227 | c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL); | 1227 | c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL); |
1228 | if (!c->wbuf) | 1228 | if (!c->wbuf) |