drivers/media/usb/pvrusb2/pvrusb2-sysfs.c

Source file repositories/reference/linux-study-clean/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c

File Facts

System
Linux kernel
Corpus path
drivers/media/usb/pvrusb2/pvrusb2-sysfs.c
Extension
.c
Size
22403 bytes
Lines
812
Domain
Driver Families
Bucket
drivers/media
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

struct pvr2_sysfs {
	struct pvr2_channel channel;
	struct device *class_dev;
#ifdef CONFIG_VIDEO_PVRUSB2_DEBUGIFC
	struct pvr2_sysfs_debugifc *debugifc;
#endif /* CONFIG_VIDEO_PVRUSB2_DEBUGIFC */
	struct pvr2_sysfs_ctl_item *item_first;
	struct pvr2_sysfs_ctl_item *item_last;
	struct device_attribute attr_v4l_minor_number;
	struct device_attribute attr_v4l_radio_minor_number;
	struct device_attribute attr_unit_number;
	struct device_attribute attr_bus_info;
	struct device_attribute attr_hdw_name;
	struct device_attribute attr_hdw_desc;
	int v4l_minor_number_created_ok;
	int v4l_radio_minor_number_created_ok;
	int unit_number_created_ok;
	int bus_info_created_ok;
	int hdw_name_created_ok;
	int hdw_desc_created_ok;
};

#ifdef CONFIG_VIDEO_PVRUSB2_DEBUGIFC
struct pvr2_sysfs_debugifc {
	struct device_attribute attr_debugcmd;
	struct device_attribute attr_debuginfo;
	int debugcmd_created_ok;
	int debuginfo_created_ok;
};
#endif /* CONFIG_VIDEO_PVRUSB2_DEBUGIFC */

struct pvr2_sysfs_ctl_item {
	struct device_attribute attr_name;
	struct device_attribute attr_type;
	struct device_attribute attr_min;
	struct device_attribute attr_max;
	struct device_attribute attr_def;
	struct device_attribute attr_enum;
	struct device_attribute attr_bits;
	struct device_attribute attr_val;
	struct device_attribute attr_custom;
	struct pvr2_ctrl *cptr;
	int ctl_id;
	struct pvr2_sysfs *chptr;
	struct pvr2_sysfs_ctl_item *item_next;
	struct attribute *attr_gen[8];
	struct attribute_group grp;
	int created_ok;
	char name[80];
};

static ssize_t show_name(struct device *class_dev,
			 struct device_attribute *attr,
			 char *buf)
{
	struct pvr2_sysfs_ctl_item *cip;
	const char *name;
	cip = container_of(attr, struct pvr2_sysfs_ctl_item, attr_name);
	name = pvr2_ctrl_get_desc(cip->cptr);
	pvr2_sysfs_trace("pvr2_sysfs(%p) show_name(cid=%d) is %s",
			 cip->chptr, cip->ctl_id, name);
	if (!name) return -EINVAL;
	return sysfs_emit(buf, "%s\n", name);
}

static ssize_t show_type(struct device *class_dev,
			 struct device_attribute *attr,
			 char *buf)
{
	struct pvr2_sysfs_ctl_item *cip;
	const char *name;
	enum pvr2_ctl_type tp;
	cip = container_of(attr, struct pvr2_sysfs_ctl_item, attr_type);
	tp = pvr2_ctrl_get_type(cip->cptr);
	switch (tp) {
	case pvr2_ctl_int: name = "integer"; break;
	case pvr2_ctl_enum: name = "enum"; break;
	case pvr2_ctl_bitmask: name = "bitmask"; break;
	case pvr2_ctl_bool: name = "boolean"; break;
	default: name = "?"; break;
	}
	pvr2_sysfs_trace("pvr2_sysfs(%p) show_type(cid=%d) is %s",
			 cip->chptr, cip->ctl_id, name);
	return sysfs_emit(buf, "%s\n", name);
}

static ssize_t show_min(struct device *class_dev,
			struct device_attribute *attr,
			char *buf)
{

Annotation

Implementation Notes