/proc/iomem和/proc/ioports对应的fops
static int __init ioresources_init(void)
{
struct proc_dir_entry *entry;
entry = create_proc_entry("ioports", 0, NULL);
if (entry)
entry->proc_fops = &proc_ioports_operations;
entry = create_proc_entry("iomem", 0, NULL);
if (entry)
entry->proc_fops = &proc_iomem_operations;
return 0;
}
__initcall(ioresources_init);
static const struct file_operations proc_iomem_operations = {
.open = iomem_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
static int iomem_open(struct inode *inode, struct file *file)
{
int res = seq_open(file, &resource_op); // seq方法集resource_op
if (!res) {
struct seq_file *m = file->private_data;
m->private = &iomem_resource; // 被操作数据iomem_resource
}
return res;
}
static const struct file_operations proc_ioports_operations = {
.open = ioports_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
static int ioports_open(struct inode *inode, struct file *file)
{
int res = seq_open(file, &resource_op); // seq方法集resource_op
if (!res) {
struct seq_file *m = file->private_data;
m->private = &ioport_resource; // 被操作数据ioport_resource
}
return res;
}
static const struct seq_operations resource_op = {
.start = r_start,
.next = r_next,
.stop = r_stop,
.show = r_show,
};
阅读(3386) | 评论(2) | 转发(0) |