Linux字符设备驱动框架详解(2)

根据file_operations结构成员的原型,这里我们需要实现如下回调:

int (*open) (struct inode *, struct file *); ssize_t (*read) (struct file *, char __user *, size_t, loff_t *); int (*release) (struct inode *, struct file *);

open和close函数为了简单起见不做任何处理,只是简单的输出kernel信息:

int simple_open(struct inode * pnode, struct file * pfile) { printk(KERN_INFO "open simple\n"); return 0; } int simple_release(struct inode * pnode, struct file * pfile) { printk(KERN_INFO "close simple\n"); return 0; }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/a85f8713204b6bdf29d85079eb2fc96b.html