drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
Source file repositories/reference/linux-study-clean/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c- Extension
.c- Size
- 51714 bytes
- Lines
- 1998
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/completion.hlinux/device.hlinux/gfp.hlinux/jiffies.hlinux/kernel.hlinux/netdevice.hlinux/spinlock.hlinux/string.hlinux/types.hlinux/units.hlinux/usb.hlinux/workqueue.hlinux/can.hlinux/can/dev.hlinux/can/error.hlinux/can/netlink.hkvaser_usb.h
Detected Declarations
struct kvaser_cmd_simplestruct kvaser_cmd_cardinfostruct leaf_cmd_softinfostruct usbcan_cmd_softinfostruct kvaser_cmd_busparamsstruct kvaser_cmd_led_action_reqstruct kvaser_cmd_tx_canstruct kvaser_cmd_rx_can_headerstruct leaf_cmd_rx_canstruct usbcan_cmd_rx_canstruct leaf_cmd_chip_state_eventstruct usbcan_cmd_chip_state_eventstruct kvaser_cmd_tx_acknowledge_headerstruct leaf_cmd_tx_acknowledgestruct usbcan_cmd_tx_acknowledgestruct leaf_cmd_can_error_eventstruct usbcan_cmd_can_error_eventstruct leaf_cmd_error_eventstruct usbcan_cmd_error_eventstruct usbcan_cmd_clk_overflow_eventstruct kvaser_cmd_ctrl_modestruct kvaser_cmd_flush_queuestruct leaf_cmd_log_messagestruct kvaser_cmd_cap_reqstruct kvaser_cmd_cap_resstruct kvaser_cmdstruct kvaser_usb_err_summarystruct kvaser_usb_net_leaf_privfunction kvaser_usb_usbcan_timestamp_to_ktimefunction kvaser_usb_leaf_verify_sizefunction kvaser_usb_leaf_frame_to_cmdfunction kvaser_usb_leaf_wait_cmdfunction kvaser_usb_leaf_send_simple_cmdfunction kvaser_usb_leaf_get_software_info_leaffunction kvaser_usb_leaf_get_software_info_innerfunction kvaser_usb_leaf_get_software_infofunction kvaser_usb_leaf_get_card_infofunction kvaser_usb_leaf_get_single_capabilityfunction kvaser_usb_leaf_get_capabilities_leaffunction kvaser_usb_leaf_set_ledfunction kvaser_usb_leaf_get_capabilitiesfunction kvaser_usb_leaf_tx_acknowledgefunction kvaser_usb_leaf_simple_cmd_asyncfunction kvaser_usb_leaf_chip_state_req_workfunction kvaser_usb_leaf_rx_error_update_can_statefunction kvaser_usb_leaf_rx_errorfunction kvaser_usb_leaf_usbcan_conditionally_rx_errorfunction kvaser_usb_leaf_usbcan_rx_error
Annotated Snippet
struct kvaser_cmd_simple {
u8 tid;
u8 channel;
} __packed;
struct kvaser_cmd_cardinfo {
u8 tid;
u8 nchannels;
__le32 serial_number;
__le32 padding0;
__le32 clock_resolution;
__le32 mfgdate;
__le32 ean[2];
u8 hw_revision;
union {
struct {
u8 usb_hs_mode;
} __packed leaf1;
struct {
u8 padding;
} __packed usbcan1;
} __packed;
__le16 padding1;
} __packed;
struct leaf_cmd_softinfo {
u8 tid;
u8 padding0;
__le32 sw_options;
__le32 fw_version;
__le16 max_outstanding_tx;
__le16 padding1[9];
} __packed;
struct usbcan_cmd_softinfo {
u8 tid;
u8 fw_name[5];
__le16 max_outstanding_tx;
u8 padding[6];
__le32 fw_version;
__le16 checksum;
__le16 sw_options;
} __packed;
struct kvaser_cmd_busparams {
u8 tid;
u8 channel;
struct kvaser_usb_busparams busparams;
} __packed;
/* The device has one LED per CAN channel
* The LSB of action field controls the state:
* 0 = ON
* 1 = OFF
* The remaining bits of action field is the LED index
*/
#define KVASER_USB_LEAF_LED_IDX_MASK GENMASK(31, 1)
#define KVASER_USB_LEAF_LED_YELLOW_CH0_IDX 2
struct kvaser_cmd_led_action_req {
u8 tid;
u8 action;
__le16 duration_ms;
u8 padding[24];
} __packed;
struct kvaser_cmd_tx_can {
u8 channel;
u8 tid;
u8 data[14];
union {
struct {
u8 padding;
u8 flags;
} __packed leaf;
struct {
u8 flags;
u8 padding;
} __packed usbcan;
} __packed;
} __packed;
struct kvaser_cmd_rx_can_header {
u8 channel;
u8 flag;
} __packed;
struct leaf_cmd_rx_can {
u8 channel;
u8 flag;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/completion.h`, `linux/device.h`, `linux/gfp.h`, `linux/jiffies.h`, `linux/kernel.h`, `linux/netdevice.h`, `linux/spinlock.h`.
- Detected declarations: `struct kvaser_cmd_simple`, `struct kvaser_cmd_cardinfo`, `struct leaf_cmd_softinfo`, `struct usbcan_cmd_softinfo`, `struct kvaser_cmd_busparams`, `struct kvaser_cmd_led_action_req`, `struct kvaser_cmd_tx_can`, `struct kvaser_cmd_rx_can_header`, `struct leaf_cmd_rx_can`, `struct usbcan_cmd_rx_can`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.