drivers/net/ethernet/micrel/ks8842.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/micrel/ks8842.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/micrel/ks8842.c- Extension
.c- Size
- 32574 bytes
- Lines
- 1260
- 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/interrupt.hlinux/kernel.hlinux/module.hlinux/platform_device.hlinux/netdevice.hlinux/etherdevice.hlinux/ethtool.hlinux/ks8842.hlinux/dmaengine.hlinux/dma-mapping.hlinux/scatterlist.h
Detected Declarations
struct ks8842_tx_dma_ctlstruct ks8842_rx_dma_ctlstruct ks8842_adapterfunction ks8842_resume_dmafunction ks8842_select_bankfunction ks8842_write8function ks8842_write16function ks8842_enable_bitsfunction ks8842_clear_bitsfunction ks8842_write32function ks8842_read8function ks8842_read16function ks8842_read32function ks8842_resetfunction ks8842_update_link_statusfunction ks8842_enable_txfunction ks8842_disable_txfunction ks8842_enable_rxfunction ks8842_disable_rxfunction ks8842_reset_hwfunction ks8842_init_mac_addrfunction ks8842_write_mac_addrfunction ks8842_tx_fifo_spacefunction ks8842_tx_frame_dmafunction ks8842_tx_framefunction ks8842_update_rx_err_countersfunction ks8842_update_rx_countersfunction __ks8842_start_new_rx_dmafunction ks8842_rx_frame_dma_taskletfunction ks8842_rx_framefunction ks8842_handle_rxfunction ks8842_handle_txfunction ks8842_handle_rx_overrunfunction ks8842_taskletfunction ks8842_irqfunction ks8842_dma_rx_cbfunction ks8842_dma_tx_cbfunction ks8842_stop_dmafunction ks8842_dealloc_dma_bufsfunction ks8842_dma_filter_fnfunction ks8842_alloc_dma_bufsfunction ks8842_openfunction ks8842_closefunction ks8842_xmit_framefunction ks8842_set_macfunction ks8842_tx_timeout_workfunction ks8842_tx_timeoutfunction ks8842_probe
Annotated Snippet
static const struct net_device_ops ks8842_netdev_ops = {
.ndo_open = ks8842_open,
.ndo_stop = ks8842_close,
.ndo_start_xmit = ks8842_xmit_frame,
.ndo_set_mac_address = ks8842_set_mac,
.ndo_tx_timeout = ks8842_tx_timeout,
.ndo_validate_addr = eth_validate_addr
};
static const struct ethtool_ops ks8842_ethtool_ops = {
.get_link = ethtool_op_get_link,
};
static int ks8842_probe(struct platform_device *pdev)
{
int err = -ENOMEM;
struct resource *iomem;
struct net_device *netdev;
struct ks8842_adapter *adapter;
struct ks8842_platform_data *pdata = dev_get_platdata(&pdev->dev);
u16 id;
unsigned i;
iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!iomem) {
dev_err(&pdev->dev, "Invalid resource\n");
return -EINVAL;
}
if (!request_mem_region(iomem->start, resource_size(iomem), DRV_NAME))
goto err_mem_region;
netdev = alloc_etherdev(sizeof(struct ks8842_adapter));
if (!netdev)
goto err_alloc_etherdev;
SET_NETDEV_DEV(netdev, &pdev->dev);
adapter = netdev_priv(netdev);
adapter->netdev = netdev;
INIT_WORK(&adapter->timeout_work, ks8842_tx_timeout_work);
adapter->hw_addr = ioremap(iomem->start, resource_size(iomem));
adapter->conf_flags = iomem->flags;
if (!adapter->hw_addr)
goto err_ioremap;
adapter->irq = platform_get_irq(pdev, 0);
if (adapter->irq < 0) {
err = adapter->irq;
goto err_get_irq;
}
adapter->dev = (pdev->dev.parent) ? pdev->dev.parent : &pdev->dev;
/* DMA is only supported when accessed via timberdale */
if (!(adapter->conf_flags & MICREL_KS884X) && pdata &&
(pdata->tx_dma_channel != -1) &&
(pdata->rx_dma_channel != -1)) {
adapter->dma_rx.channel = pdata->rx_dma_channel;
adapter->dma_tx.channel = pdata->tx_dma_channel;
} else {
adapter->dma_rx.channel = -1;
adapter->dma_tx.channel = -1;
}
tasklet_setup(&adapter->tasklet, ks8842_tasklet);
spin_lock_init(&adapter->lock);
netdev->netdev_ops = &ks8842_netdev_ops;
netdev->ethtool_ops = &ks8842_ethtool_ops;
/* Check if a mac address was given */
i = netdev->addr_len;
if (pdata) {
for (i = 0; i < netdev->addr_len; i++)
if (pdata->macaddr[i] != 0)
break;
if (i < netdev->addr_len)
/* an address was passed, use it */
eth_hw_addr_set(netdev, pdata->macaddr);
}
if (i == netdev->addr_len) {
ks8842_init_mac_addr(adapter);
if (!is_valid_ether_addr(netdev->dev_addr))
eth_hw_addr_random(netdev);
}
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`, `linux/platform_device.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/ethtool.h`, `linux/ks8842.h`.
- Detected declarations: `struct ks8842_tx_dma_ctl`, `struct ks8842_rx_dma_ctl`, `struct ks8842_adapter`, `function ks8842_resume_dma`, `function ks8842_select_bank`, `function ks8842_write8`, `function ks8842_write16`, `function ks8842_enable_bits`, `function ks8842_clear_bits`, `function ks8842_write32`.
- 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.