drivers/net/wan/fsl_ucc_hdlc.c
Source file repositories/reference/linux-study-clean/drivers/net/wan/fsl_ucc_hdlc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wan/fsl_ucc_hdlc.c- Extension
.c- Size
- 31569 bytes
- Lines
- 1296
- Domain
- Driver Families
- Bucket
- drivers/net
- 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/delay.hlinux/dma-mapping.hlinux/hdlc.hlinux/init.hlinux/interrupt.hlinux/io.hlinux/irq.hlinux/kernel.hlinux/module.hlinux/netdevice.hlinux/of_address.hlinux/of_irq.hlinux/of_platform.hlinux/platform_device.hlinux/sched.hlinux/skbuff.hlinux/slab.hlinux/spinlock.hlinux/stddef.hsoc/fsl/qe/qe_tdm.huapi/linux/if_arp.hfsl_ucc_hdlc.h
Detected Declarations
function uhdlc_initfunction ucc_hdlc_txfunction hdlc_tx_restartfunction hdlc_tx_donefunction hdlc_rx_donefunction ucc_hdlc_pollfunction ucc_hdlc_irq_handlerfunction uhdlc_ioctlfunction uhdlc_openfunction uhdlc_memcleanfunction uhdlc_closefunction ucc_hdlc_attachfunction store_clk_configfunction resume_clk_configfunction uhdlc_suspendfunction uhdlc_resumefunction uhdlc_tx_timeoutfunction hdlc_map_iomemfunction ucc_hdlc_probefunction ucc_hdlc_remove
Annotated Snippet
static const struct net_device_ops uhdlc_ops = {
.ndo_open = uhdlc_open,
.ndo_stop = uhdlc_close,
.ndo_start_xmit = hdlc_start_xmit,
.ndo_siocwandev = uhdlc_ioctl,
.ndo_tx_timeout = uhdlc_tx_timeout,
};
static int hdlc_map_iomem(char *name, int init_flag, void __iomem **ptr)
{
struct device_node *np;
struct platform_device *pdev;
struct resource *res;
static int siram_init_flag;
int ret = 0;
np = of_find_compatible_node(NULL, NULL, name);
if (!np)
return -EINVAL;
pdev = of_find_device_by_node(np);
if (!pdev) {
pr_err("%pOFn: failed to lookup pdev\n", np);
of_node_put(np);
return -EINVAL;
}
of_node_put(np);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
ret = -EINVAL;
goto error_put_device;
}
*ptr = ioremap(res->start, resource_size(res));
if (!*ptr) {
ret = -ENOMEM;
goto error_put_device;
}
/* We've remapped the addresses, and we don't need the device any
* more, so we should release it.
*/
put_device(&pdev->dev);
if (init_flag && siram_init_flag == 0) {
memset_io(*ptr, 0, resource_size(res));
siram_init_flag = 1;
}
return 0;
error_put_device:
put_device(&pdev->dev);
return ret;
}
static int ucc_hdlc_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct ucc_hdlc_private *uhdlc_priv = NULL;
struct ucc_tdm_info *ut_info;
struct ucc_tdm *utdm = NULL;
struct resource res;
struct net_device *dev;
hdlc_device *hdlc;
int ucc_num;
const char *sprop;
int ret;
u32 val;
ret = of_property_read_u32_index(np, "cell-index", 0, &val);
if (ret) {
dev_err(&pdev->dev, "Invalid ucc property\n");
return -ENODEV;
}
ucc_num = val - 1;
if (ucc_num > (UCC_MAX_NUM - 1) || ucc_num < 0) {
dev_err(&pdev->dev, ": Invalid UCC num\n");
return -EINVAL;
}
memcpy(&utdm_info[ucc_num], &utdm_primary_info,
sizeof(utdm_primary_info));
ut_info = &utdm_info[ucc_num];
ut_info->uf_info.ucc_num = ucc_num;
sprop = of_get_property(np, "rx-clock-name", NULL);
if (sprop) {
Annotation
- Immediate include surface: `linux/delay.h`, `linux/dma-mapping.h`, `linux/hdlc.h`, `linux/init.h`, `linux/interrupt.h`, `linux/io.h`, `linux/irq.h`, `linux/kernel.h`.
- Detected declarations: `function uhdlc_init`, `function ucc_hdlc_tx`, `function hdlc_tx_restart`, `function hdlc_tx_done`, `function hdlc_rx_done`, `function ucc_hdlc_poll`, `function ucc_hdlc_irq_handler`, `function uhdlc_ioctl`, `function uhdlc_open`, `function uhdlc_memclean`.
- Atlas domain: Driver Families / drivers/net.
- 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.