drivers/usb/serial/cp210x.c
Source file repositories/reference/linux-study-clean/drivers/usb/serial/cp210x.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/serial/cp210x.c- Extension
.c- Size
- 66727 bytes
- Lines
- 2202
- Domain
- Driver Families
- Bucket
- drivers/usb
- 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/kernel.hlinux/errno.hlinux/slab.hlinux/tty.hlinux/tty_flip.hlinux/module.hlinux/usb.hlinux/usb/serial.hlinux/gpio/driver.hlinux/bitops.hlinux/mutex.h
Detected Declarations
struct cp210x_serial_privatestruct cp210x_port_privatestruct cp210x_special_charsstruct cp210x_comm_statusstruct cp210x_flow_ctlstruct cp210x_pin_modestruct cp210x_dual_port_configstruct cp210x_single_port_configstruct cp210x_quad_port_statestruct cp210x_quad_port_configstruct cp210x_gpio_writestruct cp210x_gpio_write16struct cp210x_rateenum cp210x_event_statefunction cp210x_interface_numfunction cp210x_read_reg_blockfunction cp210x_read_u8_regfunction cp210x_read_vendor_blockfunction cp210x_write_u16_regfunction cp210x_write_reg_blockfunction cp210x_write_u32_regfunction cp210x_write_vendor_blockfunction cp210x_openfunction cp210x_closefunction cp210x_process_lsrfunction cp210x_process_charfunction cp210x_process_read_urbfunction cp210x_get_tx_queue_byte_countfunction cp210x_tx_emptyfunction cp210x_get_an205_ratefunction cp210x_get_actual_ratefunction undefinedfunction cp210x_enable_event_modefunction cp210x_disable_event_modefunction cp210x_termios_changefunction cp210x_set_flow_controlfunction ulFlowReplacefunction cp210x_set_termiosfunction cp210x_tiocmsetfunction cp210x_tiocmset_portfunction cp210x_dtr_rtsfunction cp210x_tiocmgetfunction cp210x_break_ctlfunction cp210x_gpio_getfunction cp210x_gpio_setfunction cp210x_gpio_direction_getfunction cp210x_gpio_direction_inputfunction cp210x_gpio_direction_output
Annotated Snippet
struct cp210x_serial_private {
#ifdef CONFIG_GPIOLIB
struct gpio_chip gc;
bool gpio_registered;
u16 gpio_pushpull;
u16 gpio_altfunc;
u16 gpio_input;
#endif
u8 partnum;
u32 fw_version;
speed_t min_speed;
speed_t max_speed;
bool use_actual_rate;
bool no_flow_control;
bool no_event_mode;
};
enum cp210x_event_state {
ES_DATA,
ES_ESCAPE,
ES_LSR,
ES_LSR_DATA_0,
ES_LSR_DATA_1,
ES_MSR
};
struct cp210x_port_private {
u8 bInterfaceNumber;
bool event_mode;
enum cp210x_event_state event_state;
u8 lsr;
struct mutex mutex;
bool crtscts;
bool dtr;
bool rts;
};
static struct usb_serial_driver cp210x_device = {
.driver = {
.name = "cp210x",
},
.id_table = id_table,
.num_ports = 1,
.bulk_in_size = 256,
.bulk_out_size = 256,
.open = cp210x_open,
.close = cp210x_close,
.break_ctl = cp210x_break_ctl,
.set_termios = cp210x_set_termios,
.tx_empty = cp210x_tx_empty,
.throttle = usb_serial_generic_throttle,
.unthrottle = usb_serial_generic_unthrottle,
.tiocmget = cp210x_tiocmget,
.tiocmset = cp210x_tiocmset,
.get_icount = usb_serial_generic_get_icount,
.attach = cp210x_attach,
.disconnect = cp210x_disconnect,
.release = cp210x_release,
.port_probe = cp210x_port_probe,
.port_remove = cp210x_port_remove,
.dtr_rts = cp210x_dtr_rts,
.process_read_urb = cp210x_process_read_urb,
};
static struct usb_serial_driver * const serial_drivers[] = {
&cp210x_device, NULL
};
/* Config request types */
#define REQTYPE_HOST_TO_INTERFACE 0x41
#define REQTYPE_INTERFACE_TO_HOST 0xc1
#define REQTYPE_HOST_TO_DEVICE 0x40
#define REQTYPE_DEVICE_TO_HOST 0xc0
/* Config request codes */
#define CP210X_IFC_ENABLE 0x00
#define CP210X_SET_BAUDDIV 0x01
#define CP210X_GET_BAUDDIV 0x02
#define CP210X_SET_LINE_CTL 0x03
#define CP210X_GET_LINE_CTL 0x04
#define CP210X_SET_BREAK 0x05
#define CP210X_IMM_CHAR 0x06
#define CP210X_SET_MHS 0x07
#define CP210X_GET_MDMSTS 0x08
#define CP210X_SET_XON 0x09
#define CP210X_SET_XOFF 0x0A
#define CP210X_SET_EVENTMASK 0x0B
#define CP210X_GET_EVENTMASK 0x0C
#define CP210X_SET_CHAR 0x0D
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/errno.h`, `linux/slab.h`, `linux/tty.h`, `linux/tty_flip.h`, `linux/module.h`, `linux/usb.h`, `linux/usb/serial.h`.
- Detected declarations: `struct cp210x_serial_private`, `struct cp210x_port_private`, `struct cp210x_special_chars`, `struct cp210x_comm_status`, `struct cp210x_flow_ctl`, `struct cp210x_pin_mode`, `struct cp210x_dual_port_config`, `struct cp210x_single_port_config`, `struct cp210x_quad_port_state`, `struct cp210x_quad_port_config`.
- Atlas domain: Driver Families / drivers/usb.
- 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.