drivers/mtd/nand/raw/denali.c
Source file repositories/reference/linux-study-clean/drivers/mtd/nand/raw/denali.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/nand/raw/denali.c- Extension
.c- Size
- 37647 bytes
- Lines
- 1382
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/completion.hlinux/dma-mapping.hlinux/interrupt.hlinux/io.hlinux/module.hlinux/mtd/mtd.hlinux/mtd/rawnand.hlinux/slab.hlinux/spinlock.hdenali.h
Detected Declarations
function Copyrightfunction denali_direct_readfunction denali_direct_writefunction denali_indexed_readfunction denali_indexed_writefunction denali_enable_irqfunction denali_disable_irqfunction denali_clear_irqfunction denali_clear_irq_allfunction denali_isrfunction denali_reset_irqfunction denali_wait_for_irqfunction denali_select_targetfunction denali_change_columnfunction denali_payload_xferfunction denali_oob_xferfunction denali_read_rawfunction denali_write_rawfunction denali_read_page_rawfunction denali_write_page_rawfunction denali_read_oobfunction denali_write_oobfunction denali_check_erased_pagefunction denali_hw_ecc_fixupfunction denali_sw_ecc_fixupfunction denali_setup_dma64function denali_setup_dma32function denali_pio_readfunction denali_pio_writefunction denali_pio_xferfunction denali_dma_xferfunction denali_page_xferfunction denali_read_pagefunction denali_write_pagefunction denali_setup_interfacefunction denali_calc_ecc_bytesfunction denali_ooblayout_eccfunction denali_ooblayout_freefunction denali_multidev_fixupfunction denali_attach_chipfunction denali_exec_in8function denali_exec_in16function denali_exec_infunction denali_exec_out8function denali_exec_out16function denali_exec_outfunction denali_exec_waitrdyfunction denali_exec_instr
Annotated Snippet
if (pos >= writesize) {
pos += oob_skip;
} else if (pos + len > writesize) {
/* This chunk overwraps the BBM area. Must be split */
ret = denali_change_column(chip, pos, buf,
writesize - pos, write);
if (ret)
return ret;
buf += writesize - pos;
len -= writesize - pos;
pos = writesize + oob_skip;
}
ret = denali_change_column(chip, pos, buf, len, write);
if (ret)
return ret;
buf += len;
}
return 0;
}
static int denali_oob_xfer(struct nand_chip *chip, void *buf, bool write)
{
struct denali_controller *denali = to_denali_controller(chip);
struct mtd_info *mtd = nand_to_mtd(chip);
struct nand_ecc_ctrl *ecc = &chip->ecc;
int writesize = mtd->writesize;
int oobsize = mtd->oobsize;
int oob_skip = denali->oob_skip_bytes;
int ret, i, pos, len;
/* BBM at the beginning of the OOB area */
ret = denali_change_column(chip, writesize, buf, oob_skip, write);
if (ret)
return ret;
buf += oob_skip;
for (i = 0; i < ecc->steps; i++) {
pos = ecc->size + i * (ecc->size + ecc->bytes);
if (i == ecc->steps - 1)
/* The last chunk includes OOB free */
len = writesize + oobsize - pos - oob_skip;
else
len = ecc->bytes;
if (pos >= writesize) {
pos += oob_skip;
} else if (pos + len > writesize) {
/* This chunk overwraps the BBM area. Must be split */
ret = denali_change_column(chip, pos, buf,
writesize - pos, write);
if (ret)
return ret;
buf += writesize - pos;
len -= writesize - pos;
pos = writesize + oob_skip;
}
ret = denali_change_column(chip, pos, buf, len, write);
if (ret)
return ret;
buf += len;
}
return 0;
}
static int denali_read_raw(struct nand_chip *chip, void *buf, void *oob_buf,
int page)
{
int ret;
if (!buf && !oob_buf)
return -EINVAL;
ret = nand_read_page_op(chip, page, 0, NULL, 0);
if (ret)
return ret;
if (buf) {
ret = denali_payload_xfer(chip, buf, false);
if (ret)
return ret;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/completion.h`, `linux/dma-mapping.h`, `linux/interrupt.h`, `linux/io.h`, `linux/module.h`, `linux/mtd/mtd.h`, `linux/mtd/rawnand.h`.
- Detected declarations: `function Copyright`, `function denali_direct_read`, `function denali_direct_write`, `function denali_indexed_read`, `function denali_indexed_write`, `function denali_enable_irq`, `function denali_disable_irq`, `function denali_clear_irq`, `function denali_clear_irq_all`, `function denali_isr`.
- Atlas domain: Driver Families / drivers/mtd.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.