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.

Dependency Surface

Detected Declarations

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

Implementation Notes