aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2013-08-15 09:55:08 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2013-08-30 16:36:05 -0400
commitabc173ad84e50645f9136ea56afa9f86c98bf349 (patch)
treeab33103502169514f85a0a5013b015f5c3f1f3c0 /drivers/mtd
parent0d58f6ee0106256c47db9640141469d1ed80819a (diff)
mtd: tests: incorporate error message for mtdtest_read()
All callers of mtdtest_read() print the same error message on failure. This incorporates the error message to mtdtest_read() 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')
-rw-r--r--drivers/mtd/tests/mtd_test.c2
-rw-r--r--drivers/mtd/tests/pagetest.c55
-rw-r--r--drivers/mtd/tests/readtest.c2
-rw-r--r--drivers/mtd/tests/speedtest.c24
-rw-r--r--drivers/mtd/tests/stresstest.c10
5 files changed, 17 insertions, 76 deletions
diff --git a/drivers/mtd/tests/mtd_test.c b/drivers/mtd/tests/mtd_test.c
index bda8c4de3433..4c2e3f0bb953 100644
--- a/drivers/mtd/tests/mtd_test.c
+++ b/drivers/mtd/tests/mtd_test.c
@@ -92,6 +92,8 @@ int mtdtest_read(struct mtd_info *mtd, loff_t addr, size_t size, void *buf)
92 err = 0; 92 err = 0;
93 if (!err && read != size) 93 if (!err && read != size)
94 err = -EIO; 94 err = -EIO;
95 if (err)
96 pr_err("error: read failed at %#llx\n", addr);
95 97
96 return err; 98 return err;
97} 99}
diff --git a/drivers/mtd/tests/pagetest.c b/drivers/mtd/tests/pagetest.c
index 83189765eb05..9e8329c5d96d 100644
--- a/drivers/mtd/tests/pagetest.c
+++ b/drivers/mtd/tests/pagetest.c
@@ -84,24 +84,15 @@ static int verify_eraseblock(int ebnum)
84 for (j = 0; j < pgcnt - 1; ++j, addr += pgsize) { 84 for (j = 0; j < pgcnt - 1; ++j, addr += pgsize) {
85 /* Do a read to set the internal dataRAMs to different data */ 85 /* Do a read to set the internal dataRAMs to different data */
86 err = mtdtest_read(mtd, addr0, bufsize, twopages); 86 err = mtdtest_read(mtd, addr0, bufsize, twopages);
87 if (err) { 87 if (err)
88 pr_err("error: read failed at %#llx\n",
89 (long long)addr0);
90 return err; 88 return err;
91 }
92 err = mtdtest_read(mtd, addrn - bufsize, bufsize, twopages); 89 err = mtdtest_read(mtd, addrn - bufsize, bufsize, twopages);
93 if (err) { 90 if (err)
94 pr_err("error: read failed at %#llx\n",
95 (long long)(addrn - bufsize));
96 return err; 91 return err;
97 }
98 memset(twopages, 0, bufsize); 92 memset(twopages, 0, bufsize);
99 err = mtdtest_read(mtd, addr, bufsize, twopages); 93 err = mtdtest_read(mtd, addr, bufsize, twopages);
100 if (err) { 94 if (err)
101 pr_err("error: read failed at %#llx\n",
102 (long long)addr);
103 break; 95 break;
104 }
105 if (memcmp(twopages, writebuf + (j * pgsize), bufsize)) { 96 if (memcmp(twopages, writebuf + (j * pgsize), bufsize)) {
106 pr_err("error: verify failed at %#llx\n", 97 pr_err("error: verify failed at %#llx\n",
107 (long long)addr); 98 (long long)addr);
@@ -114,24 +105,15 @@ static int verify_eraseblock(int ebnum)
114 105
115 /* Do a read to set the internal dataRAMs to different data */ 106 /* Do a read to set the internal dataRAMs to different data */
116 err = mtdtest_read(mtd, addr0, bufsize, twopages); 107 err = mtdtest_read(mtd, addr0, bufsize, twopages);
117 if (err) { 108 if (err)
118 pr_err("error: read failed at %#llx\n",
119 (long long)addr0);
120 return err; 109 return err;
121 }
122 err = mtdtest_read(mtd, addrn - bufsize, bufsize, twopages); 110 err = mtdtest_read(mtd, addrn - bufsize, bufsize, twopages);
123 if (err) { 111 if (err)
124 pr_err("error: read failed at %#llx\n",
125 (long long)(addrn - bufsize));
126 return err; 112 return err;
127 }
128 memset(twopages, 0, bufsize); 113 memset(twopages, 0, bufsize);
129 err = mtdtest_read(mtd, addr, bufsize, twopages); 114 err = mtdtest_read(mtd, addr, bufsize, twopages);
130 if (err) { 115 if (err)
131 pr_err("error: read failed at %#llx\n",
132 (long long)addr);
133 return err; 116 return err;
134 }
135 memcpy(boundary, writebuf + mtd->erasesize - pgsize, pgsize); 117 memcpy(boundary, writebuf + mtd->erasesize - pgsize, pgsize);
136 prandom_bytes_state(&rnd_state, boundary + pgsize, pgsize); 118 prandom_bytes_state(&rnd_state, boundary + pgsize, pgsize);
137 if (memcmp(twopages, boundary, bufsize)) { 119 if (memcmp(twopages, boundary, bufsize)) {
@@ -171,8 +153,6 @@ static int crosstest(void)
171 addr = addrn - pgsize - pgsize; 153 addr = addrn - pgsize - pgsize;
172 err = mtdtest_read(mtd, addr, pgsize, pp1); 154 err = mtdtest_read(mtd, addr, pgsize, pp1);
173 if (err) { 155 if (err) {
174 pr_err("error: read failed at %#llx\n",
175 (long long)addr);
176 kfree(pp1); 156 kfree(pp1);
177 return err; 157 return err;
178 } 158 }
@@ -181,8 +161,6 @@ static int crosstest(void)
181 addr = addrn - pgsize - pgsize - pgsize; 161 addr = addrn - pgsize - pgsize - pgsize;
182 err = mtdtest_read(mtd, addr, pgsize, pp1); 162 err = mtdtest_read(mtd, addr, pgsize, pp1);
183 if (err) { 163 if (err) {
184 pr_err("error: read failed at %#llx\n",
185 (long long)addr);
186 kfree(pp1); 164 kfree(pp1);
187 return err; 165 return err;
188 } 166 }
@@ -192,8 +170,6 @@ static int crosstest(void)
192 pr_info("reading page at %#llx\n", (long long)addr); 170 pr_info("reading page at %#llx\n", (long long)addr);
193 err = mtdtest_read(mtd, addr, pgsize, pp2); 171 err = mtdtest_read(mtd, addr, pgsize, pp2);
194 if (err) { 172 if (err) {
195 pr_err("error: read failed at %#llx\n",
196 (long long)addr);
197 kfree(pp1); 173 kfree(pp1);
198 return err; 174 return err;
199 } 175 }
@@ -203,8 +179,6 @@ static int crosstest(void)
203 pr_info("reading page at %#llx\n", (long long)addr); 179 pr_info("reading page at %#llx\n", (long long)addr);
204 err = mtdtest_read(mtd, addr, pgsize, pp3); 180 err = mtdtest_read(mtd, addr, pgsize, pp3);
205 if (err) { 181 if (err) {
206 pr_err("error: read failed at %#llx\n",
207 (long long)addr);
208 kfree(pp1); 182 kfree(pp1);
209 return err; 183 return err;
210 } 184 }
@@ -214,8 +188,6 @@ static int crosstest(void)
214 pr_info("reading page at %#llx\n", (long long)addr); 188 pr_info("reading page at %#llx\n", (long long)addr);
215 err = mtdtest_read(mtd, addr, pgsize, pp4); 189 err = mtdtest_read(mtd, addr, pgsize, pp4);
216 if (err) { 190 if (err) {
217 pr_err("error: read failed at %#llx\n",
218 (long long)addr);
219 kfree(pp1); 191 kfree(pp1);
220 return err; 192 return err;
221 } 193 }
@@ -269,11 +241,8 @@ static int erasecrosstest(void)
269 pr_info("reading 1st page of block %d\n", ebnum); 241 pr_info("reading 1st page of block %d\n", ebnum);
270 memset(readbuf, 0, pgsize); 242 memset(readbuf, 0, pgsize);
271 err = mtdtest_read(mtd, addr0, pgsize, readbuf); 243 err = mtdtest_read(mtd, addr0, pgsize, readbuf);
272 if (err) { 244 if (err)
273 pr_err("error: read failed at %#llx\n",
274 (long long)addr0);
275 return err; 245 return err;
276 }
277 246
278 pr_info("verifying 1st page of block %d\n", ebnum); 247 pr_info("verifying 1st page of block %d\n", ebnum);
279 if (memcmp(writebuf, readbuf, pgsize)) { 248 if (memcmp(writebuf, readbuf, pgsize)) {
@@ -305,11 +274,8 @@ static int erasecrosstest(void)
305 pr_info("reading 1st page of block %d\n", ebnum); 274 pr_info("reading 1st page of block %d\n", ebnum);
306 memset(readbuf, 0, pgsize); 275 memset(readbuf, 0, pgsize);
307 err = mtdtest_read(mtd, addr0, pgsize, readbuf); 276 err = mtdtest_read(mtd, addr0, pgsize, readbuf);
308 if (err) { 277 if (err)
309 pr_err("error: read failed at %#llx\n",
310 (long long)addr0);
311 return err; 278 return err;
312 }
313 279
314 pr_info("verifying 1st page of block %d\n", ebnum); 280 pr_info("verifying 1st page of block %d\n", ebnum);
315 if (memcmp(writebuf, readbuf, pgsize)) { 281 if (memcmp(writebuf, readbuf, pgsize)) {
@@ -358,11 +324,8 @@ static int erasetest(void)
358 324
359 pr_info("reading 1st page of block %d\n", ebnum); 325 pr_info("reading 1st page of block %d\n", ebnum);
360 err = mtdtest_read(mtd, addr0, pgsize, twopages); 326 err = mtdtest_read(mtd, addr0, pgsize, twopages);
361 if (err) { 327 if (err)
362 pr_err("error: read failed at %#llx\n",
363 (long long)addr0);
364 return err; 328 return err;
365 }
366 329
367 pr_info("verifying 1st page of block %d is all 0xff\n", 330 pr_info("verifying 1st page of block %d is all 0xff\n",
368 ebnum); 331 ebnum);
diff --git a/drivers/mtd/tests/readtest.c b/drivers/mtd/tests/readtest.c
index ffd50d628219..626e66d0f7e7 100644
--- a/drivers/mtd/tests/readtest.c
+++ b/drivers/mtd/tests/readtest.c
@@ -55,8 +55,6 @@ static int read_eraseblock_by_page(int ebnum)
55 memset(buf, 0 , pgsize); 55 memset(buf, 0 , pgsize);
56 ret = mtdtest_read(mtd, addr, pgsize, buf); 56 ret = mtdtest_read(mtd, addr, pgsize, buf);
57 if (ret) { 57 if (ret) {
58 pr_err("error: read failed at %#llx\n",
59 (long long)addr);
60 if (!err) 58 if (!err)
61 err = ret; 59 err = ret;
62 } 60 }
diff --git a/drivers/mtd/tests/speedtest.c b/drivers/mtd/tests/speedtest.c
index 457c45c6a704..d1a38530612e 100644
--- a/drivers/mtd/tests/speedtest.c
+++ b/drivers/mtd/tests/speedtest.c
@@ -140,14 +140,9 @@ static int write_eraseblock_by_2pages(int ebnum)
140 140
141static int read_eraseblock(int ebnum) 141static int read_eraseblock(int ebnum)
142{ 142{
143 int err;
144 loff_t addr = ebnum * mtd->erasesize; 143 loff_t addr = ebnum * mtd->erasesize;
145 144
146 err = mtdtest_read(mtd, addr, mtd->erasesize, iobuf); 145 return mtdtest_read(mtd, addr, mtd->erasesize, iobuf);
147 if (err)
148 pr_err("error: read failed at %#llx\n", addr);
149
150 return err;
151} 146}
152 147
153static int read_eraseblock_by_page(int ebnum) 148static int read_eraseblock_by_page(int ebnum)
@@ -158,11 +153,8 @@ static int read_eraseblock_by_page(int ebnum)
158 153
159 for (i = 0; i < pgcnt; i++) { 154 for (i = 0; i < pgcnt; i++) {
160 err = mtdtest_read(mtd, addr, pgsize, buf); 155 err = mtdtest_read(mtd, addr, pgsize, buf);
161 if (err) { 156 if (err)
162 pr_err("error: read failed at %#llx\n",
163 addr);
164 break; 157 break;
165 }
166 addr += pgsize; 158 addr += pgsize;
167 buf += pgsize; 159 buf += pgsize;
168 } 160 }
@@ -179,21 +171,13 @@ static int read_eraseblock_by_2pages(int ebnum)
179 171
180 for (i = 0; i < n; i++) { 172 for (i = 0; i < n; i++) {
181 err = mtdtest_read(mtd, addr, sz, buf); 173 err = mtdtest_read(mtd, addr, sz, buf);
182 if (err) { 174 if (err)
183 pr_err("error: read failed at %#llx\n",
184 addr);
185 return err; 175 return err;
186 }
187 addr += sz; 176 addr += sz;
188 buf += sz; 177 buf += sz;
189 } 178 }
190 if (pgcnt % 2) { 179 if (pgcnt % 2)
191 err = mtdtest_read(mtd, addr, pgsize, buf); 180 err = mtdtest_read(mtd, addr, pgsize, buf);
192 if (err) {
193 pr_err("error: read failed at %#llx\n",
194 addr);
195 }
196 }
197 181
198 return err; 182 return err;
199} 183}
diff --git a/drivers/mtd/tests/stresstest.c b/drivers/mtd/tests/stresstest.c
index 169524845401..6c9e23f40cbc 100644
--- a/drivers/mtd/tests/stresstest.c
+++ b/drivers/mtd/tests/stresstest.c
@@ -87,7 +87,7 @@ static int do_read(void)
87{ 87{
88 int eb = rand_eb(); 88 int eb = rand_eb();
89 int offs = rand_offs(); 89 int offs = rand_offs();
90 int len = rand_len(offs), err; 90 int len = rand_len(offs);
91 loff_t addr; 91 loff_t addr;
92 92
93 if (bbt[eb + 1]) { 93 if (bbt[eb + 1]) {
@@ -97,13 +97,7 @@ static int do_read(void)
97 len = mtd->erasesize - offs; 97 len = mtd->erasesize - offs;
98 } 98 }
99 addr = eb * mtd->erasesize + offs; 99 addr = eb * mtd->erasesize + offs;
100 err = mtdtest_read(mtd, addr, len, readbuf); 100 return mtdtest_read(mtd, addr, len, readbuf);
101 if (unlikely(err)) {
102 pr_err("error: read failed at 0x%llx\n",
103 (long long)addr);
104 return err;
105 }
106 return 0;
107} 101}
108 102
109static int do_write(void) 103static int do_write(void)