drivers/usb/host/xhci-dbgtty.c
Source file repositories/reference/linux-study-clean/drivers/usb/host/xhci-dbgtty.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/host/xhci-dbgtty.c- Extension
.c- Size
- 14823 bytes
- Lines
- 669
- 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/slab.hlinux/tty.hlinux/tty_flip.hlinux/idr.hxhci.hxhci-dbgcap.h
Detected Declarations
function dbc_kfifo_to_reqfunction dbc_do_start_txfunction dbc_start_txfunction dbc_start_rxfunction dbc_rx_push_bufferfunction dbc_read_completefunction dbc_write_completefunction xhci_dbc_free_reqfunction xhci_dbc_alloc_requestsfunction xhci_dbc_free_requestsfunction dbc_tty_installfunction dbc_tty_openfunction dbc_tty_closefunction dbc_tty_writefunction dbc_tty_put_charfunction dbc_tty_flush_charsfunction dbc_tty_write_roomfunction dbc_tty_chars_in_bufferfunction dbc_tty_unthrottlefunction dbc_rx_pushfunction dbc_port_activatefunction xhci_dbc_tty_init_portfunction xhci_dbc_tty_exit_portfunction xhci_dbc_tty_register_devicefunction xhci_dbc_tty_unregister_devicefunction xhci_dbc_tty_probefunction tty_unregister_devicefunction dbc_tty_initfunction dbc_tty_exit
Annotated Snippet
if (status) {
list_add(&req->list_pool, pool);
break;
}
}
port->tx_running = false;
if (do_tty_wake && port->port.tty)
tty_wakeup(port->port.tty);
return status;
}
/* must be called with port->port_lock held */
static int dbc_start_tx(struct dbc_port *port)
{
lockdep_assert_held(&port->port_lock);
if (port->tx_running)
return -EBUSY;
return dbc_do_start_tx(port);
}
static void dbc_start_rx(struct dbc_port *port)
__releases(&port->port_lock)
__acquires(&port->port_lock)
{
struct dbc_request *req;
int status;
struct list_head *pool = &port->read_pool;
while (!list_empty(pool)) {
if (!port->port.tty)
break;
req = list_entry(pool->next, struct dbc_request, list_pool);
list_del(&req->list_pool);
req->length = DBC_MAX_PACKET;
spin_unlock(&port->port_lock);
status = dbc_ep_queue(req);
spin_lock(&port->port_lock);
if (status) {
list_add(&req->list_pool, pool);
break;
}
}
}
/*
* Queue received data to tty buffer and push it.
*
* Returns nr of remaining bytes that didn't fit tty buffer, i.e. 0 if all
* bytes sucessfullt moved. In case of error returns negative errno.
* Call with lock held
*/
static int dbc_rx_push_buffer(struct dbc_port *port, struct dbc_request *req)
{
char *packet = req->buf;
unsigned int n, size = req->actual;
int count;
if (!req->actual)
return 0;
/* if n_read is set then request was partially moved to tty buffer */
n = port->n_read;
if (n) {
packet += n;
size -= n;
}
count = tty_insert_flip_string(&port->port, packet, size);
if (count)
tty_flip_buffer_push(&port->port);
if (count != size) {
port->n_read += count;
return size - count;
}
port->n_read = 0;
return 0;
}
static void
dbc_read_complete(struct xhci_dbc *dbc, struct dbc_request *req)
{
Annotation
- Immediate include surface: `linux/slab.h`, `linux/tty.h`, `linux/tty_flip.h`, `linux/idr.h`, `xhci.h`, `xhci-dbgcap.h`.
- Detected declarations: `function dbc_kfifo_to_req`, `function dbc_do_start_tx`, `function dbc_start_tx`, `function dbc_start_rx`, `function dbc_rx_push_buffer`, `function dbc_read_complete`, `function dbc_write_complete`, `function xhci_dbc_free_req`, `function xhci_dbc_alloc_requests`, `function xhci_dbc_free_requests`.
- 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.