drivers/mtd/tests/torturetest.c
Source file repositories/reference/linux-study-clean/drivers/mtd/tests/torturetest.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/tests/torturetest.c- Extension
.c- Size
- 11415 bytes
- Lines
- 481
- Domain
- Driver Families
- Bucket
- drivers/mtd
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/ktime.hlinux/module.hlinux/moduleparam.hlinux/err.hlinux/mtd/mtd.hlinux/slab.hlinux/sched.hmtd_test.h
Detected Declarations
function start_timingfunction stop_timingfunction check_eraseblockfunction write_patternfunction tort_initfunction tort_exitfunction report_corruptfunction print_bufsfunction countdiffsmodule init tort_init
Annotated Snippet
module_init(tort_init);
static void __exit tort_exit(void)
{
return;
}
module_exit(tort_exit);
static int countdiffs(unsigned char *buf, unsigned char *check_buf,
unsigned offset, unsigned len, unsigned *bytesp,
unsigned *bitsp);
static void print_bufs(unsigned char *read, unsigned char *written, int start,
int len);
/*
* Report the detailed information about how the read EB differs from what was
* written.
*/
static void report_corrupt(unsigned char *read, unsigned char *written)
{
int i;
int bytes, bits, pages, first;
int offset, len;
size_t check_len = mtd->erasesize;
if (pgcnt)
check_len = pgcnt * pgsize;
bytes = bits = pages = 0;
for (i = 0; i < check_len; i += pgsize)
if (countdiffs(written, read, i, pgsize, &bytes,
&bits) >= 0)
pages++;
pr_info("verify fails on %d pages, %d bytes/%d bits\n",
pages, bytes, bits);
pr_info("The following is a list of all differences between"
" what was read from flash and what was expected\n");
for (i = 0; i < check_len; i += pgsize) {
cond_resched();
bytes = bits = 0;
first = countdiffs(written, read, i, pgsize, &bytes,
&bits);
if (first < 0)
continue;
printk("-------------------------------------------------------"
"----------------------------------\n");
pr_info("Page %zd has %d bytes/%d bits failing verify,"
" starting at offset 0x%x\n",
(mtd->erasesize - check_len + i) / pgsize,
bytes, bits, first);
offset = first & ~0x7;
len = ((first + bytes) | 0x7) + 1 - offset;
print_bufs(read, written, offset, len);
}
}
static void print_bufs(unsigned char *read, unsigned char *written, int start,
int len)
{
int i = 0, j1, j2;
char *diff;
printk("Offset Read Written\n");
while (i < len) {
printk("0x%08x: ", start + i);
diff = " ";
for (j1 = 0; j1 < 8 && i + j1 < len; j1++) {
printk(" %02x", read[start + i + j1]);
if (read[start + i + j1] != written[start + i + j1])
diff = "***";
}
while (j1 < 8) {
printk(" ");
j1 += 1;
}
printk(" %s ", diff);
for (j2 = 0; j2 < 8 && i + j2 < len; j2++)
printk(" %02x", written[start + i + j2]);
printk("\n");
i += 8;
}
Annotation
- Immediate include surface: `linux/init.h`, `linux/ktime.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/err.h`, `linux/mtd/mtd.h`, `linux/slab.h`, `linux/sched.h`.
- Detected declarations: `function start_timing`, `function stop_timing`, `function check_eraseblock`, `function write_pattern`, `function tort_init`, `function tort_exit`, `function report_corrupt`, `function print_bufs`, `function countdiffs`, `module init tort_init`.
- Atlas domain: Driver Families / drivers/mtd.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.