drivers/net/can/peak_canfd/peak_canfd.c
Source file repositories/reference/linux-study-clean/drivers/net/can/peak_canfd/peak_canfd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/can/peak_canfd/peak_canfd.c- Extension
.c- Size
- 20409 bytes
- Lines
- 837
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/can.hlinux/can/dev.hlinux/ethtool.hpeak_canfd_user.h
Detected Declarations
function pucan_write_cmdfunction pucan_set_reset_modefunction pucan_set_normal_modefunction pucan_set_listen_only_modefunction pucan_set_timing_slowfunction pucan_set_timing_fastfunction pucan_set_std_filterfunction pucan_tx_abortfunction pucan_clr_err_countersfunction pucan_set_optionsfunction pucan_clr_optionsfunction pucan_setup_rx_barrierfunction pucan_netif_rxfunction pucan_handle_can_rxfunction pucan_handle_errorfunction pucan_handle_statusfunction pucan_handle_cache_criticalfunction peak_canfd_handle_msgfunction peak_canfd_handle_msgs_listfunction peak_canfd_startfunction peak_canfd_stopfunction peak_canfd_set_modefunction peak_canfd_get_berr_counterfunction peak_canfd_openfunction peak_canfd_set_bittimingfunction peak_canfd_set_data_bittimingfunction peak_canfd_closefunction peak_canfd_start_xmitfunction peak_eth_hwtstamp_getfunction peak_eth_hwtstamp_setfunction peak_get_ts_info
Annotated Snippet
static const struct net_device_ops peak_canfd_netdev_ops = {
.ndo_open = peak_canfd_open,
.ndo_stop = peak_canfd_close,
.ndo_start_xmit = peak_canfd_start_xmit,
.ndo_hwtstamp_get = peak_eth_hwtstamp_get,
.ndo_hwtstamp_set = peak_eth_hwtstamp_set,
};
static int peak_get_ts_info(struct net_device *dev,
struct kernel_ethtool_ts_info *info)
{
info->so_timestamping =
SOF_TIMESTAMPING_TX_SOFTWARE |
SOF_TIMESTAMPING_RX_HARDWARE |
SOF_TIMESTAMPING_RAW_HARDWARE;
info->tx_types = BIT(HWTSTAMP_TX_OFF);
info->rx_filters = BIT(HWTSTAMP_FILTER_ALL);
return 0;
}
static const struct ethtool_ops peak_canfd_ethtool_ops = {
.get_ts_info = peak_get_ts_info,
};
struct net_device *alloc_peak_canfd_dev(int sizeof_priv, int index,
int echo_skb_max)
{
struct net_device *ndev;
struct peak_canfd_priv *priv;
/* we DO support local echo */
if (echo_skb_max < 0)
echo_skb_max = PCANFD_ECHO_SKB_MAX;
/* allocate the candev object */
ndev = alloc_candev(sizeof_priv, echo_skb_max);
if (!ndev)
return NULL;
priv = netdev_priv(ndev);
/* complete now socket-can initialization side */
priv->can.state = CAN_STATE_STOPPED;
priv->can.bittiming_const = &peak_canfd_nominal_const;
priv->can.fd.data_bittiming_const = &peak_canfd_data_const;
priv->can.do_set_mode = peak_canfd_set_mode;
priv->can.do_get_berr_counter = peak_canfd_get_berr_counter;
priv->can.do_set_bittiming = peak_canfd_set_bittiming;
priv->can.fd.do_set_data_bittiming = peak_canfd_set_data_bittiming;
priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK |
CAN_CTRLMODE_LISTENONLY |
CAN_CTRLMODE_3_SAMPLES |
CAN_CTRLMODE_FD |
CAN_CTRLMODE_FD_NON_ISO |
CAN_CTRLMODE_BERR_REPORTING;
priv->ndev = ndev;
priv->index = index;
priv->cmd_len = 0;
spin_lock_init(&priv->echo_lock);
ndev->flags |= IFF_ECHO;
ndev->netdev_ops = &peak_canfd_netdev_ops;
ndev->ethtool_ops = &peak_canfd_ethtool_ops;
ndev->dev_id = index;
return ndev;
}
Annotation
- Immediate include surface: `linux/can.h`, `linux/can/dev.h`, `linux/ethtool.h`, `peak_canfd_user.h`.
- Detected declarations: `function pucan_write_cmd`, `function pucan_set_reset_mode`, `function pucan_set_normal_mode`, `function pucan_set_listen_only_mode`, `function pucan_set_timing_slow`, `function pucan_set_timing_fast`, `function pucan_set_std_filter`, `function pucan_tx_abort`, `function pucan_clr_err_counters`, `function pucan_set_options`.
- 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.
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.