drivers/net/can/janz-ican3.c
Source file repositories/reference/linux-study-clean/drivers/net/can/janz-ican3.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/can/janz-ican3.c- Extension
.c- Size
- 51114 bytes
- Lines
- 2060
- 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/kernel.hlinux/module.hlinux/interrupt.hlinux/delay.hlinux/ethtool.hlinux/platform_device.hlinux/netdevice.hlinux/can.hlinux/can/dev.hlinux/can/skb.hlinux/can/error.hlinux/mfd/janz.hasm/io.h
Detected Declarations
struct ican3_dpm_controlstruct ican3_devstruct ican3_msgstruct ican3_new_descstruct ican3_fast_descenum ican3_fwtypefunction ican3_set_pagefunction ican3_old_recv_msgfunction ican3_old_send_msgfunction ican3_init_new_host_interfacefunction ican3_init_fast_host_interfacefunction ican3_new_send_msgfunction ican3_new_recv_msgfunction ican3_send_msgfunction ican3_recv_msgfunction ican3_msg_connectfunction ican3_msg_disconnectfunction ican3_msg_newhostiffunction ican3_msg_fasthostiffunction ican3_set_id_filterfunction ican3_set_bus_statefunction ican3_set_terminationfunction ican3_send_inquiryfunction ican3_set_buserrorfunction ican3_to_can_framefunction can_frame_to_ican3function ican3_handle_idversfunction ican3_handle_msglostfunction ican3_handle_cevtindfunction ican3_handle_inquiryfunction ican3_handle_nmtsindfunction ican3_handle_unknown_messagefunction ican3_handle_messagefunction ican3_put_echo_skbfunction ican3_get_echo_skbfunction ican3_echo_skb_matchesfunction ican3_txokfunction ican3_recv_skbfunction ican3_napifunction ican3_irqfunction ican3_reset_modulefunction ican3_shutdown_modulefunction ican3_startup_modulefunction ican3_openfunction ican3_stopfunction ican3_xmitfunction ican3_set_modefunction ican3_get_berr_counter
Annotated Snippet
static const struct net_device_ops ican3_netdev_ops = {
.ndo_open = ican3_open,
.ndo_stop = ican3_stop,
.ndo_start_xmit = ican3_xmit,
};
static const struct ethtool_ops ican3_ethtool_ops = {
.get_ts_info = ethtool_op_get_ts_info,
};
/*
* Low-level CAN Device
*/
/* This structure was stolen from drivers/net/can/sja1000/sja1000.c */
static const struct can_bittiming_const ican3_bittiming_const = {
.name = DRV_NAME,
.tseg1_min = 1,
.tseg1_max = 16,
.tseg2_min = 1,
.tseg2_max = 8,
.sjw_max = 4,
.brp_min = 1,
.brp_max = 64,
.brp_inc = 1,
};
static int ican3_set_mode(struct net_device *ndev, enum can_mode mode)
{
struct ican3_dev *mod = netdev_priv(ndev);
int ret;
if (mode != CAN_MODE_START)
return -ENOTSUPP;
/* bring the bus online */
ret = ican3_set_bus_state(mod, true);
if (ret) {
netdev_err(ndev, "unable to set bus-on\n");
return ret;
}
/* start up the network device */
mod->can.state = CAN_STATE_ERROR_ACTIVE;
if (netif_queue_stopped(ndev))
netif_wake_queue(ndev);
return 0;
}
static int ican3_get_berr_counter(const struct net_device *ndev,
struct can_berr_counter *bec)
{
struct ican3_dev *mod = netdev_priv(ndev);
int ret;
ret = ican3_send_inquiry(mod, INQUIRY_STATUS);
if (ret)
return ret;
if (!wait_for_completion_timeout(&mod->buserror_comp, HZ)) {
netdev_info(mod->ndev, "%s timed out\n", __func__);
return -ETIMEDOUT;
}
bec->rxerr = mod->bec.rxerr;
bec->txerr = mod->bec.txerr;
return 0;
}
/*
* Sysfs Attributes
*/
static ssize_t termination_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct ican3_dev *mod = netdev_priv(to_net_dev(dev));
int ret;
ret = ican3_send_inquiry(mod, INQUIRY_TERMINATION);
if (ret)
return ret;
if (!wait_for_completion_timeout(&mod->termination_comp, HZ)) {
netdev_info(mod->ndev, "%s timed out\n", __func__);
return -ETIMEDOUT;
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/interrupt.h`, `linux/delay.h`, `linux/ethtool.h`, `linux/platform_device.h`, `linux/netdevice.h`, `linux/can.h`.
- Detected declarations: `struct ican3_dpm_control`, `struct ican3_dev`, `struct ican3_msg`, `struct ican3_new_desc`, `struct ican3_fast_desc`, `enum ican3_fwtype`, `function ican3_set_page`, `function ican3_old_recv_msg`, `function ican3_old_send_msg`, `function ican3_init_new_host_interface`.
- 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.