drivers/staging/axis-fifo/axis-fifo.c
Source file repositories/reference/linux-study-clean/drivers/staging/axis-fifo/axis-fifo.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/axis-fifo/axis-fifo.c- Extension
.c- Size
- 13881 bytes
- Lines
- 543
- Domain
- Driver Families
- Bucket
- drivers/staging
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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.
- 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/kernel.hlinux/of.hlinux/platform_device.hlinux/wait.hlinux/mutex.hlinux/device.hlinux/cdev.hlinux/init.hlinux/module.hlinux/slab.hlinux/io.hlinux/interrupt.hlinux/fs.hlinux/types.hlinux/uaccess.hlinux/jiffies.hlinux/miscdevice.hlinux/debugfs.hlinux/poll.h
Detected Declarations
struct axis_fifostruct axis_fifo_debug_regfunction reset_ip_corefunction axis_fifo_readfunction axis_fifo_writefunction axis_fifo_pollfunction axis_fifo_irqfunction axis_fifo_openfunction axis_fifo_debugfs_regs_showfunction axis_fifo_debugfs_initfunction axis_fifo_parse_dtfunction axis_fifo_probefunction axis_fifo_removefunction axis_fifo_initfunction axis_fifo_exitmodule init axis_fifo_init
Annotated Snippet
static const struct file_operations fops = {
.owner = THIS_MODULE,
.open = axis_fifo_open,
.read = axis_fifo_read,
.write = axis_fifo_write,
.poll = axis_fifo_poll,
};
static int axis_fifo_debugfs_regs_show(struct seq_file *m, void *p)
{
static const struct axis_fifo_debug_reg regs[] = {
{"isr", XLLF_ISR_OFFSET},
{"ier", XLLF_IER_OFFSET},
{"tdfv", XLLF_TDFV_OFFSET},
{"rdfo", XLLF_RDFO_OFFSET},
{ /* Sentinel */ },
};
const struct axis_fifo_debug_reg *reg;
struct axis_fifo *fifo = m->private;
for (reg = regs; reg->name; ++reg) {
u32 val = ioread32(fifo->base_addr + reg->offset);
seq_printf(m, "%*s: 0x%08x\n", AXIS_FIFO_DEBUG_REG_NAME_MAX_LEN,
reg->name, val);
}
return 0;
}
DEFINE_SHOW_ATTRIBUTE(axis_fifo_debugfs_regs);
static void axis_fifo_debugfs_init(struct axis_fifo *fifo)
{
fifo->debugfs_dir = debugfs_create_dir(dev_name(fifo->dt_device), NULL);
debugfs_create_file("regs", 0444, fifo->debugfs_dir, fifo,
&axis_fifo_debugfs_regs_fops);
}
static int axis_fifo_parse_dt(struct axis_fifo *fifo)
{
int ret;
unsigned int value;
struct device_node *node = fifo->dt_device->of_node;
ret = of_property_read_u32(node, "xlnx,axi-str-rxd-tdata-width",
&value);
if (ret)
return ret;
if (value != 32)
return -EINVAL;
ret = of_property_read_u32(node, "xlnx,axi-str-txd-tdata-width",
&value);
if (ret)
return ret;
if (value != 32)
return -EINVAL;
ret = of_property_read_u32(node, "xlnx,rx-fifo-depth",
&fifo->rx_fifo_depth);
if (ret)
return ret;
ret = of_property_read_u32(node, "xlnx,tx-fifo-depth",
&fifo->tx_fifo_depth);
if (ret)
return ret;
ret = of_property_read_u32(node, "xlnx,use-rx-data",
&fifo->has_rx_fifo);
if (ret)
return ret;
ret = of_property_read_u32(node, "xlnx,use-tx-data",
&fifo->has_tx_fifo);
if (ret)
return ret;
return 0;
}
static int axis_fifo_probe(struct platform_device *pdev)
{
struct resource *r_mem;
struct device *dev = &pdev->dev;
struct axis_fifo *fifo = NULL;
int rc = 0; /* error return value */
int irq;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/of.h`, `linux/platform_device.h`, `linux/wait.h`, `linux/mutex.h`, `linux/device.h`, `linux/cdev.h`, `linux/init.h`.
- Detected declarations: `struct axis_fifo`, `struct axis_fifo_debug_reg`, `function reset_ip_core`, `function axis_fifo_read`, `function axis_fifo_write`, `function axis_fifo_poll`, `function axis_fifo_irq`, `function axis_fifo_open`, `function axis_fifo_debugfs_regs_show`, `function axis_fifo_debugfs_init`.
- Atlas domain: Driver Families / drivers/staging.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.