drivers/net/ethernet/micrel/ks8851_common.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/micrel/ks8851_common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/micrel/ks8851_common.c- Extension
.c- Size
- 30489 bytes
- Lines
- 1227
- 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/interrupt.hlinux/module.hlinux/kernel.hlinux/netdevice.hlinux/etherdevice.hlinux/ethtool.hlinux/cache.hlinux/crc32.hlinux/mii.hlinux/gpio/consumer.hlinux/regulator/consumer.hlinux/of_mdio.hlinux/of_net.hks8851.h
Detected Declarations
function ks8851_lockfunction ks8851_unlockfunction ks8851_wrreg16function ks8851_rdreg16function ks8851_soft_resetfunction ks8851_set_powermodefunction ks8851_write_mac_addrfunction ks8851_read_mac_addrfunction ks8851_init_macfunction ks8851_rx_pktsfunction ks8851_irqfunction ks8851_flush_tx_workfunction ks8851_net_openfunction ks8851_net_stopfunction ks8851_start_xmitfunction ks8851_rxctrl_workfunction ks8851_set_rx_modefunction netdev_for_each_mc_addrfunction ks8851_set_mac_addressfunction ks8851_net_ioctlfunction ks8851_get_drvinfofunction ks8851_get_msglevelfunction ks8851_set_msglevelfunction ks8851_get_link_ksettingsfunction ks8851_set_link_ksettingsfunction ks8851_get_linkfunction ks8851_nway_resetfunction ks8851_eeprom_regreadfunction ks8851_eeprom_regwritefunction ks8851_eeprom_claimfunction ks8851_eeprom_releasefunction ks8851_set_eepromfunction ks8851_get_eepromfunction ks8851_get_eeprom_lenfunction ks8851_phy_regfunction ks8851_phy_read_commonfunction ks8851_phy_readfunction ks8851_phy_writefunction ks8851_mdio_readfunction ks8851_mdio_writefunction ks8851_read_selftestfunction ks8851_suspendfunction ks8851_resumefunction ks8851_register_mdiobusfunction ks8851_unregister_mdiobusfunction ks8851_probe_commonfunction ks8851_remove_commonexport ks8851_suspend
Annotated Snippet
static const struct net_device_ops ks8851_netdev_ops = {
.ndo_open = ks8851_net_open,
.ndo_stop = ks8851_net_stop,
.ndo_eth_ioctl = ks8851_net_ioctl,
.ndo_start_xmit = ks8851_start_xmit,
.ndo_set_mac_address = ks8851_set_mac_address,
.ndo_set_rx_mode = ks8851_set_rx_mode,
.ndo_validate_addr = eth_validate_addr,
};
/* ethtool support */
static void ks8851_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *di)
{
strscpy(di->driver, "KS8851", sizeof(di->driver));
strscpy(di->version, "1.00", sizeof(di->version));
strscpy(di->bus_info, dev_name(dev->dev.parent), sizeof(di->bus_info));
}
static u32 ks8851_get_msglevel(struct net_device *dev)
{
struct ks8851_net *ks = netdev_priv(dev);
return ks->msg_enable;
}
static void ks8851_set_msglevel(struct net_device *dev, u32 to)
{
struct ks8851_net *ks = netdev_priv(dev);
ks->msg_enable = to;
}
static int ks8851_get_link_ksettings(struct net_device *dev,
struct ethtool_link_ksettings *cmd)
{
struct ks8851_net *ks = netdev_priv(dev);
mii_ethtool_get_link_ksettings(&ks->mii, cmd);
return 0;
}
static int ks8851_set_link_ksettings(struct net_device *dev,
const struct ethtool_link_ksettings *cmd)
{
struct ks8851_net *ks = netdev_priv(dev);
return mii_ethtool_set_link_ksettings(&ks->mii, cmd);
}
static u32 ks8851_get_link(struct net_device *dev)
{
struct ks8851_net *ks = netdev_priv(dev);
return mii_link_ok(&ks->mii);
}
static int ks8851_nway_reset(struct net_device *dev)
{
struct ks8851_net *ks = netdev_priv(dev);
return mii_nway_restart(&ks->mii);
}
/* EEPROM support */
static void ks8851_eeprom_regread(struct eeprom_93cx6 *ee)
{
struct ks8851_net *ks = ee->data;
unsigned val;
val = ks8851_rdreg16(ks, KS_EEPCR);
ee->reg_data_out = (val & EEPCR_EESB) ? 1 : 0;
ee->reg_data_clock = (val & EEPCR_EESCK) ? 1 : 0;
ee->reg_chip_select = (val & EEPCR_EECS) ? 1 : 0;
}
static void ks8851_eeprom_regwrite(struct eeprom_93cx6 *ee)
{
struct ks8851_net *ks = ee->data;
unsigned val = EEPCR_EESA; /* default - eeprom access on */
if (ee->drive_data)
val |= EEPCR_EESRWA;
if (ee->reg_data_in)
val |= EEPCR_EEDO;
if (ee->reg_data_clock)
val |= EEPCR_EESCK;
if (ee->reg_chip_select)
val |= EEPCR_EECS;
ks8851_wrreg16(ks, KS_EEPCR, val);
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/module.h`, `linux/kernel.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/ethtool.h`, `linux/cache.h`, `linux/crc32.h`.
- Detected declarations: `function ks8851_lock`, `function ks8851_unlock`, `function ks8851_wrreg16`, `function ks8851_rdreg16`, `function ks8851_soft_reset`, `function ks8851_set_powermode`, `function ks8851_write_mac_addr`, `function ks8851_read_mac_addr`, `function ks8851_init_mac`, `function ks8851_rx_pkts`.
- 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.