drivers/net/can/usb/peak_usb/pcan_usb_pro.c
Source file repositories/reference/linux-study-clean/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/can/usb/peak_usb/pcan_usb_pro.c- Extension
.c- Size
- 27823 bytes
- Lines
- 1103
- 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.
- 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/ethtool.hlinux/module.hlinux/netdevice.hlinux/usb.hlinux/can.hlinux/can/dev.hlinux/can/error.hpcan_usb_core.hpcan_usb_pro.h
Detected Declarations
struct pcan_usb_pro_interfacestruct pcan_usb_pro_devicestruct pcan_usb_pro_msgfunction pcan_msg_add_recfunction pcan_usb_pro_send_cmdfunction pcan_usb_pro_wait_rspfunction pcan_usb_pro_send_reqfunction pcan_usb_pro_set_tsfunction pcan_usb_pro_set_bitratefunction pcan_usb_pro_set_busfunction pcan_usb_pro_set_silentfunction pcan_usb_pro_set_filterfunction pcan_usb_pro_set_ledfunction pcan_usb_pro_get_can_channel_idfunction pcan_usb_pro_set_can_channel_idfunction pcan_usb_pro_set_bittimingfunction pcan_usb_pro_restart_completefunction pcan_usb_pro_restart_asyncfunction pcan_usb_pro_drv_loadedfunction pcan_usb_pro_handle_canmsgfunction pcan_usb_pro_handle_errorfunction pcan_usb_pro_handle_tsfunction pcan_usb_pro_decode_buffunction pcan_usb_pro_encode_msgfunction pcan_usb_pro_startfunction pcan_usb_pro_stopfunction pcan_usb_pro_initfunction pcan_usb_pro_exitfunction pcan_usb_pro_freefunction pcan_usb_pro_probefunction pcan_usb_pro_set_phys_id
Annotated Snippet
struct pcan_usb_pro_interface {
struct peak_usb_device *dev[PCAN_USBPRO_CHANNEL_COUNT];
struct peak_time_ref time_ref;
int cm_ignore_count;
int dev_opened_count;
};
/* device information */
struct pcan_usb_pro_device {
struct peak_usb_device dev;
struct pcan_usb_pro_interface *usb_if;
u32 cached_ccbt;
};
/* internal structure used to handle messages sent to bulk urb */
struct pcan_usb_pro_msg {
u8 *rec_ptr;
int rec_buffer_size;
int rec_buffer_len;
union {
__le16 *rec_cnt_rd;
__le32 *rec_cnt;
u8 *rec_buffer;
} u;
};
/* records sizes table indexed on message id. (8-bits value) */
static u16 pcan_usb_pro_sizeof_rec[256] = {
[PCAN_USBPRO_SETBTR] = sizeof(struct pcan_usb_pro_btr),
[PCAN_USBPRO_SETBUSACT] = sizeof(struct pcan_usb_pro_busact),
[PCAN_USBPRO_SETSILENT] = sizeof(struct pcan_usb_pro_silent),
[PCAN_USBPRO_SETFILTR] = sizeof(struct pcan_usb_pro_filter),
[PCAN_USBPRO_SETTS] = sizeof(struct pcan_usb_pro_setts),
[PCAN_USBPRO_GETDEVID] = sizeof(struct pcan_usb_pro_devid),
[PCAN_USBPRO_SETDEVID] = sizeof(struct pcan_usb_pro_devid),
[PCAN_USBPRO_SETLED] = sizeof(struct pcan_usb_pro_setled),
[PCAN_USBPRO_RXMSG8] = sizeof(struct pcan_usb_pro_rxmsg),
[PCAN_USBPRO_RXMSG4] = sizeof(struct pcan_usb_pro_rxmsg) - 4,
[PCAN_USBPRO_RXMSG0] = sizeof(struct pcan_usb_pro_rxmsg) - 8,
[PCAN_USBPRO_RXRTR] = sizeof(struct pcan_usb_pro_rxmsg) - 8,
[PCAN_USBPRO_RXSTATUS] = sizeof(struct pcan_usb_pro_rxstatus),
[PCAN_USBPRO_RXTS] = sizeof(struct pcan_usb_pro_rxts),
[PCAN_USBPRO_TXMSG8] = sizeof(struct pcan_usb_pro_txmsg),
[PCAN_USBPRO_TXMSG4] = sizeof(struct pcan_usb_pro_txmsg) - 4,
[PCAN_USBPRO_TXMSG0] = sizeof(struct pcan_usb_pro_txmsg) - 8,
};
/*
* initialize PCAN-USB Pro message data structure
*/
static u8 *pcan_msg_init(struct pcan_usb_pro_msg *pm, void *buffer_addr,
int buffer_size)
{
if (buffer_size < PCAN_USBPRO_MSG_HEADER_LEN)
return NULL;
pm->u.rec_buffer = (u8 *)buffer_addr;
pm->rec_buffer_size = pm->rec_buffer_len = buffer_size;
pm->rec_ptr = pm->u.rec_buffer + PCAN_USBPRO_MSG_HEADER_LEN;
return pm->rec_ptr;
}
static u8 *pcan_msg_init_empty(struct pcan_usb_pro_msg *pm,
void *buffer_addr, int buffer_size)
{
u8 *pr = pcan_msg_init(pm, buffer_addr, buffer_size);
if (pr) {
pm->rec_buffer_len = PCAN_USBPRO_MSG_HEADER_LEN;
*pm->u.rec_cnt = 0;
}
return pr;
}
/*
* add one record to a message being built
*/
static int pcan_msg_add_rec(struct pcan_usb_pro_msg *pm, int id, ...)
{
int len, i;
u8 *pc;
va_list ap;
va_start(ap, id);
pc = pm->rec_ptr + 1;
i = 0;
switch (id) {
Annotation
- Immediate include surface: `linux/ethtool.h`, `linux/module.h`, `linux/netdevice.h`, `linux/usb.h`, `linux/can.h`, `linux/can/dev.h`, `linux/can/error.h`, `pcan_usb_core.h`.
- Detected declarations: `struct pcan_usb_pro_interface`, `struct pcan_usb_pro_device`, `struct pcan_usb_pro_msg`, `function pcan_msg_add_rec`, `function pcan_usb_pro_send_cmd`, `function pcan_usb_pro_wait_rsp`, `function pcan_usb_pro_send_req`, `function pcan_usb_pro_set_ts`, `function pcan_usb_pro_set_bitrate`, `function pcan_usb_pro_set_bus`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
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.