diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2013-08-15 09:55:09 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2013-08-30 16:36:06 -0400 |
commit | 8a9f4aa3ac7560efcb242b3d1a31b1d804106f12 (patch) | |
tree | ac105da51b1987e3b6894fb6b1bd73a6765c3ca3 /drivers/mtd/tests | |
parent | abc173ad84e50645f9136ea56afa9f86c98bf349 (diff) |
mtd: tests: incorporate error message for mtdtest_write()
All callers of mtdtest_write() print the same error message on failure.
This incorporates the error message to mtdtest_write() and removes them
from the callers.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/tests')
-rw-r--r-- | drivers/mtd/tests/mtd_test.c | 2 | ||||
-rw-r--r-- | drivers/mtd/tests/nandbiterrs.c | 8 | ||||
-rw-r--r-- | drivers/mtd/tests/pagetest.c | 23 | ||||
-rw-r--r-- | drivers/mtd/tests/speedtest.c | 24 | ||||
-rw-r--r-- | drivers/mtd/tests/stresstest.c | 5 |
5 files changed, 12 insertions, 50 deletions
diff --git a/drivers/mtd/tests/mtd_test.c b/drivers/mtd/tests/mtd_test.c index 4c2e3f0bb953..c818a63532e7 100644 --- a/drivers/mtd/tests/mtd_test.c +++ b/drivers/mtd/tests/mtd_test.c | |||
@@ -107,6 +107,8 @@ int mtdtest_write(struct mtd_info *mtd, loff_t addr, size_t size, | |||
107 | err = mtd_write(mtd, addr, size, &written, buf); | 107 | err = mtd_write(mtd, addr, size, &written, buf); |
108 | if (!err && written != size) | 108 | if (!err && written != size) |
109 | err = -EIO; | 109 | err = -EIO; |
110 | if (err) | ||
111 | pr_err("error: write failed at %#llx\n", addr); | ||
110 | 112 | ||
111 | return err; | 113 | return err; |
112 | } | 114 | } |
diff --git a/drivers/mtd/tests/nandbiterrs.c b/drivers/mtd/tests/nandbiterrs.c index 5a8c8584112d..3cd3aabbe1cd 100644 --- a/drivers/mtd/tests/nandbiterrs.c +++ b/drivers/mtd/tests/nandbiterrs.c | |||
@@ -102,16 +102,10 @@ static uint8_t hash(unsigned offset) | |||
102 | /* Writes wbuffer to page */ | 102 | /* Writes wbuffer to page */ |
103 | static int write_page(int log) | 103 | static int write_page(int log) |
104 | { | 104 | { |
105 | int err; | ||
106 | |||
107 | if (log) | 105 | if (log) |
108 | pr_info("write_page\n"); | 106 | pr_info("write_page\n"); |
109 | 107 | ||
110 | err = mtdtest_write(mtd, offset, mtd->writesize, wbuffer); | 108 | return mtdtest_write(mtd, offset, mtd->writesize, wbuffer); |
111 | if (err) | ||
112 | pr_err("error: write failed at %#llx\n", (long long)offset); | ||
113 | |||
114 | return err; | ||
115 | } | 109 | } |
116 | 110 | ||
117 | /* Re-writes the data area while leaving the OOB alone. */ | 111 | /* Re-writes the data area while leaving the OOB alone. */ |
diff --git a/drivers/mtd/tests/pagetest.c b/drivers/mtd/tests/pagetest.c index 9e8329c5d96d..44b96e999ad4 100644 --- a/drivers/mtd/tests/pagetest.c +++ b/drivers/mtd/tests/pagetest.c | |||
@@ -52,17 +52,11 @@ static struct rnd_state rnd_state; | |||
52 | 52 | ||
53 | static int write_eraseblock(int ebnum) | 53 | static int write_eraseblock(int ebnum) |
54 | { | 54 | { |
55 | int err; | ||
56 | loff_t addr = ebnum * mtd->erasesize; | 55 | loff_t addr = ebnum * mtd->erasesize; |
57 | 56 | ||
58 | prandom_bytes_state(&rnd_state, writebuf, mtd->erasesize); | 57 | prandom_bytes_state(&rnd_state, writebuf, mtd->erasesize); |
59 | cond_resched(); | 58 | cond_resched(); |
60 | err = mtdtest_write(mtd, addr, mtd->erasesize, writebuf); | 59 | return mtdtest_write(mtd, addr, mtd->erasesize, writebuf); |
61 | if (err) | ||
62 | pr_err("error: write failed at %#llx\n", | ||
63 | (long long)addr); | ||
64 | |||
65 | return err; | ||
66 | } | 60 | } |
67 | 61 | ||
68 | static int verify_eraseblock(int ebnum) | 62 | static int verify_eraseblock(int ebnum) |
@@ -232,11 +226,8 @@ static int erasecrosstest(void) | |||
232 | prandom_bytes_state(&rnd_state, writebuf, pgsize); | 226 | prandom_bytes_state(&rnd_state, writebuf, pgsize); |
233 | strcpy(writebuf, "There is no data like this!"); | 227 | strcpy(writebuf, "There is no data like this!"); |
234 | err = mtdtest_write(mtd, addr0, pgsize, writebuf); | 228 | err = mtdtest_write(mtd, addr0, pgsize, writebuf); |
235 | if (err) { | 229 | if (err) |
236 | pr_info("error: write failed at %#llx\n", | ||
237 | (long long)addr0); | ||
238 | return err; | 230 | return err; |
239 | } | ||
240 | 231 | ||
241 | pr_info("reading 1st page of block %d\n", ebnum); | 232 | pr_info("reading 1st page of block %d\n", ebnum); |
242 | memset(readbuf, 0, pgsize); | 233 | memset(readbuf, 0, pgsize); |
@@ -260,11 +251,8 @@ static int erasecrosstest(void) | |||
260 | prandom_bytes_state(&rnd_state, writebuf, pgsize); | 251 | prandom_bytes_state(&rnd_state, writebuf, pgsize); |
261 | strcpy(writebuf, "There is no data like this!"); | 252 | strcpy(writebuf, "There is no data like this!"); |
262 | err = mtdtest_write(mtd, addr0, pgsize, writebuf); | 253 | err = mtdtest_write(mtd, addr0, pgsize, writebuf); |
263 | if (err) { | 254 | if (err) |
264 | pr_err("error: write failed at %#llx\n", | ||
265 | (long long)addr0); | ||
266 | return err; | 255 | return err; |
267 | } | ||
268 | 256 | ||
269 | pr_info("erasing block %d\n", ebnum2); | 257 | pr_info("erasing block %d\n", ebnum2); |
270 | err = mtdtest_erase_eraseblock(mtd, ebnum2); | 258 | err = mtdtest_erase_eraseblock(mtd, ebnum2); |
@@ -311,11 +299,8 @@ static int erasetest(void) | |||
311 | pr_info("writing 1st page of block %d\n", ebnum); | 299 | pr_info("writing 1st page of block %d\n", ebnum); |
312 | prandom_bytes_state(&rnd_state, writebuf, pgsize); | 300 | prandom_bytes_state(&rnd_state, writebuf, pgsize); |
313 | err = mtdtest_write(mtd, addr0, pgsize, writebuf); | 301 | err = mtdtest_write(mtd, addr0, pgsize, writebuf); |
314 | if (err) { | 302 | if (err) |
315 | pr_err("error: write failed at %#llx\n", | ||
316 | (long long)addr0); | ||
317 | return err; | 303 | return err; |
318 | } | ||
319 | 304 | ||
320 | pr_info("erasing block %d\n", ebnum); | 305 | pr_info("erasing block %d\n", ebnum); |
321 | err = mtdtest_erase_eraseblock(mtd, ebnum); | 306 | err = mtdtest_erase_eraseblock(mtd, ebnum); |
diff --git a/drivers/mtd/tests/speedtest.c b/drivers/mtd/tests/speedtest.c index d1a38530612e..87ff6a29f84e 100644 --- a/drivers/mtd/tests/speedtest.c +++ b/drivers/mtd/tests/speedtest.c | |||
@@ -80,14 +80,9 @@ static int multiblock_erase(int ebnum, int blocks) | |||
80 | 80 | ||
81 | static int write_eraseblock(int ebnum) | 81 | static int write_eraseblock(int ebnum) |
82 | { | 82 | { |
83 | int err; | ||
84 | loff_t addr = ebnum * mtd->erasesize; | 83 | loff_t addr = ebnum * mtd->erasesize; |
85 | 84 | ||
86 | err = mtdtest_write(mtd, addr, mtd->erasesize, iobuf); | 85 | return mtdtest_write(mtd, addr, mtd->erasesize, iobuf); |
87 | if (err) | ||
88 | pr_err("error: write failed at %#llx\n", addr); | ||
89 | |||
90 | return err; | ||
91 | } | 86 | } |
92 | 87 | ||
93 | static int write_eraseblock_by_page(int ebnum) | 88 | static int write_eraseblock_by_page(int ebnum) |
@@ -98,11 +93,8 @@ static int write_eraseblock_by_page(int ebnum) | |||
98 | 93 | ||
99 | for (i = 0; i < pgcnt; i++) { | 94 | for (i = 0; i < pgcnt; i++) { |
100 | err = mtdtest_write(mtd, addr, pgsize, buf); | 95 | err = mtdtest_write(mtd, addr, pgsize, buf); |
101 | if (err) { | 96 | if (err) |
102 | pr_err("error: write failed at %#llx\n", | ||
103 | addr); | ||
104 | break; | 97 | break; |
105 | } | ||
106 | addr += pgsize; | 98 | addr += pgsize; |
107 | buf += pgsize; | 99 | buf += pgsize; |
108 | } | 100 | } |
@@ -119,21 +111,13 @@ static int write_eraseblock_by_2pages(int ebnum) | |||
119 | 111 | ||
120 | for (i = 0; i < n; i++) { | 112 | for (i = 0; i < n; i++) { |
121 | err = mtdtest_write(mtd, addr, sz, buf); | 113 | err = mtdtest_write(mtd, addr, sz, buf); |
122 | if (err) { | 114 | if (err) |
123 | pr_err("error: write failed at %#llx\n", | ||
124 | addr); | ||
125 | return err; | 115 | return err; |
126 | } | ||
127 | addr += sz; | 116 | addr += sz; |
128 | buf += sz; | 117 | buf += sz; |
129 | } | 118 | } |
130 | if (pgcnt % 2) { | 119 | if (pgcnt % 2) |
131 | err = mtdtest_write(mtd, addr, pgsize, buf); | 120 | err = mtdtest_write(mtd, addr, pgsize, buf); |
132 | if (err) { | ||
133 | pr_err("error: write failed at %#llx\n", | ||
134 | addr); | ||
135 | } | ||
136 | } | ||
137 | 121 | ||
138 | return err; | 122 | return err; |
139 | } | 123 | } |
diff --git a/drivers/mtd/tests/stresstest.c b/drivers/mtd/tests/stresstest.c index 6c9e23f40cbc..c9d42cc2df1b 100644 --- a/drivers/mtd/tests/stresstest.c +++ b/drivers/mtd/tests/stresstest.c | |||
@@ -126,11 +126,8 @@ static int do_write(void) | |||
126 | } | 126 | } |
127 | addr = eb * mtd->erasesize + offs; | 127 | addr = eb * mtd->erasesize + offs; |
128 | err = mtdtest_write(mtd, addr, len, writebuf); | 128 | err = mtdtest_write(mtd, addr, len, writebuf); |
129 | if (unlikely(err)) { | 129 | if (unlikely(err)) |
130 | pr_err("error: write failed at 0x%llx\n", | ||
131 | (long long)addr); | ||
132 | return err; | 130 | return err; |
133 | } | ||
134 | offs += len; | 131 | offs += len; |
135 | while (offs > mtd->erasesize) { | 132 | while (offs > mtd->erasesize) { |
136 | offsets[eb++] = mtd->erasesize; | 133 | offsets[eb++] = mtd->erasesize; |