drivers/net/can/usb/peak_usb/pcan_usb_core.h

Source file repositories/reference/linux-study-clean/drivers/net/can/usb/peak_usb/pcan_usb_core.h

File Facts

System
Linux kernel
Corpus path
drivers/net/can/usb/peak_usb/pcan_usb_core.h
Extension
.h
Size
5003 bytes
Lines
157
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 peak_usb_adapter {
	char *name;
	u32 device_id;
	u32 ctrlmode_supported;
	struct can_clock clock;
	const struct can_bittiming_const * const bittiming_const;
	const struct can_bittiming_const * const data_bittiming_const;
	unsigned int ctrl_count;

	const struct ethtool_ops *ethtool_ops;

	int (*intf_probe)(struct usb_interface *intf);

	int (*dev_init)(struct peak_usb_device *dev);
	void (*dev_exit)(struct peak_usb_device *dev);
	void (*dev_free)(struct peak_usb_device *dev);
	int (*dev_open)(struct peak_usb_device *dev);
	int (*dev_close)(struct peak_usb_device *dev);
	int (*dev_set_bittiming)(struct peak_usb_device *dev,
					struct can_bittiming *bt);
	int (*dev_set_data_bittiming)(struct peak_usb_device *dev,
				      struct can_bittiming *bt);
	int (*dev_set_bus)(struct peak_usb_device *dev, u8 onoff);
	int (*dev_get_can_channel_id)(struct peak_usb_device *dev, u32 *can_ch_id);
	int (*dev_set_can_channel_id)(struct peak_usb_device *dev, u32 can_ch_id);
	int (*dev_decode_buf)(struct peak_usb_device *dev, struct urb *urb);
	int (*dev_encode_msg)(struct peak_usb_device *dev, struct sk_buff *skb,
					u8 *obuf, size_t *size);
	int (*dev_start)(struct peak_usb_device *dev);
	int (*dev_stop)(struct peak_usb_device *dev);
	int (*dev_restart_async)(struct peak_usb_device *dev, struct urb *urb,
					u8 *buf);
	int (*do_get_berr_counter)(const struct net_device *netdev,
				   struct can_berr_counter *bec);
	u8 ep_msg_in;
	u8 ep_msg_out[PCAN_USB_MAX_CHANNEL];
	u8 ts_used_bits;
	u8 us_per_ts_shift;
	u32 us_per_ts_scale;

	int rx_buffer_size;
	int tx_buffer_size;
	int sizeof_dev_private;
};

extern const struct peak_usb_adapter pcan_usb;
extern const struct peak_usb_adapter pcan_usb_pro;
extern const struct peak_usb_adapter pcan_usb_fd;
extern const struct peak_usb_adapter pcan_usb_chip;
extern const struct peak_usb_adapter pcan_usb_pro_fd;
extern const struct peak_usb_adapter pcan_usb_x6;

struct peak_time_ref {
	ktime_t tv_host_0, tv_host;
	u32 ts_dev_1, ts_dev_2;
	u64 ts_total;
	u32 tick_count;
	const struct peak_usb_adapter *adapter;
};

struct peak_tx_urb_context {
	struct peak_usb_device *dev;
	u32 echo_index;
	struct urb *urb;
};

#define PCAN_USB_STATE_CONNECTED	0x00000001
#define PCAN_USB_STATE_STARTED		0x00000002

/* PEAK-System USB device */
struct peak_usb_device {
	struct can_priv can;
	const struct peak_usb_adapter *adapter;
	unsigned int ctrl_idx;
	u32 state;

	struct usb_device *udev;
	struct net_device *netdev;

	atomic_t active_tx_urbs;
	struct usb_anchor tx_submitted;
	struct peak_tx_urb_context tx_contexts[PCAN_USB_MAX_TX_URBS];

	u8 *cmd_buf;
	struct usb_anchor rx_submitted;

	/* equivalent to the device ID in the Windows API */
	u32 can_channel_id;
	u8 device_rev;

Annotation

Implementation Notes