drivers/usb/serial/pl2303.c
Source file repositories/reference/linux-study-clean/drivers/usb/serial/pl2303.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/serial/pl2303.c- Extension
.c- Size
- 34922 bytes
- Lines
- 1311
- 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_driver.hlinux/tty_flip.hlinux/serial.hlinux/module.hlinux/moduleparam.hlinux/spinlock.hlinux/uaccess.hlinux/usb.hlinux/usb/serial.hlinux/unaligned.hpl2303.h
Detected Declarations
struct pl2303_type_datastruct pl2303_serial_privatestruct pl2303_privateenum pl2303_typefunction pl2303_vendor_readfunction pl2303_vendor_writefunction pl2303_update_regfunction pl2303_probefunction pl2303_endpoint_hackfunction pl2303_calc_num_portsfunction pl2303_supports_hx_statusfunction pl2303_detect_typefunction pl2303_is_hxd_clonefunction pl2303_startupfunction pl2303_releasefunction pl2303_port_probefunction pl2303_port_removefunction pl2303_set_control_linesfunction pl2303_get_supported_baud_ratefunction pl2303_encode_baud_rate_directfunction pl2303_encode_baud_rate_divisorfunction pl2303_encode_baud_rate_divisor_altfunction pl2303_encode_baud_ratefunction pl2303_get_line_requestfunction pl2303_set_line_requestfunction pl2303_termios_changefunction pl2303_enable_xonxofffunction pl2303_set_termiosfunction usedfunction pl2303_dtr_rtsfunction pl2303_closefunction pl2303_openfunction pl2303_tiocmsetfunction pl2303_tiocmgetfunction pl2303_carrier_raisedfunction pl2303_set_breakfunction pl2303_break_ctlfunction pl2303_update_line_statusfunction pl2303_read_int_callbackfunction pl2303_process_read_urb
Annotated Snippet
struct pl2303_type_data {
const char *name;
speed_t max_baud_rate;
unsigned long quirks;
unsigned int no_autoxonxoff:1;
unsigned int no_divisors:1;
unsigned int alt_divisors:1;
};
struct pl2303_serial_private {
const struct pl2303_type_data *type;
unsigned long quirks;
};
struct pl2303_private {
spinlock_t lock;
u8 line_control;
u8 line_status;
u8 line_settings[7];
};
static const struct pl2303_type_data pl2303_type_data[TYPE_COUNT] = {
[TYPE_H] = {
.name = "H",
.max_baud_rate = 1228800,
.quirks = PL2303_QUIRK_LEGACY,
.no_autoxonxoff = true,
},
[TYPE_HX] = {
.name = "HX",
.max_baud_rate = 6000000,
},
[TYPE_TA] = {
.name = "TA",
.max_baud_rate = 6000000,
.alt_divisors = true,
},
[TYPE_TB] = {
.name = "TB",
.max_baud_rate = 12000000,
.alt_divisors = true,
},
[TYPE_HXD] = {
.name = "HXD",
.max_baud_rate = 12000000,
},
[TYPE_HXN] = {
.name = "G",
.max_baud_rate = 12000000,
.no_divisors = true,
},
};
static int pl2303_vendor_read(struct usb_serial *serial, u16 value,
unsigned char buf[1])
{
struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
struct device *dev = &serial->interface->dev;
u8 request;
int res;
if (spriv->type == &pl2303_type_data[TYPE_HXN])
request = VENDOR_READ_NREQUEST;
else
request = VENDOR_READ_REQUEST;
res = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
request, VENDOR_READ_REQUEST_TYPE,
value, 0, buf, 1, 100);
if (res != 1) {
dev_err(dev, "%s - failed to read [%04x]: %d\n", __func__,
value, res);
if (res >= 0)
res = -EIO;
return res;
}
dev_dbg(dev, "%s - [%04x] = %02x\n", __func__, value, buf[0]);
return 0;
}
static int pl2303_vendor_write(struct usb_serial *serial, u16 value, u16 index)
{
struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
struct device *dev = &serial->interface->dev;
u8 request;
int res;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/errno.h`, `linux/slab.h`, `linux/tty.h`, `linux/tty_driver.h`, `linux/tty_flip.h`, `linux/serial.h`, `linux/module.h`.
- Detected declarations: `struct pl2303_type_data`, `struct pl2303_serial_private`, `struct pl2303_private`, `enum pl2303_type`, `function pl2303_vendor_read`, `function pl2303_vendor_write`, `function pl2303_update_reg`, `function pl2303_probe`, `function pl2303_endpoint_hack`, `function pl2303_calc_num_ports`.
- 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.