drivers/net/can/ctucanfd/ctucanfd_base.c
Source file repositories/reference/linux-study-clean/drivers/net/can/ctucanfd/ctucanfd_base.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/can/ctucanfd/ctucanfd_base.c- Extension
.c- Size
- 40082 bytes
- Lines
- 1461
- 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/clk.hlinux/errno.hlinux/ethtool.hlinux/init.hlinux/bitfield.hlinux/interrupt.hlinux/io.hlinux/kernel.hlinux/module.hlinux/skbuff.hlinux/string.hlinux/types.hlinux/can/error.hlinux/pm_runtime.hctucanfd.hctucanfd_kregs.hctucanfd_kframe.h
Detected Declarations
enum ctucan_txtb_statusenum ctucan_txtb_commandfunction ctucan_write32_lefunction ctucan_write32_befunction ctucan_read32_lefunction ctucan_read32_befunction ctucan_write32function ctucan_read32function ctucan_write_txt_buffunction ctucan_state_to_strfunction ctucan_resetfunction ctucan_set_btrfunction ctucan_set_bittimingfunction ctucan_set_data_bittimingfunction ctucan_set_secondary_sample_pointfunction ctucan_set_modefunction ctucan_chip_startfunction ctucan_do_set_modefunction ctucan_get_tx_statusfunction ctucan_is_txt_buf_writablefunction ctucan_insert_framefunction ctucan_give_txtb_cmdfunction ctucan_start_xmitfunction ctucan_read_rx_framefunction ctucan_rxfunction ctucan_read_fault_statefunction ctucan_get_rec_tecfunction ctucan_err_interruptfunction ctucan_rx_pollfunction ctucan_rotate_txb_priofunction ctucan_tx_interruptfunction ctucan_interruptfunction ctucan_chip_stopfunction ctucan_openfunction ctucan_closefunction ctucan_get_berr_counterfunction ctucan_suspendfunction ctucan_resumefunction ctucan_probe_commonexport ctucan_suspendexport ctucan_resumeexport ctucan_probe_common
Annotated Snippet
static const struct net_device_ops ctucan_netdev_ops = {
.ndo_open = ctucan_open,
.ndo_stop = ctucan_close,
.ndo_start_xmit = ctucan_start_xmit,
};
static const struct ethtool_ops ctucan_ethtool_ops = {
.get_ts_info = ethtool_op_get_ts_info,
};
int ctucan_suspend(struct device *dev)
{
struct net_device *ndev = dev_get_drvdata(dev);
struct ctucan_priv *priv = netdev_priv(ndev);
if (netif_running(ndev)) {
netif_stop_queue(ndev);
netif_device_detach(ndev);
}
priv->can.state = CAN_STATE_SLEEPING;
return 0;
}
EXPORT_SYMBOL(ctucan_suspend);
int ctucan_resume(struct device *dev)
{
struct net_device *ndev = dev_get_drvdata(dev);
struct ctucan_priv *priv = netdev_priv(ndev);
priv->can.state = CAN_STATE_ERROR_ACTIVE;
if (netif_running(ndev)) {
netif_device_attach(ndev);
netif_start_queue(ndev);
}
return 0;
}
EXPORT_SYMBOL(ctucan_resume);
int ctucan_probe_common(struct device *dev, void __iomem *addr, int irq, unsigned int ntxbufs,
unsigned long can_clk_rate, int pm_enable_call,
void (*set_drvdata_fnc)(struct device *dev, struct net_device *ndev))
{
struct ctucan_priv *priv;
struct net_device *ndev;
int ret;
/* Create a CAN device instance */
ndev = alloc_candev(sizeof(struct ctucan_priv), ntxbufs);
if (!ndev)
return -ENOMEM;
priv = netdev_priv(ndev);
spin_lock_init(&priv->tx_lock);
INIT_LIST_HEAD(&priv->peers_on_pdev);
priv->ntxbufs = ntxbufs;
priv->dev = dev;
priv->can.bittiming_const = &ctu_can_fd_bit_timing_max;
priv->can.fd.data_bittiming_const = &ctu_can_fd_bit_timing_data_max;
priv->can.do_set_mode = ctucan_do_set_mode;
/* Needed for timing adjustment to be performed as soon as possible */
priv->can.do_set_bittiming = ctucan_set_bittiming;
priv->can.fd.do_set_data_bittiming = ctucan_set_data_bittiming;
priv->can.do_get_berr_counter = ctucan_get_berr_counter;
priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK
| CAN_CTRLMODE_LISTENONLY
| CAN_CTRLMODE_FD
| CAN_CTRLMODE_PRESUME_ACK
| CAN_CTRLMODE_BERR_REPORTING
| CAN_CTRLMODE_FD_NON_ISO
| CAN_CTRLMODE_ONE_SHOT;
priv->mem_base = addr;
/* Get IRQ for the device */
ndev->irq = irq;
ndev->flags |= IFF_ECHO; /* We support local echo */
if (set_drvdata_fnc)
set_drvdata_fnc(dev, ndev);
SET_NETDEV_DEV(ndev, dev);
ndev->netdev_ops = &ctucan_netdev_ops;
ndev->ethtool_ops = &ctucan_ethtool_ops;
/* Getting the can_clk info */
if (!can_clk_rate) {
Annotation
- Immediate include surface: `linux/clk.h`, `linux/errno.h`, `linux/ethtool.h`, `linux/init.h`, `linux/bitfield.h`, `linux/interrupt.h`, `linux/io.h`, `linux/kernel.h`.
- Detected declarations: `enum ctucan_txtb_status`, `enum ctucan_txtb_command`, `function ctucan_write32_le`, `function ctucan_write32_be`, `function ctucan_read32_le`, `function ctucan_read32_be`, `function ctucan_write32`, `function ctucan_read32`, `function ctucan_write_txt_buf`, `function ctucan_state_to_str`.
- 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.