drivers/pci/pcie/ptm.c

Source file repositories/reference/linux-study-clean/drivers/pci/pcie/ptm.c

File Facts

System
Linux kernel
Corpus path
drivers/pci/pcie/ptm.c
Extension
.c
Size
13658 bytes
Lines
588
Domain
Representative Device Path
Bucket
PCIe NVMe Storage Path
Inferred role
Representative Device Path: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.

Dependency Surface

Detected Declarations

Annotated Snippet

static const struct file_operations context_update_fops = {
	.open = simple_open,
	.read = context_update_read,
	.write = context_update_write,
};

static int context_valid_get(void *data, u64 *val)
{
	struct pci_ptm_debugfs *ptm_debugfs = data;
	bool valid;
	int ret;

	if (!ptm_debugfs->ops->context_valid_read)
		return -EOPNOTSUPP;

	mutex_lock(&ptm_debugfs->lock);
	ret = ptm_debugfs->ops->context_valid_read(ptm_debugfs->pdata, &valid);
	mutex_unlock(&ptm_debugfs->lock);
	if (ret)
		return ret;

	*val = valid;

	return 0;
}

static int context_valid_set(void *data, u64 val)
{
	struct pci_ptm_debugfs *ptm_debugfs = data;
	int ret;

	if (!ptm_debugfs->ops->context_valid_write)
		return -EOPNOTSUPP;

	mutex_lock(&ptm_debugfs->lock);
	ret = ptm_debugfs->ops->context_valid_write(ptm_debugfs->pdata, !!val);
	mutex_unlock(&ptm_debugfs->lock);

	return ret;
}

DEFINE_DEBUGFS_ATTRIBUTE(context_valid_fops, context_valid_get,
			 context_valid_set, "%llu\n");

static int local_clock_get(void *data, u64 *val)
{
	struct pci_ptm_debugfs *ptm_debugfs = data;
	u64 clock;
	int ret;

	if (!ptm_debugfs->ops->local_clock_read)
		return -EOPNOTSUPP;

	ret = ptm_debugfs->ops->local_clock_read(ptm_debugfs->pdata, &clock);
	if (ret)
		return ret;

	*val = clock;

	return 0;
}

DEFINE_DEBUGFS_ATTRIBUTE(local_clock_fops, local_clock_get, NULL, "%llu\n");

static int master_clock_get(void *data, u64 *val)
{
	struct pci_ptm_debugfs *ptm_debugfs = data;
	u64 clock;
	int ret;

	if (!ptm_debugfs->ops->master_clock_read)
		return -EOPNOTSUPP;

	ret = ptm_debugfs->ops->master_clock_read(ptm_debugfs->pdata, &clock);
	if (ret)
		return ret;

	*val = clock;

	return 0;
}

DEFINE_DEBUGFS_ATTRIBUTE(master_clock_fops, master_clock_get, NULL, "%llu\n");

static int t1_get(void *data, u64 *val)
{
	struct pci_ptm_debugfs *ptm_debugfs = data;
	u64 clock;
	int ret;

Annotation

Implementation Notes