Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 298163
b: refs/heads/master
c: d107bc3
h: refs/heads/master
i:
  298161: 1996229
  298159: 1372475
v: v3
  • Loading branch information
Robert Jarzmik authored and David Woodhouse committed Mar 26, 2012
1 parent a41990f commit df734b6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cfe781946dac7f5ff42e23cd7054c75e7201fbdc
refs/heads/master: d107bc34f4953852834f086968fc7963125d6943
21 changes: 13 additions & 8 deletions trunk/drivers/mtd/devices/docg3.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ static int doc_read_page_prepare(struct docg3 *docg3, int block0, int block1,
* doc_read_page_getbytes - Reads bytes from a prepared page
* @docg3: the device
* @len: the number of bytes to be read (must be a multiple of 4)
* @buf: the buffer to be filled in
* @buf: the buffer to be filled in (or NULL is forget bytes)
* @first: 1 if first time read, DOC_READADDRESS should be set
*
*/
Expand Down Expand Up @@ -849,7 +849,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t from,
struct mtd_oob_ops *ops)
{
struct docg3 *docg3 = mtd->priv;
int block0, block1, page, ret, ofs = 0;
int block0, block1, page, ret, skip, ofs = 0;
u8 *oobbuf = ops->oobbuf;
u8 *buf = ops->datbuf;
size_t len, ooblen, nbdata, nboob;
Expand All @@ -869,8 +869,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t from,

doc_dbg("doc_read_oob(from=%lld, mode=%d, data=(%p:%zu), oob=(%p:%zu))\n",
from, ops->mode, buf, len, oobbuf, ooblen);
if ((len % DOC_LAYOUT_PAGE_SIZE) || (ooblen % DOC_LAYOUT_OOB_SIZE) ||
(from % DOC_LAYOUT_PAGE_SIZE))
if (ooblen % DOC_LAYOUT_OOB_SIZE)
return -EINVAL;

ret = -EINVAL;
Expand All @@ -882,21 +881,26 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t from,
ops->oobretlen = 0;
ops->retlen = 0;
ret = 0;
skip = from % DOC_LAYOUT_PAGE_SIZE;
while (!ret && (len > 0 || ooblen > 0)) {
calc_block_sector(from, &block0, &block1, &page, &ofs,
calc_block_sector(from - skip, &block0, &block1, &page, &ofs,
docg3->reliable);
nbdata = min_t(size_t, len, (size_t)DOC_LAYOUT_PAGE_SIZE);
nbdata = min_t(size_t, len, DOC_LAYOUT_PAGE_SIZE - skip);
nboob = min_t(size_t, ooblen, (size_t)DOC_LAYOUT_OOB_SIZE);
ret = doc_read_page_prepare(docg3, block0, block1, page, ofs);
if (ret < 0)
goto err;
ret = doc_read_page_ecc_init(docg3, DOC_ECC_BCH_TOTAL_BYTES);
if (ret < 0)
goto err_in_read;
ret = doc_read_page_getbytes(docg3, nbdata, buf, 1);
ret = doc_read_page_getbytes(docg3, skip, NULL, 1);
if (ret < skip)
goto err_in_read;
ret = doc_read_page_getbytes(docg3, nbdata, buf, 0);
if (ret < nbdata)
goto err_in_read;
doc_read_page_getbytes(docg3, DOC_LAYOUT_PAGE_SIZE - nbdata,
doc_read_page_getbytes(docg3,
DOC_LAYOUT_PAGE_SIZE - nbdata - skip,
NULL, 0);
ret = doc_read_page_getbytes(docg3, nboob, oobbuf, 0);
if (ret < nboob)
Expand Down Expand Up @@ -950,6 +954,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t from,
len -= nbdata;
ooblen -= nboob;
from += DOC_LAYOUT_PAGE_SIZE;
skip = 0;
}

return ret;
Expand Down

0 comments on commit df734b6

Please sign in to comment.