diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-04-27 18:34:57 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-04-27 18:34:57 -0400 |
commit | f00546363fff1576ceddc2690d47e5f9c1dd2e05 (patch) | |
tree | f6cb8965b6754fc6ce7570cf1471ebe9874e509a /drivers/mtd/onenand/onenand_base.c | |
parent | 50f732ee63b91eb08a29974b36bd63e1150bb642 (diff) | |
parent | 28b57cddb3ed4f7999e4b76ef36ebaaf6e2e0c37 (diff) |
Merge git://git.infradead.org/mtd-2.6
* git://git.infradead.org/mtd-2.6: (46 commits)
[MTD] [MAPS] drivers/mtd/maps/ck804xrom.c: convert pci_module_init()
[MTD] [NAND] CM-x270 MTD driver
[MTD] [NAND] Wrong calculation of page number in nand_block_bad()
[MTD] [MAPS] fix plat-ram printk format
[JFFS2] Fix compr_rubin.c build after include file elimination.
[JFFS2] Handle inodes with only a single metadata node with non-zero isize
[JFFS2] Tidy up licensing/copyright boilerplate.
[MTD] [OneNAND] Exit loop only when column start with 0
[MTD] [OneNAND] Fix access the past of the real oobfree array
[MTD] [OneNAND] Update Samsung OneNAND official URL
[JFFS2] Better fix for all-zero node headers
[JFFS2] Improve read_inode memory usage, v2.
[JFFS2] Improve failure mode if inode checking leaves unchecked space.
[JFFS2] Fix cross-endian build.
[MTD] Finish conversion mtd_blkdevs to use the kthread API
[JFFS2] Obsolete dirent nodes immediately on unlink, where possible.
Use menuconfig objects: MTD
[MTD] mtd_blkdevs: Convert to use the kthread API
[MTD] Fix fwh_lock locking
[JFFS2] Speed up mount for directly-mapped NOR flash
...
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; |