drivers/net/ethernet/davicom/dm9000.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/davicom/dm9000.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/davicom/dm9000.c- Extension
.c- Size
- 42307 bytes
- Lines
- 1812
- 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/module.hlinux/ioport.hlinux/netdevice.hlinux/etherdevice.hlinux/interrupt.hlinux/skbuff.hlinux/spinlock.hlinux/crc32.hlinux/mii.hlinux/of.hlinux/of_net.hlinux/ethtool.hlinux/dm9000.hlinux/delay.hlinux/platform_device.hlinux/irq.hlinux/slab.hlinux/regulator/consumer.hlinux/gpio/consumer.hasm/delay.hasm/irq.hasm/io.hdm9000.h
Detected Declarations
struct board_infostruct dm9000_rxhdrenum dm9000_typefunction iorfunction iowfunction dm9000_resetfunction dm9000_outblk_8bitfunction dm9000_outblk_16bitfunction dm9000_outblk_32bitfunction dm9000_inblk_8bitfunction dm9000_inblk_16bitfunction dm9000_inblk_32bitfunction dm9000_dumpblk_8bitfunction dm9000_dumpblk_16bitfunction dm9000_dumpblk_32bitfunction mdelayfunction dm9000_phy_readfunction dm9000_phy_writefunction dm9000_set_iofunction dm9000_schedule_pollfunction dm9000_ioctlfunction dm9000_read_lockedfunction dm9000_wait_eepromfunction timeoutfunction dm9000_read_eepromfunction dm9000_write_eepromfunction dm9000_get_drvinfofunction dm9000_get_msglevelfunction dm9000_set_msglevelfunction dm9000_get_link_ksettingsfunction dm9000_set_link_ksettingsfunction dm9000_nway_resetfunction dm9000_set_featuresfunction dm9000_get_linkfunction dm9000_get_eeprom_lenfunction dm9000_get_eepromfunction dm9000_set_eepromfunction dm9000_get_wolfunction dm9000_set_wolfunction dm9000_show_carrierfunction dm9000_poll_workfunction dm9000_release_boardfunction dm9000_type_to_charfunction dm9000_hash_table_unlockedfunction dm9000_hash_tablefunction dm9000_mask_interruptsfunction dm9000_unmask_interruptsfunction dm9000_init_dm9000
Annotated Snippet
static const struct net_device_ops dm9000_netdev_ops = {
.ndo_open = dm9000_open,
.ndo_stop = dm9000_stop,
.ndo_start_xmit = dm9000_start_xmit,
.ndo_tx_timeout = dm9000_timeout,
.ndo_set_rx_mode = dm9000_hash_table,
.ndo_eth_ioctl = dm9000_ioctl,
.ndo_set_features = dm9000_set_features,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = dm9000_poll_controller,
#endif
};
static struct dm9000_plat_data *dm9000_parse_dt(struct device *dev)
{
struct dm9000_plat_data *pdata;
struct device_node *np = dev->of_node;
int ret;
if (!IS_ENABLED(CONFIG_OF) || !np)
return ERR_PTR(-ENXIO);
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return ERR_PTR(-ENOMEM);
if (of_property_read_bool(np, "davicom,ext-phy"))
pdata->flags |= DM9000_PLATF_EXT_PHY;
if (of_property_read_bool(np, "davicom,no-eeprom"))
pdata->flags |= DM9000_PLATF_NO_EEPROM;
ret = of_get_mac_address(np, pdata->dev_addr);
if (ret == -EPROBE_DEFER)
return ERR_PTR(ret);
return pdata;
}
/*
* Search DM9000 board, allocate space and register it
*/
static int
dm9000_probe(struct platform_device *pdev)
{
struct dm9000_plat_data *pdata = dev_get_platdata(&pdev->dev);
struct board_info *db; /* Point a board information structure */
struct net_device *ndev;
struct device *dev = &pdev->dev;
const unsigned char *mac_src;
int ret = 0;
int iosize;
int i;
u32 id_val;
struct gpio_desc *reset_gpio;
struct regulator *power;
bool inv_mac_addr = false;
u8 addr[ETH_ALEN];
power = devm_regulator_get(dev, "vcc");
if (IS_ERR(power)) {
if (PTR_ERR(power) == -EPROBE_DEFER)
return -EPROBE_DEFER;
dev_dbg(dev, "no regulator provided\n");
} else {
ret = regulator_enable(power);
if (ret != 0) {
dev_err(dev,
"Failed to enable power regulator: %d\n", ret);
return ret;
}
dev_dbg(dev, "regulator enabled\n");
}
reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
ret = PTR_ERR_OR_ZERO(reset_gpio);
if (ret) {
dev_err(dev, "failed to request reset gpio: %d\n", ret);
goto out_regulator_disable;
}
if (reset_gpio) {
ret = gpiod_set_consumer_name(reset_gpio, "dm9000_reset");
if (ret) {
dev_err(dev, "failed to set reset gpio name: %d\n",
ret);
goto out_regulator_disable;
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/ioport.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/interrupt.h`, `linux/skbuff.h`, `linux/spinlock.h`, `linux/crc32.h`.
- Detected declarations: `struct board_info`, `struct dm9000_rxhdr`, `enum dm9000_type`, `function ior`, `function iow`, `function dm9000_reset`, `function dm9000_outblk_8bit`, `function dm9000_outblk_16bit`, `function dm9000_outblk_32bit`, `function dm9000_inblk_8bit`.
- 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.