drivers/usb/host/xhci-debugfs.c

Source file repositories/reference/linux-study-clean/drivers/usb/host/xhci-debugfs.c

File Facts

System
Linux kernel
Corpus path
drivers/usb/host/xhci-debugfs.c
Extension
.c
Size
22033 bytes
Lines
855
Domain
Driver Families
Bucket
drivers/usb
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern 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

static const struct file_operations xhci_ring_fops = {
	.open			= xhci_ring_open,
	.read			= seq_read,
	.llseek			= seq_lseek,
	.release		= single_release,
};

static int xhci_slot_context_show(struct seq_file *s, void *unused)
{
	struct xhci_hcd		*xhci;
	struct xhci_slot_ctx	*slot_ctx;
	struct xhci_slot_priv	*priv = s->private;
	struct xhci_virt_device	*dev = priv->dev;
	char			str[XHCI_MSG_MAX];

	xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus));
	slot_ctx = xhci_get_slot_ctx(xhci, dev->out_ctx);
	seq_printf(s, "%pad: %s\n", &dev->out_ctx->dma,
		   xhci_decode_slot_context(str,
					    le32_to_cpu(slot_ctx->dev_info),
					    le32_to_cpu(slot_ctx->dev_info2),
					    le32_to_cpu(slot_ctx->tt_info),
					    le32_to_cpu(slot_ctx->dev_state)));

	return 0;
}

static int xhci_endpoint_context_show(struct seq_file *s, void *unused)
{
	int			ep_index;
	dma_addr_t		dma;
	struct xhci_hcd		*xhci;
	struct xhci_ep_ctx	*ep_ctx;
	struct xhci_slot_priv	*priv = s->private;
	struct xhci_virt_device	*dev = priv->dev;
	char			str[XHCI_MSG_MAX];

	xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus));

	for (ep_index = 0; ep_index < 31; ep_index++) {
		ep_ctx = xhci_get_ep_ctx(xhci, dev->out_ctx, ep_index);
		dma = dev->out_ctx->dma + (ep_index + 1) * CTX_SIZE(xhci->hcc_params);
		seq_printf(s, "%pad: %s, virt_state:%#x\n", &dma,
			   xhci_decode_ep_context(str,
						  le32_to_cpu(ep_ctx->ep_info),
						  le32_to_cpu(ep_ctx->ep_info2),
						  le64_to_cpu(ep_ctx->deq),
						  le32_to_cpu(ep_ctx->tx_info)),
						  dev->eps[ep_index].ep_state);
	}

	return 0;
}

static int xhci_device_name_show(struct seq_file *s, void *unused)
{
	struct xhci_slot_priv	*priv = s->private;
	struct xhci_virt_device	*dev = priv->dev;

	seq_printf(s, "%s\n", dev_name(&dev->udev->dev));

	return 0;
}

static struct xhci_file_map context_files[] = {
	{"name",		xhci_device_name_show, },
	{"slot-context",	xhci_slot_context_show, },
	{"ep-context",		xhci_endpoint_context_show, },
};

static int xhci_context_open(struct inode *inode, struct file *file)
{
	const struct xhci_file_map *f_map = debugfs_get_aux(file);

	return single_open(file, f_map->show, inode->i_private);
}

static const struct file_operations xhci_context_fops = {
	.open			= xhci_context_open,
	.read			= seq_read,
	.llseek			= seq_lseek,
	.release		= single_release,
};



static int xhci_portsc_show(struct seq_file *s, void *unused)
{
	struct xhci_port	*port = s->private;
	u32			portsc;

Annotation

Implementation Notes