aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorVitaly Wool <vwool@ru.mvista.com>2006-11-03 10:20:38 -0500
committerDavid Woodhouse <dwmw2@infradead.org>2006-11-28 17:39:03 -0500
commit7014568bad55c20b7ee4f439d78c9e875912d51f (patch)
tree1b558ef8d77d31925cc396ed69d8f785615cf09f /fs
parent191876729901d0c8dab8a331f9a1e4b73a56457b (diff)
[MTD] [NAND] remove len/ooblen confusion.
As was discussed between Ricard Wanderlöf, David Woodhouse, Artem Bityutskiy and me, the current API for reading/writing OOB is confusing. The thing that introduces confusion is the need to specify ops.len together with ops.ooblen for reads/writes that concern only OOB not data area. So, ops.len is overloaded: when ops.datbuf != NULL it serves to specify the length of the data read, and when ops.datbuf == NULL, it serves to specify the full OOB read length. The patch inlined below is the slightly updated version of the previous patch serving the same purpose, but with the new Artem's comments taken into account. Artem, BTW, thanks a lot for your valuable input! Signed-off-by: Vitaly Wool <vwool@ru.mvista.com> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/jffs2/wbuf.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
index b9b700730dfe..dcb18e9a646e 100644
--- a/fs/jffs2/wbuf.c
+++ b/fs/jffs2/wbuf.c
@@ -968,8 +968,7 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c,
968 int oobsize = c->mtd->oobsize; 968 int oobsize = c->mtd->oobsize;
969 struct mtd_oob_ops ops; 969 struct mtd_oob_ops ops;
970 970
971 ops.len = NR_OOB_SCAN_PAGES * oobsize; 971 ops.ooblen = NR_OOB_SCAN_PAGES * oobsize;
972 ops.ooblen = oobsize;
973 ops.oobbuf = c->oobbuf; 972 ops.oobbuf = c->oobbuf;
974 ops.ooboffs = 0; 973 ops.ooboffs = 0;
975 ops.datbuf = NULL; 974 ops.datbuf = NULL;
@@ -982,10 +981,10 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c,
982 return ret; 981 return ret;
983 } 982 }
984 983
985 if (ops.retlen < ops.len) { 984 if (ops.oobretlen < ops.ooblen) {
986 D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Read OOB " 985 D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Read OOB "
987 "returned short read (%zd bytes not %d) for block " 986 "returned short read (%zd bytes not %d) for block "
988 "at %08x\n", ops.retlen, ops.len, jeb->offset)); 987 "at %08x\n", ops.oobretlen, ops.ooblen, jeb->offset));
989 return -EIO; 988 return -EIO;
990 } 989 }
991 990
@@ -1004,7 +1003,7 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c,
1004 } 1003 }
1005 1004
1006 /* we know, we are aligned :) */ 1005 /* we know, we are aligned :) */
1007 for (page = oobsize; page < ops.len; page += sizeof(long)) { 1006 for (page = oobsize; page < ops.ooblen; page += sizeof(long)) {
1008 long dat = *(long *)(&ops.oobbuf[page]); 1007 long dat = *(long *)(&ops.oobbuf[page]);
1009 if(dat != -1) 1008 if(dat != -1)
1010 return 1; 1009 return 1;
@@ -1032,7 +1031,6 @@ int jffs2_check_nand_cleanmarker (struct jffs2_sb_info *c,
1032 return 2; 1031 return 2;
1033 } 1032 }
1034 1033
1035 ops.len = oobsize;
1036 ops.ooblen = oobsize; 1034 ops.ooblen = oobsize;
1037 ops.oobbuf = c->oobbuf; 1035 ops.oobbuf = c->oobbuf;
1038 ops.ooboffs = 0; 1036 ops.ooboffs = 0;
@@ -1047,10 +1045,10 @@ int jffs2_check_nand_cleanmarker (struct jffs2_sb_info *c,
1047 return ret; 1045 return ret;
1048 } 1046 }
1049 1047
1050 if (ops.retlen < ops.len) { 1048 if (ops.oobretlen < ops.ooblen) {
1051 D1 (printk (KERN_WARNING "jffs2_check_nand_cleanmarker(): " 1049 D1 (printk (KERN_WARNING "jffs2_check_nand_cleanmarker(): "
1052 "Read OOB return short read (%zd bytes not %d) " 1050 "Read OOB return short read (%zd bytes not %d) "
1053 "for block at %08x\n", ops.retlen, ops.len, 1051 "for block at %08x\n", ops.oobretlen, ops.ooblen,
1054 jeb->offset)); 1052 jeb->offset));
1055 return -EIO; 1053 return -EIO;
1056 } 1054 }
@@ -1089,8 +1087,7 @@ int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c,
1089 n.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER); 1087 n.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER);
1090 n.totlen = cpu_to_je32(8); 1088 n.totlen = cpu_to_je32(8);
1091 1089
1092 ops.len = c->fsdata_len; 1090 ops.ooblen = c->fsdata_len;
1093 ops.ooblen = c->fsdata_len;;
1094 ops.oobbuf = (uint8_t *)&n; 1091 ops.oobbuf = (uint8_t *)&n;
1095 ops.ooboffs = c->fsdata_pos; 1092 ops.ooboffs = c->fsdata_pos;
1096 ops.datbuf = NULL; 1093 ops.datbuf = NULL;
@@ -1104,10 +1101,10 @@ int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c,
1104 jeb->offset, ret)); 1101 jeb->offset, ret));
1105 return ret; 1102 return ret;
1106 } 1103 }
1107 if (ops.retlen != ops.len) { 1104 if (ops.oobretlen != ops.ooblen) {
1108 D1(printk(KERN_WARNING "jffs2_write_nand_cleanmarker(): " 1105 D1(printk(KERN_WARNING "jffs2_write_nand_cleanmarker(): "
1109 "Short write for block at %08x: %zd not %d\n", 1106 "Short write for block at %08x: %zd not %d\n",
1110 jeb->offset, ops.retlen, ops.len)); 1107 jeb->offset, ops.oobretlen, ops.ooblen));
1111 return -EIO; 1108 return -EIO;
1112 } 1109 }
1113 return 0; 1110 return 0;