aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nftlmount.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@cruncher.tec.linutronix.de>2006-05-28 05:01:53 -0400
committerThomas Gleixner <tglx@cruncher.tec.linutronix.de>2006-05-29 09:06:50 -0400
commitf4a43cfcecfcaeeaa40a9dbc1d1378298c22446e (patch)
tree5647ebccb720c9d8ca314c8a3a5f6a660d000019 /drivers/mtd/nftlmount.c
parent5bd34c091a044d130601370c370f84b1c59f1627 (diff)
[MTD] Remove silly MTD_WRITE/READ macros
Most of those macros are unused and the used ones just obfuscate the code. Remove them and fixup all users. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/mtd/nftlmount.c')
-rw-r--r--drivers/mtd/nftlmount.c74
1 files changed, 44 insertions, 30 deletions
diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
index 90e5e7e97fdc..521b07cd2326 100644
--- a/drivers/mtd/nftlmount.c
+++ b/drivers/mtd/nftlmount.c
@@ -45,6 +45,7 @@ static int find_boot_record(struct NFTLrecord *nftl)
45 size_t retlen; 45 size_t retlen;
46 u8 buf[SECTORSIZE]; 46 u8 buf[SECTORSIZE];
47 struct NFTLMediaHeader *mh = &nftl->MediaHdr; 47 struct NFTLMediaHeader *mh = &nftl->MediaHdr;
48 struct mtd_info *mtd = nftl->mbd.mtd;
48 unsigned int i; 49 unsigned int i;
49 50
50 /* Assume logical EraseSize == physical erasesize for starting the scan. 51 /* Assume logical EraseSize == physical erasesize for starting the scan.
@@ -65,7 +66,8 @@ static int find_boot_record(struct NFTLrecord *nftl)
65 66
66 /* Check for ANAND header first. Then can whinge if it's found but later 67 /* Check for ANAND header first. Then can whinge if it's found but later
67 checks fail */ 68 checks fail */
68 ret = MTD_READ(nftl->mbd.mtd, block * nftl->EraseSize, SECTORSIZE, &retlen, buf); 69 ret = mtd->read(mtd, block * nftl->EraseSize, SECTORSIZE,
70 &retlen, buf);
69 /* We ignore ret in case the ECC of the MediaHeader is invalid 71 /* We ignore ret in case the ECC of the MediaHeader is invalid
70 (which is apparently acceptable) */ 72 (which is apparently acceptable) */
71 if (retlen != SECTORSIZE) { 73 if (retlen != SECTORSIZE) {
@@ -90,8 +92,9 @@ static int find_boot_record(struct NFTLrecord *nftl)
90 } 92 }
91 93
92 /* To be safer with BIOS, also use erase mark as discriminant */ 94 /* To be safer with BIOS, also use erase mark as discriminant */
93 if ((ret = MTD_READOOB(nftl->mbd.mtd, block * nftl->EraseSize + SECTORSIZE + 8, 95 if ((ret = mtd->read_oob(mtd, block * nftl->EraseSize +
94 8, &retlen, (char *)&h1) < 0)) { 96 SECTORSIZE + 8, 8, &retlen,
97 (char *)&h1) < 0)) {
95 printk(KERN_WARNING "ANAND header found at 0x%x in mtd%d, but OOB data read failed (err %d)\n", 98 printk(KERN_WARNING "ANAND header found at 0x%x in mtd%d, but OOB data read failed (err %d)\n",
96 block * nftl->EraseSize, nftl->mbd.mtd->index, ret); 99 block * nftl->EraseSize, nftl->mbd.mtd->index, ret);
97 continue; 100 continue;
@@ -109,8 +112,8 @@ static int find_boot_record(struct NFTLrecord *nftl)
109 } 112 }
110 113
111 /* Finally reread to check ECC */ 114 /* Finally reread to check ECC */
112 if ((ret = MTD_READECC(nftl->mbd.mtd, block * nftl->EraseSize, SECTORSIZE, 115 if ((ret = mtd->read(mtd, block * nftl->EraseSize, SECTORSIZE,
113 &retlen, buf, (char *)&oob, NULL) < 0)) { 116 &retlen, buf) < 0)) {
114 printk(KERN_NOTICE "ANAND header found at 0x%x in mtd%d, but ECC read failed (err %d)\n", 117 printk(KERN_NOTICE "ANAND header found at 0x%x in mtd%d, but ECC read failed (err %d)\n",
115 block * nftl->EraseSize, nftl->mbd.mtd->index, ret); 118 block * nftl->EraseSize, nftl->mbd.mtd->index, ret);
116 continue; 119 continue;
@@ -228,9 +231,9 @@ device is already correct.
228The new DiskOnChip driver already scanned the bad block table. Just query it. 231The new DiskOnChip driver already scanned the bad block table. Just query it.
229 if ((i & (SECTORSIZE - 1)) == 0) { 232 if ((i & (SECTORSIZE - 1)) == 0) {
230 /* read one sector for every SECTORSIZE of blocks */ 233 /* read one sector for every SECTORSIZE of blocks */
231 if ((ret = MTD_READECC(nftl->mbd.mtd, block * nftl->EraseSize + 234 if ((ret = mtd->read(nftl->mbd.mtd, block * nftl->EraseSize +
232 i + SECTORSIZE, SECTORSIZE, &retlen, buf, 235 i + SECTORSIZE, SECTORSIZE, &retlen,
233 (char *)&oob, NULL)) < 0) { 236 buf)) < 0) {
234 printk(KERN_NOTICE "Read of bad sector table failed (err %d)\n", 237 printk(KERN_NOTICE "Read of bad sector table failed (err %d)\n",
235 ret); 238 ret);
236 kfree(nftl->ReplUnitTable); 239 kfree(nftl->ReplUnitTable);
@@ -305,10 +308,11 @@ int NFTL_formatblock(struct NFTLrecord *nftl, int block)
305 unsigned int nb_erases, erase_mark; 308 unsigned int nb_erases, erase_mark;
306 struct nftl_uci1 uci; 309 struct nftl_uci1 uci;
307 struct erase_info *instr = &nftl->instr; 310 struct erase_info *instr = &nftl->instr;
311 struct mtd_info *mtd = nftl->mbd.mtd;
308 312
309 /* Read the Unit Control Information #1 for Wear-Leveling */ 313 /* Read the Unit Control Information #1 for Wear-Leveling */
310 if (MTD_READOOB(nftl->mbd.mtd, block * nftl->EraseSize + SECTORSIZE + 8, 314 if (mtd->read_oob(mtd, block * nftl->EraseSize + SECTORSIZE + 8,
311 8, &retlen, (char *)&uci) < 0) 315 8, &retlen, (char *)&uci) < 0)
312 goto default_uci1; 316 goto default_uci1;
313 317
314 erase_mark = le16_to_cpu ((uci.EraseMark | uci.EraseMark1)); 318 erase_mark = le16_to_cpu ((uci.EraseMark | uci.EraseMark1));
@@ -325,7 +329,7 @@ int NFTL_formatblock(struct NFTLrecord *nftl, int block)
325 instr->mtd = nftl->mbd.mtd; 329 instr->mtd = nftl->mbd.mtd;
326 instr->addr = block * nftl->EraseSize; 330 instr->addr = block * nftl->EraseSize;
327 instr->len = nftl->EraseSize; 331 instr->len = nftl->EraseSize;
328 MTD_ERASE(nftl->mbd.mtd, instr); 332 mtd->erase(mtd, instr);
329 333
330 if (instr->state == MTD_ERASE_FAILED) { 334 if (instr->state == MTD_ERASE_FAILED) {
331 printk("Error while formatting block %d\n", block); 335 printk("Error while formatting block %d\n", block);
@@ -347,8 +351,8 @@ int NFTL_formatblock(struct NFTLrecord *nftl, int block)
347 goto fail; 351 goto fail;
348 352
349 uci.WearInfo = le32_to_cpu(nb_erases); 353 uci.WearInfo = le32_to_cpu(nb_erases);
350 if (MTD_WRITEOOB(nftl->mbd.mtd, block * nftl->EraseSize + SECTORSIZE + 8, 8, 354 if (mtd->write_oob(mtd, block * nftl->EraseSize + SECTORSIZE +
351 &retlen, (char *)&uci) < 0) 355 8, 8, &retlen, (char *)&uci) < 0)
352 goto fail; 356 goto fail;
353 return 0; 357 return 0;
354fail: 358fail:
@@ -369,6 +373,7 @@ fail:
369 * case. */ 373 * case. */
370static void check_sectors_in_chain(struct NFTLrecord *nftl, unsigned int first_block) 374static void check_sectors_in_chain(struct NFTLrecord *nftl, unsigned int first_block)
371{ 375{
376 struct mtd_info *mtd = nftl->mbd.mtd;
372 unsigned int block, i, status; 377 unsigned int block, i, status;
373 struct nftl_bci bci; 378 struct nftl_bci bci;
374 int sectors_per_block; 379 int sectors_per_block;
@@ -378,8 +383,9 @@ static void check_sectors_in_chain(struct NFTLrecord *nftl, unsigned int first_b
378 block = first_block; 383 block = first_block;
379 for (;;) { 384 for (;;) {
380 for (i = 0; i < sectors_per_block; i++) { 385 for (i = 0; i < sectors_per_block; i++) {
381 if (MTD_READOOB(nftl->mbd.mtd, block * nftl->EraseSize + i * SECTORSIZE, 386 if (mtd->read_oob(mtd,
382 8, &retlen, (char *)&bci) < 0) 387 block * nftl->EraseSize + i * SECTORSIZE,
388 8, &retlen, (char *)&bci) < 0)
383 status = SECTOR_IGNORE; 389 status = SECTOR_IGNORE;
384 else 390 else
385 status = bci.Status | bci.Status1; 391 status = bci.Status | bci.Status1;
@@ -398,9 +404,10 @@ static void check_sectors_in_chain(struct NFTLrecord *nftl, unsigned int first_b
398 /* sector not free actually : mark it as SECTOR_IGNORE */ 404 /* sector not free actually : mark it as SECTOR_IGNORE */
399 bci.Status = SECTOR_IGNORE; 405 bci.Status = SECTOR_IGNORE;
400 bci.Status1 = SECTOR_IGNORE; 406 bci.Status1 = SECTOR_IGNORE;
401 MTD_WRITEOOB(nftl->mbd.mtd, 407 mtd->write_oob(mtd, block *
402 block * nftl->EraseSize + i * SECTORSIZE, 408 nftl->EraseSize +
403 8, &retlen, (char *)&bci); 409 i * SECTORSIZE, 8,
410 &retlen, (char *)&bci);
404 } 411 }
405 break; 412 break;
406 default: 413 default:
@@ -485,13 +492,14 @@ static void format_chain(struct NFTLrecord *nftl, unsigned int first_block)
485 * 1. */ 492 * 1. */
486static int check_and_mark_free_block(struct NFTLrecord *nftl, int block) 493static int check_and_mark_free_block(struct NFTLrecord *nftl, int block)
487{ 494{
495 struct mtd_info *mtd = nftl->mbd.mtd;
488 struct nftl_uci1 h1; 496 struct nftl_uci1 h1;
489 unsigned int erase_mark; 497 unsigned int erase_mark;
490 size_t retlen; 498 size_t retlen;
491 499
492 /* check erase mark. */ 500 /* check erase mark. */
493 if (MTD_READOOB(nftl->mbd.mtd, block * nftl->EraseSize + SECTORSIZE + 8, 8, 501 if (mtd->read_oob(mtd, block * nftl->EraseSize + SECTORSIZE + 8, 8,
494 &retlen, (char *)&h1) < 0) 502 &retlen, (char *)&h1) < 0)
495 return -1; 503 return -1;
496 504
497 erase_mark = le16_to_cpu ((h1.EraseMark | h1.EraseMark1)); 505 erase_mark = le16_to_cpu ((h1.EraseMark | h1.EraseMark1));
@@ -505,8 +513,9 @@ static int check_and_mark_free_block(struct NFTLrecord *nftl, int block)
505 h1.EraseMark = cpu_to_le16(ERASE_MARK); 513 h1.EraseMark = cpu_to_le16(ERASE_MARK);
506 h1.EraseMark1 = cpu_to_le16(ERASE_MARK); 514 h1.EraseMark1 = cpu_to_le16(ERASE_MARK);
507 h1.WearInfo = cpu_to_le32(0); 515 h1.WearInfo = cpu_to_le32(0);
508 if (MTD_WRITEOOB(nftl->mbd.mtd, block * nftl->EraseSize + SECTORSIZE + 8, 8, 516 if (mtd->write_oob(mtd,
509 &retlen, (char *)&h1) < 0) 517 block * nftl->EraseSize + SECTORSIZE + 8, 8,
518 &retlen, (char *)&h1) < 0)
510 return -1; 519 return -1;
511 } else { 520 } else {
512#if 0 521#if 0
@@ -517,8 +526,8 @@ static int check_and_mark_free_block(struct NFTLrecord *nftl, int block)
517 SECTORSIZE, 0) != 0) 526 SECTORSIZE, 0) != 0)
518 return -1; 527 return -1;
519 528
520 if (MTD_READOOB(nftl->mbd.mtd, block * nftl->EraseSize + i, 529 if (mtd->read_oob(mtd, block * nftl->EraseSize + i,
521 16, &retlen, buf) < 0) 530 16, &retlen, buf) < 0)
522 return -1; 531 return -1;
523 if (i == SECTORSIZE) { 532 if (i == SECTORSIZE) {
524 /* skip erase mark */ 533 /* skip erase mark */
@@ -544,11 +553,12 @@ static int check_and_mark_free_block(struct NFTLrecord *nftl, int block)
544 */ 553 */
545static int get_fold_mark(struct NFTLrecord *nftl, unsigned int block) 554static int get_fold_mark(struct NFTLrecord *nftl, unsigned int block)
546{ 555{
556 struct mtd_info *mtd = nftl->mbd.mtd;
547 struct nftl_uci2 uci; 557 struct nftl_uci2 uci;
548 size_t retlen; 558 size_t retlen;
549 559
550 if (MTD_READOOB(nftl->mbd.mtd, block * nftl->EraseSize + 2 * SECTORSIZE + 8, 560 if (mtd->read_oob(mtd, block * nftl->EraseSize + 2 * SECTORSIZE + 8,
551 8, &retlen, (char *)&uci) < 0) 561 8, &retlen, (char *)&uci) < 0)
552 return 0; 562 return 0;
553 563
554 return le16_to_cpu((uci.FoldMark | uci.FoldMark1)); 564 return le16_to_cpu((uci.FoldMark | uci.FoldMark1));
@@ -562,6 +572,7 @@ int NFTL_mount(struct NFTLrecord *s)
562 int chain_length, do_format_chain; 572 int chain_length, do_format_chain;
563 struct nftl_uci0 h0; 573 struct nftl_uci0 h0;
564 struct nftl_uci1 h1; 574 struct nftl_uci1 h1;
575 struct mtd_info *mtd = s->mbd.mtd;
565 size_t retlen; 576 size_t retlen;
566 577
567 /* search for NFTL MediaHeader and Spare NFTL Media Header */ 578 /* search for NFTL MediaHeader and Spare NFTL Media Header */
@@ -586,10 +597,13 @@ int NFTL_mount(struct NFTLrecord *s)
586 597
587 for (;;) { 598 for (;;) {
588 /* read the block header. If error, we format the chain */ 599 /* read the block header. If error, we format the chain */
589 if (MTD_READOOB(s->mbd.mtd, block * s->EraseSize + 8, 8, 600 if (mtd->read_oob(mtd,
590 &retlen, (char *)&h0) < 0 || 601 block * s->EraseSize + 8, 8,
591 MTD_READOOB(s->mbd.mtd, block * s->EraseSize + SECTORSIZE + 8, 8, 602 &retlen, (char *)&h0) < 0 ||
592 &retlen, (char *)&h1) < 0) { 603 mtd->read_oob(mtd,
604 block * s->EraseSize +
605 SECTORSIZE + 8, 8,
606 &retlen, (char *)&h1) < 0) {
593 s->ReplUnitTable[block] = BLOCK_NIL; 607 s->ReplUnitTable[block] = BLOCK_NIL;
594 do_format_chain = 1; 608 do_format_chain = 1;
595 break; 609 break;