drivers/net/ethernet/cirrus/ep93xx_eth.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/cirrus/ep93xx_eth.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/cirrus/ep93xx_eth.c- Extension
.c- Size
- 20736 bytes
- Lines
- 877
- 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.
- 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/dma-mapping.hlinux/module.hlinux/kernel.hlinux/netdevice.hlinux/mii.hlinux/etherdevice.hlinux/ethtool.hlinux/interrupt.hlinux/moduleparam.hlinux/of.hlinux/platform_device.hlinux/delay.hlinux/io.hlinux/slab.h
Detected Declarations
struct ep93xx_rdescstruct ep93xx_rstatstruct ep93xx_tdescstruct ep93xx_tstatstruct ep93xx_descsstruct ep93xx_privfunction ep93xx_mdio_readfunction ep93xx_mdio_writefunction ep93xx_rxfunction ep93xx_pollfunction ep93xx_xmitfunction ep93xx_tx_completefunction ep93xx_irqfunction ep93xx_free_buffersfunction ep93xx_alloc_buffersfunction ep93xx_start_hwfunction ep93xx_stop_hwfunction ep93xx_openfunction ep93xx_closefunction ep93xx_ioctlfunction ep93xx_get_drvinfofunction ep93xx_get_link_ksettingsfunction ep93xx_set_link_ksettingsfunction ep93xx_nway_resetfunction ep93xx_get_linkfunction ep93xx_eth_removefunction ep93xx_eth_probe
Annotated Snippet
static const struct net_device_ops ep93xx_netdev_ops = {
.ndo_open = ep93xx_open,
.ndo_stop = ep93xx_close,
.ndo_start_xmit = ep93xx_xmit,
.ndo_eth_ioctl = ep93xx_ioctl,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
};
static void ep93xx_eth_remove(struct platform_device *pdev)
{
struct net_device *dev;
struct ep93xx_priv *ep;
struct resource *mem;
dev = platform_get_drvdata(pdev);
if (dev == NULL)
return;
ep = netdev_priv(dev);
/* @@@ Force down. */
unregister_netdev(dev);
ep93xx_free_buffers(ep);
if (ep->base_addr != NULL)
iounmap(ep->base_addr);
if (ep->res != NULL) {
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(mem->start, resource_size(mem));
}
free_netdev(dev);
}
static int ep93xx_eth_probe(struct platform_device *pdev)
{
struct net_device *dev;
struct ep93xx_priv *ep;
struct resource *mem;
void __iomem *base_addr;
struct device_node *np;
u8 addr[ETH_ALEN];
u32 phy_id;
int irq;
int err;
if (pdev == NULL)
return -ENODEV;
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
irq = platform_get_irq(pdev, 0);
if (!mem || irq < 0)
return -ENXIO;
base_addr = ioremap(mem->start, resource_size(mem));
if (!base_addr)
return dev_err_probe(&pdev->dev, -EIO, "Failed to ioremap ethernet registers\n");
np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
if (!np)
return dev_err_probe(&pdev->dev, -ENODEV, "Please provide \"phy-handle\"\n");
err = of_property_read_u32(np, "reg", &phy_id);
of_node_put(np);
if (err)
return dev_err_probe(&pdev->dev, -ENOENT, "Failed to locate \"phy_id\"\n");
dev = alloc_etherdev(sizeof(struct ep93xx_priv));
if (dev == NULL) {
err = -ENOMEM;
goto err_out;
}
memcpy_fromio(addr, base_addr + 0x50, ETH_ALEN);
eth_hw_addr_set(dev, addr);
dev->ethtool_ops = &ep93xx_ethtool_ops;
dev->netdev_ops = &ep93xx_netdev_ops;
dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM;
ep = netdev_priv(dev);
ep->dev = dev;
SET_NETDEV_DEV(dev, &pdev->dev);
netif_napi_add(dev, &ep->napi, ep93xx_poll);
platform_set_drvdata(pdev, dev);
ep->res = request_mem_region(mem->start, resource_size(mem),
dev_name(&pdev->dev));
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `linux/module.h`, `linux/kernel.h`, `linux/netdevice.h`, `linux/mii.h`, `linux/etherdevice.h`, `linux/ethtool.h`, `linux/interrupt.h`.
- Detected declarations: `struct ep93xx_rdesc`, `struct ep93xx_rstat`, `struct ep93xx_tdesc`, `struct ep93xx_tstat`, `struct ep93xx_descs`, `struct ep93xx_priv`, `function ep93xx_mdio_read`, `function ep93xx_mdio_write`, `function ep93xx_rx`, `function ep93xx_poll`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern 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.