Lines Matching +full:read +full:- +full:out
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2006-2008 Artem Bityutskiy
4 * Copyright (C) 2006-2008 Jarkko Lavinen
5 * Copyright (C) 2006-2008 Adrian Hunter
40 static int dev = -EINVAL;
73 static void report_corrupt(unsigned char *read, unsigned char *written);
92 size_t read; in check_eraseblock() local
93 loff_t addr = (loff_t)ebnum * mtd->erasesize; in check_eraseblock()
94 size_t len = mtd->erasesize; in check_eraseblock()
97 addr = (loff_t)(ebnum + 1) * mtd->erasesize - pgcnt * pgsize; in check_eraseblock()
102 err = mtd_read(mtd, addr, len, &read, check_buf); in check_eraseblock()
108 "read %zd\n", err, ebnum, read); in check_eraseblock()
112 if (read != len) { in check_eraseblock()
113 pr_err("failed to read %zd bytes from EB %d, " in check_eraseblock()
114 "read only %zd, but no error reported\n", in check_eraseblock()
115 len, ebnum, read); in check_eraseblock()
116 return -EIO; in check_eraseblock()
120 pr_err("read wrong data from EB %d\n", ebnum); in check_eraseblock()
124 /* Try read again */ in check_eraseblock()
126 pr_info("re-try reading data from EB %d\n", in check_eraseblock()
131 "give-up\n", RETRIES); in check_eraseblock()
132 return -EINVAL; in check_eraseblock()
147 loff_t addr = (loff_t)ebnum * mtd->erasesize; in write_pattern()
148 size_t len = mtd->erasesize; in write_pattern()
151 addr = (loff_t)(ebnum + 1) * mtd->erasesize - pgcnt * pgsize; in write_pattern()
163 return -EIO; in write_pattern()
176 pr_info("Warning: this program is trying to wear out your " in tort_init()
180 pr_info("Please specify a valid mtd-device via module parameter\n"); in tort_init()
182 return -EINVAL; in tort_init()
186 pr_info("torture %d eraseblocks (%d-%d) of mtd%d\n", in tort_init()
187 ebcnt, eb, eb + ebcnt - 1, dev); in tort_init()
200 if (mtd->writesize == 1) { in tort_init()
205 pgsize = mtd->writesize; in tort_init()
207 if (pgcnt && (pgcnt > mtd->erasesize / pgsize || pgcnt < 0)) { in tort_init()
212 err = -ENOMEM; in tort_init()
213 patt_5A5 = kmalloc(mtd->erasesize, GFP_KERNEL); in tort_init()
217 patt_A5A = kmalloc(mtd->erasesize, GFP_KERNEL); in tort_init()
221 patt_FF = kmalloc(mtd->erasesize, GFP_KERNEL); in tort_init()
225 check_buf = kmalloc(mtd->erasesize, GFP_KERNEL); in tort_init()
234 memset(patt_FF, 0xFF, mtd->erasesize); in tort_init()
235 for (i = 0; i < mtd->erasesize / pgsize; i++) { in tort_init()
247 goto out; in tort_init()
256 goto out; in tort_init()
261 if (bad_ebs[i - eb]) in tort_init()
267 goto out; in tort_init()
272 goto out; in tort_init()
278 if (bad_ebs[i - eb]) in tort_init()
286 goto out; in tort_init()
290 goto out; in tort_init()
296 if (bad_ebs[i - eb]) in tort_init()
308 goto out; in tort_init()
313 goto out; in tort_init()
330 if (!infinite && --cycles_count == 0) in tort_init()
333 out: in tort_init()
364 static void print_bufs(unsigned char *read, unsigned char *written, int start,
368 * Report the detailed information about how the read EB differs from what was
371 static void report_corrupt(unsigned char *read, unsigned char *written) in report_corrupt() argument
376 size_t check_len = mtd->erasesize; in report_corrupt()
383 if (countdiffs(written, read, i, pgsize, &bytes, in report_corrupt()
390 " what was read from flash and what was expected\n"); in report_corrupt()
395 first = countdiffs(written, read, i, pgsize, &bytes, in report_corrupt()
400 printk("-------------------------------------------------------" in report_corrupt()
401 "----------------------------------\n"); in report_corrupt()
405 (mtd->erasesize - check_len + i) / pgsize, in report_corrupt()
409 len = ((first + bytes) | 0x7) + 1 - offset; in report_corrupt()
411 print_bufs(read, written, offset, len); in report_corrupt()
415 static void print_bufs(unsigned char *read, unsigned char *written, int start, in print_bufs() argument
421 printk("Offset Read Written\n"); in print_bufs()
426 printk(" %02x", read[start + i + j1]); in print_bufs()
427 if (read[start + i + j1] != written[start + i + j1]) in print_bufs()
454 int first = -1; in countdiffs()