aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/sm_ftl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/sm_ftl.c')
-rw-r--r--drivers/mtd/sm_ftl.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
index ed3d6cd2c6dc..fddb714e323c 100644
--- a/drivers/mtd/sm_ftl.c
+++ b/drivers/mtd/sm_ftl.c
@@ -34,7 +34,7 @@ module_param(debug, int, S_IRUGO | S_IWUSR);
34MODULE_PARM_DESC(debug, "Debug level (0-2)"); 34MODULE_PARM_DESC(debug, "Debug level (0-2)");
35 35
36 36
37/* ------------------- sysfs attributtes ---------------------------------- */ 37/* ------------------- sysfs attributes ---------------------------------- */
38struct sm_sysfs_attribute { 38struct sm_sysfs_attribute {
39 struct device_attribute dev_attr; 39 struct device_attribute dev_attr;
40 char *data; 40 char *data;
@@ -138,7 +138,7 @@ static int sm_get_lba(uint8_t *lba)
138 if ((lba[0] & 0xF8) != 0x10) 138 if ((lba[0] & 0xF8) != 0x10)
139 return -2; 139 return -2;
140 140
141 /* check parity - endianess doesn't matter */ 141 /* check parity - endianness doesn't matter */
142 if (hweight16(*(uint16_t *)lba) & 1) 142 if (hweight16(*(uint16_t *)lba) & 1)
143 return -2; 143 return -2;
144 144
@@ -147,7 +147,7 @@ static int sm_get_lba(uint8_t *lba)
147 147
148 148
149/* 149/*
150 * Read LBA asscociated with block 150 * Read LBA associated with block
151 * returns -1, if block is erased 151 * returns -1, if block is erased
152 * returns -2 if error happens 152 * returns -2 if error happens
153 */ 153 */
@@ -252,11 +252,11 @@ static int sm_read_sector(struct sm_ftl *ftl,
252 return 0; 252 return 0;
253 } 253 }
254 254
255 /* User might not need the oob, but we do for data vertification */ 255 /* User might not need the oob, but we do for data verification */
256 if (!oob) 256 if (!oob)
257 oob = &tmp_oob; 257 oob = &tmp_oob;
258 258
259 ops.mode = ftl->smallpagenand ? MTD_OOB_RAW : MTD_OOB_PLACE; 259 ops.mode = ftl->smallpagenand ? MTD_OPS_RAW : MTD_OPS_PLACE_OOB;
260 ops.ooboffs = 0; 260 ops.ooboffs = 0;
261 ops.ooblen = SM_OOB_SIZE; 261 ops.ooblen = SM_OOB_SIZE;
262 ops.oobbuf = (void *)oob; 262 ops.oobbuf = (void *)oob;
@@ -276,12 +276,12 @@ again:
276 return ret; 276 return ret;
277 } 277 }
278 278
279 /* Unfortunelly, oob read will _always_ succeed, 279 /* Unfortunately, oob read will _always_ succeed,
280 despite card removal..... */ 280 despite card removal..... */
281 ret = mtd->read_oob(mtd, sm_mkoffset(ftl, zone, block, boffset), &ops); 281 ret = mtd->read_oob(mtd, sm_mkoffset(ftl, zone, block, boffset), &ops);
282 282
283 /* Test for unknown errors */ 283 /* Test for unknown errors */
284 if (ret != 0 && ret != -EUCLEAN && ret != -EBADMSG) { 284 if (ret != 0 && !mtd_is_bitflip_or_eccerr(ret)) {
285 dbg("read of block %d at zone %d, failed due to error (%d)", 285 dbg("read of block %d at zone %d, failed due to error (%d)",
286 block, zone, ret); 286 block, zone, ret);
287 goto again; 287 goto again;
@@ -306,7 +306,7 @@ again:
306 } 306 }
307 307
308 /* Test ECC*/ 308 /* Test ECC*/
309 if (ret == -EBADMSG || 309 if (mtd_is_eccerr(ret) ||
310 (ftl->smallpagenand && sm_correct_sector(buffer, oob))) { 310 (ftl->smallpagenand && sm_correct_sector(buffer, oob))) {
311 311
312 dbg("read of block %d at zone %d, failed due to ECC error", 312 dbg("read of block %d at zone %d, failed due to ECC error",
@@ -336,7 +336,7 @@ static int sm_write_sector(struct sm_ftl *ftl,
336 if (ftl->unstable) 336 if (ftl->unstable)
337 return -EIO; 337 return -EIO;
338 338
339 ops.mode = ftl->smallpagenand ? MTD_OOB_RAW : MTD_OOB_PLACE; 339 ops.mode = ftl->smallpagenand ? MTD_OPS_RAW : MTD_OPS_PLACE_OOB;
340 ops.len = SM_SECTOR_SIZE; 340 ops.len = SM_SECTOR_SIZE;
341 ops.datbuf = buffer; 341 ops.datbuf = buffer;
342 ops.ooboffs = 0; 342 ops.ooboffs = 0;
@@ -447,14 +447,14 @@ static void sm_mark_block_bad(struct sm_ftl *ftl, int zone, int block)
447 447
448 /* We aren't checking the return value, because we don't care */ 448 /* We aren't checking the return value, because we don't care */
449 /* This also fails on fake xD cards, but I guess these won't expose 449 /* This also fails on fake xD cards, but I guess these won't expose
450 any bad blocks till fail completly */ 450 any bad blocks till fail completely */
451 for (boffset = 0; boffset < ftl->block_size; boffset += SM_SECTOR_SIZE) 451 for (boffset = 0; boffset < ftl->block_size; boffset += SM_SECTOR_SIZE)
452 sm_write_sector(ftl, zone, block, boffset, NULL, &oob); 452 sm_write_sector(ftl, zone, block, boffset, NULL, &oob);
453} 453}
454 454
455/* 455/*
456 * Erase a block within a zone 456 * Erase a block within a zone
457 * If erase succedes, it updates free block fifo, otherwise marks block as bad 457 * If erase succeeds, it updates free block fifo, otherwise marks block as bad
458 */ 458 */
459static int sm_erase_block(struct sm_ftl *ftl, int zone_num, uint16_t block, 459static int sm_erase_block(struct sm_ftl *ftl, int zone_num, uint16_t block,
460 int put_free) 460 int put_free)
@@ -510,7 +510,7 @@ static void sm_erase_callback(struct erase_info *self)
510 complete(&ftl->erase_completion); 510 complete(&ftl->erase_completion);
511} 511}
512 512
513/* Throughtly test that block is valid. */ 513/* Thoroughly test that block is valid. */
514static int sm_check_block(struct sm_ftl *ftl, int zone, int block) 514static int sm_check_block(struct sm_ftl *ftl, int zone, int block)
515{ 515{
516 int boffset; 516 int boffset;
@@ -526,7 +526,7 @@ static int sm_check_block(struct sm_ftl *ftl, int zone, int block)
526 for (boffset = 0; boffset < ftl->block_size; 526 for (boffset = 0; boffset < ftl->block_size;
527 boffset += SM_SECTOR_SIZE) { 527 boffset += SM_SECTOR_SIZE) {
528 528
529 /* This shoudn't happen anyway */ 529 /* This shouldn't happen anyway */
530 if (sm_read_sector(ftl, zone, block, boffset, NULL, &oob)) 530 if (sm_read_sector(ftl, zone, block, boffset, NULL, &oob))
531 return -2; 531 return -2;
532 532