drivers/misc/xilinx_sdfec.c
Source file repositories/reference/linux-study-clean/drivers/misc/xilinx_sdfec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/misc/xilinx_sdfec.c- Extension
.c- Size
- 38660 bytes
- Lines
- 1455
- Domain
- Driver Families
- Bucket
- drivers/misc
- 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/miscdevice.hlinux/io.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/poll.hlinux/slab.hlinux/clk.hlinux/compat.hlinux/highmem.huapi/misc/xilinx_sdfec.h
Detected Declarations
struct xsdfec_clksstruct xsdfec_devfunction xsdfec_regwritefunction xsdfec_regreadfunction update_bool_config_from_regfunction update_config_from_hwfunction xsdfec_get_statusfunction xsdfec_get_configfunction xsdfec_isr_enablefunction xsdfec_ecc_isr_enablefunction xsdfec_set_irqfunction xsdfec_set_turbofunction xsdfec_get_turbofunction xsdfec_reg0_writefunction xsdfec_reg1_writefunction xsdfec_reg2_writefunction xsdfec_reg3_writefunction xsdfec_table_writefunction Scalefunction xsdfec_add_ldpcfunction xsdfec_set_orderfunction xsdfec_set_bypassfunction xsdfec_is_activefunction xsdfec_translate_axis_width_cfg_valfunction xsdfec_translate_axis_words_cfg_valfunction xsdfec_cfg_axi_streamsfunction xsdfec_startfunction xsdfec_stopfunction xsdfec_clear_statsfunction xsdfec_get_statsfunction xsdfec_set_default_configfunction xsdfec_dev_ioctlfunction xsdfec_pollfunction xsdfec_parse_offunction xsdfec_irq_threadfunction xsdfec_clk_initfunction xsdfec_disable_all_clksfunction xsdfec_probefunction xsdfec_remove
Annotated Snippet
static const struct file_operations xsdfec_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = xsdfec_dev_ioctl,
.poll = xsdfec_poll,
.compat_ioctl = compat_ptr_ioctl,
};
static int xsdfec_parse_of(struct xsdfec_dev *xsdfec)
{
struct device *dev = xsdfec->dev;
struct device_node *node = dev->of_node;
int rval;
const char *fec_code;
u32 din_width;
u32 din_word_include;
u32 dout_width;
u32 dout_word_include;
rval = of_property_read_string(node, "xlnx,sdfec-code", &fec_code);
if (rval < 0)
return rval;
if (!strcasecmp(fec_code, "ldpc"))
xsdfec->config.code = XSDFEC_LDPC_CODE;
else if (!strcasecmp(fec_code, "turbo"))
xsdfec->config.code = XSDFEC_TURBO_CODE;
else
return -EINVAL;
rval = of_property_read_u32(node, "xlnx,sdfec-din-words",
&din_word_include);
if (rval < 0)
return rval;
if (din_word_include < XSDFEC_AXIS_WORDS_INCLUDE_MAX)
xsdfec->config.din_word_include = din_word_include;
else
return -EINVAL;
rval = of_property_read_u32(node, "xlnx,sdfec-din-width", &din_width);
if (rval < 0)
return rval;
switch (din_width) {
/* Fall through and set for valid values */
case XSDFEC_1x128b:
case XSDFEC_2x128b:
case XSDFEC_4x128b:
xsdfec->config.din_width = din_width;
break;
default:
return -EINVAL;
}
rval = of_property_read_u32(node, "xlnx,sdfec-dout-words",
&dout_word_include);
if (rval < 0)
return rval;
if (dout_word_include < XSDFEC_AXIS_WORDS_INCLUDE_MAX)
xsdfec->config.dout_word_include = dout_word_include;
else
return -EINVAL;
rval = of_property_read_u32(node, "xlnx,sdfec-dout-width", &dout_width);
if (rval < 0)
return rval;
switch (dout_width) {
/* Fall through and set for valid values */
case XSDFEC_1x128b:
case XSDFEC_2x128b:
case XSDFEC_4x128b:
xsdfec->config.dout_width = dout_width;
break;
default:
return -EINVAL;
}
/* Write LDPC to CODE Register */
xsdfec_regwrite(xsdfec, XSDFEC_FEC_CODE_ADDR, xsdfec->config.code);
xsdfec_cfg_axi_streams(xsdfec);
return 0;
}
static irqreturn_t xsdfec_irq_thread(int irq, void *dev_id)
{
struct xsdfec_dev *xsdfec = dev_id;
Annotation
- Immediate include surface: `linux/miscdevice.h`, `linux/io.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/poll.h`.
- Detected declarations: `struct xsdfec_clks`, `struct xsdfec_dev`, `function xsdfec_regwrite`, `function xsdfec_regread`, `function update_bool_config_from_reg`, `function update_config_from_hw`, `function xsdfec_get_status`, `function xsdfec_get_config`, `function xsdfec_isr_enable`, `function xsdfec_ecc_isr_enable`.
- Atlas domain: Driver Families / drivers/misc.
- 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.