Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15369742
  • 博文数量: 2005
  • 博客积分: 11986
  • 博客等级: 上将
  • 技术积分: 22535
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-17 13:56
文章分类

全部博文(2005)

文章存档

2014年(2)

2013年(2)

2012年(16)

2011年(66)

2010年(368)

2009年(743)

2008年(491)

2007年(317)

分类:

2010-05-16 11:43:10

/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,
};
阅读(3340) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~

2011-05-22 15:26:14

学习了,多谢楼主分享哦!也欢迎广大linux爱好者来我的论坛一起讨论arm哦!www.lt-net.cn

chinaunix网友2010-06-17 23:11:59

disocuntMBT Shoes on sale! Welcome to our online store! www.my-cheapshoes.com. MBT Shoes stands for Masai Barefoot Technology. The uniquely-designed, multi-layered, cured sole is designed to simulate walking in sand. If you love MBT Shoes, please come to our store. We offer Wome