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.

Dependency Surface

Detected Declarations

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

Implementation Notes