码迷,mamicode.com
首页 > 其他好文 > 详细

/proc/iomem和/proc/ioports对应的fops

时间:2015-07-09 17:42:22      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:

/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,
};

/proc/iomem和/proc/ioports对应的fops

标签:

原文地址:http://www.cnblogs.com/cute/p/4633535.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!