diff options
Diffstat (limited to 'drivers/mtd/tests/oobtest.c')
-rw-r--r-- | drivers/mtd/tests/oobtest.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/mtd/tests/oobtest.c b/drivers/mtd/tests/oobtest.c index 2e9e2d11f204..f19ab1acde1f 100644 --- a/drivers/mtd/tests/oobtest.c +++ b/drivers/mtd/tests/oobtest.c | |||
@@ -69,8 +69,8 @@ static int write_eraseblock(int ebnum) | |||
69 | int err = 0; | 69 | int err = 0; |
70 | loff_t addr = ebnum * mtd->erasesize; | 70 | loff_t addr = ebnum * mtd->erasesize; |
71 | 71 | ||
72 | prandom_bytes_state(&rnd_state, writebuf, use_len_max * pgcnt); | ||
72 | for (i = 0; i < pgcnt; ++i, addr += mtd->writesize) { | 73 | for (i = 0; i < pgcnt; ++i, addr += mtd->writesize) { |
73 | prandom_bytes_state(&rnd_state, writebuf, use_len); | ||
74 | ops.mode = MTD_OPS_AUTO_OOB; | 74 | ops.mode = MTD_OPS_AUTO_OOB; |
75 | ops.len = 0; | 75 | ops.len = 0; |
76 | ops.retlen = 0; | 76 | ops.retlen = 0; |
@@ -78,7 +78,7 @@ static int write_eraseblock(int ebnum) | |||
78 | ops.oobretlen = 0; | 78 | ops.oobretlen = 0; |
79 | ops.ooboffs = use_offset; | 79 | ops.ooboffs = use_offset; |
80 | ops.datbuf = NULL; | 80 | ops.datbuf = NULL; |
81 | ops.oobbuf = writebuf; | 81 | ops.oobbuf = writebuf + (use_len_max * i) + use_offset; |
82 | err = mtd_write_oob(mtd, addr, &ops); | 82 | err = mtd_write_oob(mtd, addr, &ops); |
83 | if (err || ops.oobretlen != use_len) { | 83 | if (err || ops.oobretlen != use_len) { |
84 | pr_err("error: writeoob failed at %#llx\n", | 84 | pr_err("error: writeoob failed at %#llx\n", |
@@ -122,8 +122,8 @@ static int verify_eraseblock(int ebnum) | |||
122 | int err = 0; | 122 | int err = 0; |
123 | loff_t addr = ebnum * mtd->erasesize; | 123 | loff_t addr = ebnum * mtd->erasesize; |
124 | 124 | ||
125 | prandom_bytes_state(&rnd_state, writebuf, use_len_max * pgcnt); | ||
125 | for (i = 0; i < pgcnt; ++i, addr += mtd->writesize) { | 126 | for (i = 0; i < pgcnt; ++i, addr += mtd->writesize) { |
126 | prandom_bytes_state(&rnd_state, writebuf, use_len); | ||
127 | ops.mode = MTD_OPS_AUTO_OOB; | 127 | ops.mode = MTD_OPS_AUTO_OOB; |
128 | ops.len = 0; | 128 | ops.len = 0; |
129 | ops.retlen = 0; | 129 | ops.retlen = 0; |
@@ -139,7 +139,8 @@ static int verify_eraseblock(int ebnum) | |||
139 | errcnt += 1; | 139 | errcnt += 1; |
140 | return err ? err : -1; | 140 | return err ? err : -1; |
141 | } | 141 | } |
142 | if (memcmp(readbuf, writebuf, use_len)) { | 142 | if (memcmp(readbuf, writebuf + (use_len_max * i) + use_offset, |
143 | use_len)) { | ||
143 | pr_err("error: verify failed at %#llx\n", | 144 | pr_err("error: verify failed at %#llx\n", |
144 | (long long)addr); | 145 | (long long)addr); |
145 | errcnt += 1; | 146 | errcnt += 1; |
@@ -166,7 +167,9 @@ static int verify_eraseblock(int ebnum) | |||
166 | errcnt += 1; | 167 | errcnt += 1; |
167 | return err ? err : -1; | 168 | return err ? err : -1; |
168 | } | 169 | } |
169 | if (memcmp(readbuf + use_offset, writebuf, use_len)) { | 170 | if (memcmp(readbuf + use_offset, |
171 | writebuf + (use_len_max * i) + use_offset, | ||
172 | use_len)) { | ||
170 | pr_err("error: verify failed at %#llx\n", | 173 | pr_err("error: verify failed at %#llx\n", |
171 | (long long)addr); | 174 | (long long)addr); |
172 | errcnt += 1; | 175 | errcnt += 1; |
@@ -566,8 +569,8 @@ static int __init mtd_oobtest_init(void) | |||
566 | if (bbt[i] || bbt[i + 1]) | 569 | if (bbt[i] || bbt[i + 1]) |
567 | continue; | 570 | continue; |
568 | addr = (i + 1) * mtd->erasesize - mtd->writesize; | 571 | addr = (i + 1) * mtd->erasesize - mtd->writesize; |
572 | prandom_bytes_state(&rnd_state, writebuf, sz * cnt); | ||
569 | for (pg = 0; pg < cnt; ++pg) { | 573 | for (pg = 0; pg < cnt; ++pg) { |
570 | prandom_bytes_state(&rnd_state, writebuf, sz); | ||
571 | ops.mode = MTD_OPS_AUTO_OOB; | 574 | ops.mode = MTD_OPS_AUTO_OOB; |
572 | ops.len = 0; | 575 | ops.len = 0; |
573 | ops.retlen = 0; | 576 | ops.retlen = 0; |
@@ -575,7 +578,7 @@ static int __init mtd_oobtest_init(void) | |||
575 | ops.oobretlen = 0; | 578 | ops.oobretlen = 0; |
576 | ops.ooboffs = 0; | 579 | ops.ooboffs = 0; |
577 | ops.datbuf = NULL; | 580 | ops.datbuf = NULL; |
578 | ops.oobbuf = writebuf; | 581 | ops.oobbuf = writebuf + pg * sz; |
579 | err = mtd_write_oob(mtd, addr, &ops); | 582 | err = mtd_write_oob(mtd, addr, &ops); |
580 | if (err) | 583 | if (err) |
581 | goto out; | 584 | goto out; |