drivers/gpu/drm/i915/display/intel_display_debugfs_params.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/display/intel_display_debugfs_params.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/i915/display/intel_display_debugfs_params.c
Extension
.c
Size
4619 bytes
Lines
178
Domain
Driver Families
Bucket
drivers/gpu
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 intel_display_param_int_fops = {
	.owner = THIS_MODULE,
	.open = intel_display_param_int_open,
	.read = seq_read,
	.write = intel_display_param_int_write,
	.llseek = default_llseek,
	.release = single_release,
};

static const struct file_operations intel_display_param_int_fops_ro = {
	.owner = THIS_MODULE,
	.open = intel_display_param_int_open,
	.read = seq_read,
	.llseek = default_llseek,
	.release = single_release,
};

/* unsigned int param */
static int intel_display_param_uint_show(struct seq_file *m, void *data)
{
	unsigned int *value = m->private;

	seq_printf(m, "%u\n", *value);

	return 0;
}

static int intel_display_param_uint_open(struct inode *inode, struct file *file)
{
	return single_open(file, intel_display_param_uint_show, inode->i_private);
}

static ssize_t intel_display_param_uint_write(struct file *file,
					      const char __user *ubuf, size_t len,
					      loff_t *offp)
{
	struct seq_file *m = file->private_data;
	unsigned int *value = m->private;
	int ret;

	ret = kstrtouint_from_user(ubuf, len, 0, value);
	if (ret) {
		/* support boolean values too */
		bool b;

		ret = kstrtobool_from_user(ubuf, len, &b);
		if (!ret)
			*value = b;
	}

	return ret ?: len;
}

static const struct file_operations intel_display_param_uint_fops = {
	.owner = THIS_MODULE,
	.open = intel_display_param_uint_open,
	.read = seq_read,
	.write = intel_display_param_uint_write,
	.llseek = default_llseek,
	.release = single_release,
};

static const struct file_operations intel_display_param_uint_fops_ro = {
	.owner = THIS_MODULE,
	.open = intel_display_param_uint_open,
	.read = seq_read,
	.llseek = default_llseek,
	.release = single_release,
};

#define RO(mode) (((mode) & 0222) == 0)

__maybe_unused static struct dentry *
intel_display_debugfs_create_int(const char *name, umode_t mode,
			struct dentry *parent, int *value)
{
	return debugfs_create_file_unsafe(name, mode, parent, value,
					  RO(mode) ? &intel_display_param_int_fops_ro :
					  &intel_display_param_int_fops);
}

__maybe_unused static struct dentry *
intel_display_debugfs_create_uint(const char *name, umode_t mode,
			 struct dentry *parent, unsigned int *value)
{
	return debugfs_create_file_unsafe(name, mode, parent, value,
					  RO(mode) ? &intel_display_param_uint_fops_ro :
					  &intel_display_param_uint_fops);
}

Annotation

Implementation Notes