demo.h

来自「《linux驱动程序设计从入门到精通》一书中所有的程序代码含驱动和相应的应用程序」· C头文件 代码 · 共 47 行

H
47
字号
#ifndef _DEMO_H_#define _DEMO_H_#include <linux/ioctl.h> /* needed for the _IOW etc stuff used later *//******************************************************** * Macros to help debugging ********************************************************/#undef PDEBUG             /* undef it, just in case */#ifdef DEMO_DEBUG#ifdef __KERNEL__#    define PDEBUG(fmt, args...) printk( KERN_DEBUG "DEMO: " fmt, ## args)#else//usr space#    define PDEBUG(fmt, args...) fprintf(stderr, fmt, ## args)#endif#else#  define PDEBUG(fmt, args...) /* not debugging: nothing */#endif#undef PDEBUGG#define PDEBUGG(fmt, args...) /* nothing: it's a placeholder *///设备号#define DEMO_MAJOR 224#define DEMO_MINOR 0#define COMMAND1 1#define COMMAND2 2//设备结构struct DEMO_dev {	struct cdev cdev;	  /* Char device structure		*/};//函数申明ssize_t DEMO_read(struct file *filp, char __user *buf, size_t count,                   loff_t *f_pos);ssize_t DEMO_write(struct file *filp, const char __user *buf, size_t count,                    loff_t *f_pos);loff_t  DEMO_llseek(struct file *filp, loff_t off, int whence);int     DEMO_ioctl(struct inode *inode, struct file *filp,                    unsigned int cmd, unsigned long arg);#endif /* _DEMO_H_ */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?