[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>
This commit is contained in:

committed by
David Woodhouse

parent
1918767299
commit
7014568bad
@@ -247,7 +247,7 @@ concat_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)
|
||||
struct mtd_oob_ops devops = *ops;
|
||||
int i, err, ret = 0;
|
||||
|
||||
ops->retlen = 0;
|
||||
ops->retlen = ops->oobretlen = 0;
|
||||
|
||||
for (i = 0; i < concat->num_subdev; i++) {
|
||||
struct mtd_info *subdev = concat->subdev[i];
|
||||
@@ -263,6 +263,7 @@ concat_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)
|
||||
|
||||
err = subdev->read_oob(subdev, from, &devops);
|
||||
ops->retlen += devops.retlen;
|
||||
ops->oobretlen += devops.oobretlen;
|
||||
|
||||
/* Save information about bitflips! */
|
||||
if (unlikely(err)) {
|
||||
@@ -278,14 +279,18 @@ concat_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)
|
||||
return err;
|
||||
}
|
||||
|
||||
devops.len = ops->len - ops->retlen;
|
||||
if (!devops.len)
|
||||
return ret;
|
||||
|
||||
if (devops.datbuf)
|
||||
if (devops.datbuf) {
|
||||
devops.len = ops->len - ops->retlen;
|
||||
if (!devops.len)
|
||||
return ret;
|
||||
devops.datbuf += devops.retlen;
|
||||
if (devops.oobbuf)
|
||||
devops.oobbuf += devops.ooblen;
|
||||
}
|
||||
if (devops.oobbuf) {
|
||||
devops.ooblen = ops->ooblen - ops->oobretlen;
|
||||
if (!devops.ooblen)
|
||||
return ret;
|
||||
devops.oobbuf += ops->oobretlen;
|
||||
}
|
||||
|
||||
from = 0;
|
||||
}
|
||||
@@ -321,14 +326,18 @@ concat_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops)
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
devops.len = ops->len - ops->retlen;
|
||||
if (!devops.len)
|
||||
return 0;
|
||||
|
||||
if (devops.datbuf)
|
||||
if (devops.datbuf) {
|
||||
devops.len = ops->len - ops->retlen;
|
||||
if (!devops.len)
|
||||
return 0;
|
||||
devops.datbuf += devops.retlen;
|
||||
if (devops.oobbuf)
|
||||
devops.oobbuf += devops.ooblen;
|
||||
}
|
||||
if (devops.oobbuf) {
|
||||
devops.ooblen = ops->ooblen - ops->oobretlen;
|
||||
if (!devops.ooblen)
|
||||
return 0;
|
||||
devops.oobbuf += devops.oobretlen;
|
||||
}
|
||||
to = 0;
|
||||
}
|
||||
return -EINVAL;
|
||||
|
Reference in New Issue
Block a user