drivers/net/can/at91_can.c
Source file repositories/reference/linux-study-clean/drivers/net/can/at91_can.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/can/at91_can.c- Extension
.c- Size
- 30197 bytes
- Lines
- 1206
- 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.
- 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/bitfield.hlinux/clk.hlinux/errno.hlinux/ethtool.hlinux/if_arp.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/netdevice.hlinux/of.hlinux/phy/phy.hlinux/platform_device.hlinux/rtnetlink.hlinux/skbuff.hlinux/spinlock.hlinux/string.hlinux/types.hlinux/can/dev.hlinux/can/error.hlinux/can/rx-offload.h
Detected Declarations
struct at91_devtype_datastruct at91_privenum at91_regenum at91_mb_modeenum at91_devtypefunction get_mb_rx_firstfunction get_mb_rx_lastfunction get_mb_tx_shiftfunction get_mb_tx_numfunction get_mb_tx_firstfunction get_mb_tx_lastfunction get_head_prio_shiftfunction get_head_prio_maskfunction get_head_mb_maskfunction get_head_maskfunction get_irq_mb_rxfunction get_irq_mb_txfunction get_tx_head_mbfunction get_tx_head_priofunction get_tx_tail_mbfunction at91_readfunction at91_writefunction set_mb_mode_priofunction set_mb_modefunction at91_can_id_to_reg_midfunction at91_setup_mailboxesfunction at91_set_bittimingfunction at91_get_berr_counterfunction at91_chip_startfunction at91_chip_stopfunction at91_start_xmitfunction at91_get_timestampfunction at91_alloc_can_err_skbfunction at91_rx_overflow_errfunction at91_irq_txfunction at91_irq_err_linefunction at91_irq_err_framefunction at91_get_reg_sr_rxfunction at91_irqfunction at91_openfunction at91_closefunction at91_set_modefunction mb0_id_showfunction mb0_id_storefunction at91_can_probefunction at91_can_remove
Annotated Snippet
static const struct net_device_ops at91_netdev_ops = {
.ndo_open = at91_open,
.ndo_stop = at91_close,
.ndo_start_xmit = at91_start_xmit,
};
static const struct ethtool_ops at91_ethtool_ops = {
.get_ts_info = ethtool_op_get_ts_info,
};
static ssize_t mb0_id_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct at91_priv *priv = netdev_priv(to_net_dev(dev));
if (priv->mb0_id & CAN_EFF_FLAG)
return sysfs_emit(buf, "0x%08x\n", priv->mb0_id);
else
return sysfs_emit(buf, "0x%03x\n", priv->mb0_id);
}
static ssize_t mb0_id_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct net_device *ndev = to_net_dev(dev);
struct at91_priv *priv = netdev_priv(ndev);
unsigned long can_id;
ssize_t ret;
int err;
rtnl_lock();
if (ndev->flags & IFF_UP) {
ret = -EBUSY;
goto out;
}
err = kstrtoul(buf, 0, &can_id);
if (err) {
ret = err;
goto out;
}
if (can_id & CAN_EFF_FLAG)
can_id &= CAN_EFF_MASK | CAN_EFF_FLAG;
else
can_id &= CAN_SFF_MASK;
priv->mb0_id = can_id;
ret = count;
out:
rtnl_unlock();
return ret;
}
static DEVICE_ATTR_RW(mb0_id);
static struct attribute *at91_sysfs_attrs[] = {
&dev_attr_mb0_id.attr,
NULL,
};
static const struct attribute_group at91_sysfs_attr_group = {
.attrs = at91_sysfs_attrs,
};
#if defined(CONFIG_OF)
static const struct of_device_id at91_can_dt_ids[] = {
{
.compatible = "atmel,at91sam9x5-can",
.data = &at91_at91sam9x5_data,
}, {
.compatible = "atmel,at91sam9263-can",
.data = &at91_at91sam9263_data,
}, {
/* sentinel */
}
};
MODULE_DEVICE_TABLE(of, at91_can_dt_ids);
#endif
static const struct at91_devtype_data *at91_can_get_driver_data(struct platform_device *pdev)
{
if (pdev->dev.of_node) {
const struct of_device_id *match;
match = of_match_node(at91_can_dt_ids, pdev->dev.of_node);
if (!match) {
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/errno.h`, `linux/ethtool.h`, `linux/if_arp.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`.
- Detected declarations: `struct at91_devtype_data`, `struct at91_priv`, `enum at91_reg`, `enum at91_mb_mode`, `enum at91_devtype`, `function get_mb_rx_first`, `function get_mb_rx_last`, `function get_mb_tx_shift`, `function get_mb_tx_num`, `function get_mb_tx_first`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- 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.