drivers/net/can/usb/etas_es58x/es58x_core.c
Source file repositories/reference/linux-study-clean/drivers/net/can/usb/etas_es58x/es58x_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/can/usb/etas_es58x/es58x_core.c- Extension
.c- Size
- 64738 bytes
- Lines
- 2279
- 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/unaligned.hlinux/crc16.hlinux/ethtool.hlinux/kernel.hlinux/module.hlinux/usb.hnet/devlink.hes58x_core.h
Detected Declarations
function bytesfunction es58x_get_crcfunction es58x_set_crcfunction es58x_check_crcfunction es58x_timestamp_to_nsfunction es58x_set_skb_timestampfunction es58x_rx_timestampfunction es58x_set_realtime_diff_nsfunction es58x_is_can_state_activefunction es58x_is_echo_skb_threshold_reachedfunction es58x_can_free_echo_skb_tailfunction es58x_can_get_echo_skb_recoveryfunction es58x_can_get_echo_skbfunction es58x_can_reset_echo_fifofunction es58x_flush_pending_tx_msgfunction es58x_tx_ack_msgfunction es58x_rx_can_msgfunction es58x_rx_err_msgfunction es58x_cmd_ret_descfunction es58x_rx_cmd_ret_u8function es58x_rx_cmd_ret_u32function es58x_increment_rx_errorsfunction es58x_handle_urb_cmdfunction es58x_check_rx_urbfunction es58x_copy_to_cmd_buffunction es58x_split_urb_try_recoveryfunction es58x_handle_incomplete_cmdfunction es58x_split_urbfunction es58x_read_bulk_callbackfunction es58x_write_bulk_callbackfunction es58x_alloc_urbfunction es58x_get_tx_urbfunction es58x_submit_urbfunction es58x_send_msgfunction es58x_alloc_rx_urbsfunction es58x_free_urbsfunction es58x_openfunction es58x_stopfunction es58x_xmit_commitfunction es58x_xmit_morefunction es58x_start_xmitfunction es58x_set_modefunction es58x_init_privfunction es58x_init_netdevfunction es58x_free_netdevsfunction es58x_init_es58x_devfunction es58x_probefunction es58x_disconnect
Annotated Snippet
static const struct net_device_ops es58x_netdev_ops = {
.ndo_open = es58x_open,
.ndo_stop = es58x_stop,
.ndo_start_xmit = es58x_start_xmit,
.ndo_hwtstamp_get = can_hwtstamp_get,
.ndo_hwtstamp_set = can_hwtstamp_set,
};
static const struct ethtool_ops es58x_ethtool_ops = {
.get_ts_info = can_ethtool_op_get_ts_info_hwts,
};
/**
* es58x_set_mode() - Change network device mode.
* @netdev: CAN network device.
* @mode: either %CAN_MODE_START, %CAN_MODE_STOP or %CAN_MODE_SLEEP
*
* Currently, this function is only used to stop and restart the
* channel during a bus off event (c.f. es58x_rx_err_msg() and
* drivers/net/can/dev.c:can_restart() which are the two only
* callers).
*
* Return: zero on success, errno when any error occurs.
*/
static int es58x_set_mode(struct net_device *netdev, enum can_mode mode)
{
struct es58x_priv *priv = es58x_priv(netdev);
switch (mode) {
case CAN_MODE_START:
switch (priv->can.state) {
case CAN_STATE_BUS_OFF:
return priv->es58x_dev->ops->enable_channel(priv);
case CAN_STATE_STOPPED:
return es58x_open(netdev);
case CAN_STATE_ERROR_ACTIVE:
case CAN_STATE_ERROR_WARNING:
case CAN_STATE_ERROR_PASSIVE:
default:
return 0;
}
case CAN_MODE_STOP:
switch (priv->can.state) {
case CAN_STATE_STOPPED:
return 0;
case CAN_STATE_ERROR_ACTIVE:
case CAN_STATE_ERROR_WARNING:
case CAN_STATE_ERROR_PASSIVE:
case CAN_STATE_BUS_OFF:
default:
return priv->es58x_dev->ops->disable_channel(priv);
}
case CAN_MODE_SLEEP:
default:
return -EOPNOTSUPP;
}
}
/**
* es58x_init_priv() - Initialize private parameters.
* @es58x_dev: ES58X device.
* @priv: ES58X private parameters related to the network device.
* @channel_idx: Index of the network device.
*
* Return: zero on success, errno if devlink port could not be
* properly registered.
*/
static int es58x_init_priv(struct es58x_device *es58x_dev,
struct es58x_priv *priv, int channel_idx)
{
struct devlink_port_attrs attrs = {
.flavour = DEVLINK_PORT_FLAVOUR_PHYSICAL,
};
const struct es58x_parameters *param = es58x_dev->param;
struct can_priv *can = &priv->can;
priv->es58x_dev = es58x_dev;
priv->channel_idx = channel_idx;
priv->tx_urb = NULL;
priv->tx_can_msg_cnt = 0;
can->bittiming_const = param->bittiming_const;
if (param->ctrlmode_supported & CAN_CTRLMODE_FD) {
can->fd.data_bittiming_const = param->data_bittiming_const;
can->fd.tdc_const = param->tdc_const;
Annotation
- Immediate include surface: `linux/unaligned.h`, `linux/crc16.h`, `linux/ethtool.h`, `linux/kernel.h`, `linux/module.h`, `linux/usb.h`, `net/devlink.h`, `es58x_core.h`.
- Detected declarations: `function bytes`, `function es58x_get_crc`, `function es58x_set_crc`, `function es58x_check_crc`, `function es58x_timestamp_to_ns`, `function es58x_set_skb_timestamp`, `function es58x_rx_timestamp`, `function es58x_set_realtime_diff_ns`, `function es58x_is_can_state_active`, `function es58x_is_echo_skb_threshold_reached`.
- 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.