diff options
Diffstat (limited to 'drivers/mtd/onenand/onenand_base.c')
-rw-r--r-- | drivers/mtd/onenand/onenand_base.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c index 9e14a26ca4e8..000794c6caf5 100644 --- a/drivers/mtd/onenand/onenand_base.c +++ b/drivers/mtd/onenand/onenand_base.c | |||
@@ -836,9 +836,11 @@ static int onenand_transfer_auto_oob(struct mtd_info *mtd, uint8_t *buf, int col | |||
836 | int readcol = column; | 836 | int readcol = column; |
837 | int readend = column + thislen; | 837 | int readend = column + thislen; |
838 | int lastgap = 0; | 838 | int lastgap = 0; |
839 | unsigned int i; | ||
839 | uint8_t *oob_buf = this->oob_buf; | 840 | uint8_t *oob_buf = this->oob_buf; |
840 | 841 | ||
841 | for (free = this->ecclayout->oobfree; free->length; ++free) { | 842 | free = this->ecclayout->oobfree; |
843 | for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES && free->length; i++, free++) { | ||
842 | if (readcol >= lastgap) | 844 | if (readcol >= lastgap) |
843 | readcol += free->offset - lastgap; | 845 | readcol += free->offset - lastgap; |
844 | if (readend >= lastgap) | 846 | if (readend >= lastgap) |
@@ -846,7 +848,8 @@ static int onenand_transfer_auto_oob(struct mtd_info *mtd, uint8_t *buf, int col | |||
846 | lastgap = free->offset + free->length; | 848 | lastgap = free->offset + free->length; |
847 | } | 849 | } |
848 | this->read_bufferram(mtd, ONENAND_SPARERAM, oob_buf, 0, mtd->oobsize); | 850 | this->read_bufferram(mtd, ONENAND_SPARERAM, oob_buf, 0, mtd->oobsize); |
849 | for (free = this->ecclayout->oobfree; free->length; ++free) { | 851 | free = this->ecclayout->oobfree; |
852 | for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES && free->length; i++, free++) { | ||
850 | int free_end = free->offset + free->length; | 853 | int free_end = free->offset + free->length; |
851 | if (free->offset < readend && free_end > readcol) { | 854 | if (free->offset < readend && free_end > readcol) { |
852 | int st = max_t(int,free->offset,readcol); | 855 | int st = max_t(int,free->offset,readcol); |
@@ -854,7 +857,7 @@ static int onenand_transfer_auto_oob(struct mtd_info *mtd, uint8_t *buf, int col | |||
854 | int n = ed - st; | 857 | int n = ed - st; |
855 | memcpy(buf, oob_buf + st, n); | 858 | memcpy(buf, oob_buf + st, n); |
856 | buf += n; | 859 | buf += n; |
857 | } else | 860 | } else if (column == 0) |
858 | break; | 861 | break; |
859 | } | 862 | } |
860 | return 0; | 863 | return 0; |
@@ -1280,15 +1283,18 @@ static int onenand_fill_auto_oob(struct mtd_info *mtd, u_char *oob_buf, | |||
1280 | int writecol = column; | 1283 | int writecol = column; |
1281 | int writeend = column + thislen; | 1284 | int writeend = column + thislen; |
1282 | int lastgap = 0; | 1285 | int lastgap = 0; |
1286 | unsigned int i; | ||
1283 | 1287 | ||
1284 | for (free = this->ecclayout->oobfree; free->length; ++free) { | 1288 | free = this->ecclayout->oobfree; |
1289 | for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES && free->length; i++, free++) { | ||
1285 | if (writecol >= lastgap) | 1290 | if (writecol >= lastgap) |
1286 | writecol += free->offset - lastgap; | 1291 | writecol += free->offset - lastgap; |
1287 | if (writeend >= lastgap) | 1292 | if (writeend >= lastgap) |
1288 | writeend += free->offset - lastgap; | 1293 | writeend += free->offset - lastgap; |
1289 | lastgap = free->offset + free->length; | 1294 | lastgap = free->offset + free->length; |
1290 | } | 1295 | } |
1291 | for (free = this->ecclayout->oobfree; free->length; ++free) { | 1296 | free = this->ecclayout->oobfree; |
1297 | for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES && free->length; i++, free++) { | ||
1292 | int free_end = free->offset + free->length; | 1298 | int free_end = free->offset + free->length; |
1293 | if (free->offset < writeend && free_end > writecol) { | 1299 | if (free->offset < writeend && free_end > writecol) { |
1294 | int st = max_t(int,free->offset,writecol); | 1300 | int st = max_t(int,free->offset,writecol); |
@@ -1296,7 +1302,7 @@ static int onenand_fill_auto_oob(struct mtd_info *mtd, u_char *oob_buf, | |||
1296 | int n = ed - st; | 1302 | int n = ed - st; |
1297 | memcpy(oob_buf + st, buf, n); | 1303 | memcpy(oob_buf + st, buf, n); |
1298 | buf += n; | 1304 | buf += n; |
1299 | } else | 1305 | } else if (column == 0) |
1300 | break; | 1306 | break; |
1301 | } | 1307 | } |
1302 | return 0; | 1308 | return 0; |
@@ -2386,7 +2392,8 @@ int onenand_scan(struct mtd_info *mtd, int maxchips) | |||
2386 | * the out of band area | 2392 | * the out of band area |
2387 | */ | 2393 | */ |
2388 | this->ecclayout->oobavail = 0; | 2394 | this->ecclayout->oobavail = 0; |
2389 | for (i = 0; this->ecclayout->oobfree[i].length; i++) | 2395 | for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES && |
2396 | this->ecclayout->oobfree[i].length; i++) | ||
2390 | this->ecclayout->oobavail += | 2397 | this->ecclayout->oobavail += |
2391 | this->ecclayout->oobfree[i].length; | 2398 | this->ecclayout->oobfree[i].length; |
2392 | mtd->oobavail = this->ecclayout->oobavail; | 2399 | mtd->oobavail = this->ecclayout->oobavail; |