drivers/mtd/spi-nor/debugfs.c
Source file repositories/reference/linux-study-clean/drivers/mtd/spi-nor/debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/spi-nor/debugfs.c- Extension
.c- Size
- 9401 bytes
- Lines
- 326
- Domain
- Driver Families
- Bucket
- drivers/mtd
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/array_size.hlinux/debugfs.hlinux/math64.hlinux/mtd/spi-nor.hlinux/spi/spi.hlinux/spi/spi-mem.hcore.h
Detected Declarations
function spi_nor_print_flagsfunction spi_nor_params_showfunction spi_nor_locked_sectors_map_showfunction spi_nor_print_read_cmdfunction spi_nor_print_pp_cmdfunction spi_nor_capabilities_showfunction spi_nor_debugfs_unregisterfunction spi_nor_debugfs_registerfunction spi_nor_debugfs_shutdown
Annotated Snippet
if (et->size) {
string_get_size(et->size, 1, STRING_UNITS_2, buf,
sizeof(buf));
seq_printf(s, " %02x (%s) [%d]\n", et->opcode, buf, i);
}
}
if (!(nor->flags & SNOR_F_NO_OP_CHIP_ERASE)) {
string_get_size(params->size, 1, STRING_UNITS_2, buf, sizeof(buf));
seq_printf(s, " %02x (%s)\n", params->die_erase_opcode, buf);
}
seq_puts(s, "\nsector map\n");
seq_puts(s, " region (in hex) | erase mask | overlaid\n");
seq_puts(s, " ------------------+------------+---------\n");
for (i = 0; i < erase_map->n_regions; i++) {
u64 start = region[i].offset;
u64 end = start + region[i].size - 1;
u8 erase_mask = region[i].erase_mask;
seq_printf(s, " %08llx-%08llx | [%c%c%c%c] | %s\n",
start, end,
erase_mask & BIT(0) ? '0' : ' ',
erase_mask & BIT(1) ? '1' : ' ',
erase_mask & BIT(2) ? '2' : ' ',
erase_mask & BIT(3) ? '3' : ' ',
region[i].overlaid ? "yes" : "no");
}
if (!spi_nor_has_default_locking_ops(nor))
return 0;
seq_puts(s, "\nlocked sectors\n");
seq_puts(s, " region (in hex) | status | #sectors\n");
seq_puts(s, " ------------------+----------+---------\n");
spi_nor_get_locked_range_sr(nor, nor->dfs_sr_cache, &lock_start, &lock_length);
if (!lock_length || lock_length == params->size) {
seq_printf(s, " %08llx-%08llx | %s | %llu\n", 0ULL, params->size - 1,
lock_length ? " locked" : "unlocked",
div_u64(params->size, min_prot_len));
} else if (!lock_start) {
seq_printf(s, " %08llx-%08llx | %s | %llu\n", 0ULL, lock_length - 1,
" locked", div_u64(lock_length, min_prot_len));
seq_printf(s, " %08llx-%08llx | %s | %llu\n", lock_length, params->size - 1,
"unlocked", div_u64(params->size - lock_length, min_prot_len));
} else {
seq_printf(s, " %08llx-%08llx | %s | %llu\n", 0ULL, lock_start - 1,
"unlocked", div_u64(lock_start, min_prot_len));
seq_printf(s, " %08llx-%08llx | %s | %llu\n", lock_start, params->size - 1,
" locked", div_u64(lock_length, min_prot_len));
}
return 0;
}
DEFINE_SHOW_ATTRIBUTE(spi_nor_params);
static int spi_nor_locked_sectors_map_show(struct seq_file *s, void *data)
{
struct spi_nor *nor = s->private;
struct spi_nor_flash_parameter *params = nor->params;
u64 min_prot_len = spi_nor_get_min_prot_length_sr(nor);
unsigned int sector = 0;
u64 offset = 0;
bool locked;
int i;
seq_printf(s, "Locked sectors map (x: locked, .: unlocked, unit: %lldkiB)\n",
min_prot_len / 1024);
while (offset < params->size) {
seq_printf(s, " 0x%08llx (#%5d): ", offset, sector);
for (i = 0; i < 64 && offset < params->size; i++) {
locked = spi_nor_is_locked_sr(nor, offset, min_prot_len,
nor->dfs_sr_cache);
if (locked)
seq_puts(s, "x");
else
seq_puts(s, ".");
if (((i + 1) % 16) == 0)
seq_puts(s, " ");
offset += min_prot_len;
sector++;
}
seq_puts(s, "\n");
}
return 0;
}
Annotation
- Immediate include surface: `linux/array_size.h`, `linux/debugfs.h`, `linux/math64.h`, `linux/mtd/spi-nor.h`, `linux/spi/spi.h`, `linux/spi/spi-mem.h`, `core.h`.
- Detected declarations: `function spi_nor_print_flags`, `function spi_nor_params_show`, `function spi_nor_locked_sectors_map_show`, `function spi_nor_print_read_cmd`, `function spi_nor_print_pp_cmd`, `function spi_nor_capabilities_show`, `function spi_nor_debugfs_unregister`, `function spi_nor_debugfs_register`, `function spi_nor_debugfs_shutdown`.
- Atlas domain: Driver Families / drivers/mtd.
- Implementation status: source 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.