drivers/mtd/rfd_ftl.c
Source file repositories/reference/linux-study-clean/drivers/mtd/rfd_ftl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/rfd_ftl.c- Extension
.c- Size
- 18316 bytes
- Lines
- 830
- 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.
- 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/hdreg.hlinux/init.hlinux/mtd/blktrans.hlinux/mtd/mtd.hlinux/vmalloc.hlinux/slab.hlinux/jiffies.hlinux/module.hasm/types.h
Detected Declarations
struct blockstruct partitionfunction build_block_mapfunction scan_headerfunction rfd_ftl_readsectfunction erase_blockfunction move_block_contentsfunction reclaim_blockfunction find_free_blockfunction find_writable_blockfunction mark_sector_deletedfunction find_free_sectorfunction do_writesectfunction rfd_ftl_writesectfunction rfd_ftl_discardsectfunction rfd_ftl_getgeofunction rfd_ftl_add_mtdfunction rfd_ftl_remove_dev
Annotated Snippet
struct block {
enum {
BLOCK_OK,
BLOCK_ERASING,
BLOCK_ERASED,
BLOCK_UNUSED,
BLOCK_FAILED
} state;
int free_sectors;
int used_sectors;
int erases;
u_long offset;
};
struct partition {
struct mtd_blktrans_dev mbd;
u_int block_size; /* size of erase unit */
u_int total_blocks; /* number of erase units */
u_int header_sectors_per_block; /* header sectors in erase unit */
u_int data_sectors_per_block; /* data sectors in erase unit */
u_int sector_count; /* sectors in translated disk */
u_int header_size; /* bytes in header sector */
int reserved_block; /* block next up for reclaim */
int current_block; /* block to write to */
u16 *header_cache; /* cached header */
int is_reclaiming;
int cylinders;
int errors;
u_long *sector_map;
struct block *blocks;
};
static int rfd_ftl_writesect(struct mtd_blktrans_dev *dev, u_long sector, char *buf);
static int build_block_map(struct partition *part, int block_no)
{
struct block *block = &part->blocks[block_no];
int i;
block->offset = part->block_size * block_no;
if (le16_to_cpu(part->header_cache[0]) != RFD_MAGIC) {
block->state = BLOCK_UNUSED;
return -ENOENT;
}
block->state = BLOCK_OK;
for (i=0; i<part->data_sectors_per_block; i++) {
u16 entry;
entry = le16_to_cpu(part->header_cache[HEADER_MAP_OFFSET + i]);
if (entry == SECTOR_DELETED)
continue;
if (entry == SECTOR_FREE) {
block->free_sectors++;
continue;
}
if (entry == SECTOR_ZERO)
entry = 0;
if (entry >= part->sector_count) {
printk(KERN_WARNING PREFIX
"'%s': unit #%d: entry %d corrupt, "
"sector %d out of range\n",
part->mbd.mtd->name, block_no, i, entry);
continue;
}
if (part->sector_map[entry] != -1) {
printk(KERN_WARNING PREFIX
"'%s': more than one entry for sector %d\n",
part->mbd.mtd->name, entry);
part->errors = 1;
continue;
}
part->sector_map[entry] = block->offset +
(i + part->header_sectors_per_block) * SECTOR_SIZE;
block->used_sectors++;
}
if (block->free_sectors == part->data_sectors_per_block)
part->reserved_block = block_no;
Annotation
- Immediate include surface: `linux/hdreg.h`, `linux/init.h`, `linux/mtd/blktrans.h`, `linux/mtd/mtd.h`, `linux/vmalloc.h`, `linux/slab.h`, `linux/jiffies.h`, `linux/module.h`.
- Detected declarations: `struct block`, `struct partition`, `function build_block_map`, `function scan_header`, `function rfd_ftl_readsect`, `function erase_block`, `function move_block_contents`, `function reclaim_block`, `function find_free_block`, `function find_writable_block`.
- 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.