drivers/net/ethernet/microchip/encx24j600.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/encx24j600.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/microchip/encx24j600.c- Extension
.c- Size
- 29726 bytes
- Lines
- 1129
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/errno.hlinux/etherdevice.hlinux/ethtool.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/netdevice.hlinux/regmap.hlinux/skbuff.hlinux/spi/spi.hencx24j600_hw.h
Detected Declarations
struct encx24j600_privfunction dump_packetfunction encx24j600_dump_rsvfunction encx24j600_read_regfunction encx24j600_write_regfunction encx24j600_update_regfunction encx24j600_read_phyfunction encx24j600_write_phyfunction encx24j600_clr_bitsfunction encx24j600_set_bitsfunction encx24j600_cmdfunction encx24j600_raw_readfunction encx24j600_raw_writefunction encx24j600_update_phcon1function encx24j600_wait_for_autonegfunction encx24j600_check_link_statusfunction encx24j600_int_link_handlerfunction encx24j600_tx_completefunction encx24j600_receive_packetfunction encx24j600_rx_packetsfunction encx24j600_isrfunction encx24j600_soft_resetfunction encx24j600_hw_resetfunction encx24j600_reset_hw_txfunction encx24j600_hw_init_txfunction encx24j600_hw_init_rxfunction encx24j600_dump_configfunction encx24j600_set_rxfilter_modefunction encx24j600_hw_initfunction encx24j600_hw_enablefunction encx24j600_hw_disablefunction encx24j600_setlinkfunction encx24j600_hw_initfunction encx24j600_hw_get_macaddrfunction encx24j600_set_hw_macaddrfunction encx24j600_set_mac_addressfunction encx24j600_openfunction encx24j600_stopfunction encx24j600_setrx_procfunction encx24j600_set_multicast_listfunction encx24j600_hw_txfunction encx24j600_tx_procfunction encx24j600_txfunction encx24j600_tx_timeoutfunction encx24j600_get_regs_lenfunction encx24j600_get_regsfunction encx24j600_get_drvinfofunction encx24j600_get_link_ksettings
Annotated Snippet
static const struct net_device_ops encx24j600_netdev_ops = {
.ndo_open = encx24j600_open,
.ndo_stop = encx24j600_stop,
.ndo_start_xmit = encx24j600_tx,
.ndo_set_rx_mode = encx24j600_set_multicast_list,
.ndo_set_mac_address = encx24j600_set_mac_address,
.ndo_tx_timeout = encx24j600_tx_timeout,
.ndo_validate_addr = eth_validate_addr,
};
static int encx24j600_spi_probe(struct spi_device *spi)
{
int ret;
struct net_device *ndev;
struct encx24j600_priv *priv;
u16 eidled;
u8 addr[ETH_ALEN];
ndev = alloc_etherdev(sizeof(struct encx24j600_priv));
if (!ndev) {
ret = -ENOMEM;
goto error_out;
}
priv = netdev_priv(ndev);
spi_set_drvdata(spi, priv);
dev_set_drvdata(&spi->dev, priv);
SET_NETDEV_DEV(ndev, &spi->dev);
priv->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE);
priv->ndev = ndev;
/* Default configuration PHY configuration */
priv->full_duplex = true;
priv->autoneg = AUTONEG_ENABLE;
priv->speed = SPEED_100;
priv->ctx.spi = spi;
ndev->irq = spi->irq;
ndev->netdev_ops = &encx24j600_netdev_ops;
ret = devm_regmap_init_encx24j600(&spi->dev, &priv->ctx);
if (ret)
goto out_free;
mutex_init(&priv->lock);
/* Reset device and check if it is connected */
if (encx24j600_hw_reset(priv)) {
netif_err(priv, probe, ndev,
DRV_NAME ": Chip is not detected\n");
ret = -EIO;
goto out_free;
}
/* Initialize the device HW to the consistent state */
encx24j600_hw_init(priv);
kthread_init_worker(&priv->kworker);
kthread_init_work(&priv->tx_work, encx24j600_tx_proc);
kthread_init_work(&priv->setrx_work, encx24j600_setrx_proc);
priv->kworker_task = kthread_run(kthread_worker_fn, &priv->kworker,
"encx24j600");
if (IS_ERR(priv->kworker_task)) {
ret = PTR_ERR(priv->kworker_task);
goto out_free;
}
/* Get the MAC address from the chip */
encx24j600_hw_get_macaddr(priv, addr);
eth_hw_addr_set(ndev, addr);
ndev->ethtool_ops = &encx24j600_ethtool_ops;
ret = register_netdev(ndev);
if (unlikely(ret)) {
netif_err(priv, probe, ndev, "Error %d initializing card encx24j600 card\n",
ret);
goto out_stop;
}
eidled = encx24j600_read_reg(priv, EIDLED);
if (((eidled & DEVID_MASK) >> DEVID_SHIFT) != ENCX24J600_DEV_ID) {
ret = -EINVAL;
goto out_unregister;
}
Annotation
- Immediate include surface: `linux/device.h`, `linux/errno.h`, `linux/etherdevice.h`, `linux/ethtool.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`, `linux/netdevice.h`.
- Detected declarations: `struct encx24j600_priv`, `function dump_packet`, `function encx24j600_dump_rsv`, `function encx24j600_read_reg`, `function encx24j600_write_reg`, `function encx24j600_update_reg`, `function encx24j600_read_phy`, `function encx24j600_write_phy`, `function encx24j600_clr_bits`, `function encx24j600_set_bits`.
- 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.