系统大全为您提供开始学习驱动的时候,是将驱动程序编译成模块然后用mknod命令手动建立设备节点以提供给应用程序调用。这对于刚开始调试驱动程序的时候常用的一种方法。但是,当有种需要必须在系统启动的时候就将驱动程序就绪,来供应用层程序调用。这时就不能再手动的建立设备节点了,而必须自动的创建设备节点(不需要人为的操作)。★注册类注册类的目的是为了使mdev可以在/dev/目录下建立设备节点。首先要定义一个类,利用struct class结构体。这个结构体定义在头文件includenux/device.h中struct class {const char* name;struct module* owner;struct subsystemsubsys;struct list_headchildren;struct list_headdevices;struct list_headinterfaces;struct semaphoresem;/* locks both the children and interfaces lists */struct kobject*virtual_dir;struct class_attribute* class_attrs;struct class_device_attribute* class_dev_attrs;struct device_attribute* dev_attrs;int(*uevent)(struct class_device *dev, char **envp, int num_envp, char *buffer, int buffer_size);int(*dev_uevent)(struct device *dev, char **envp, int num_envp,char *buffer, int buffer_size);void(*release)(struct class_device *dev);void(*class_release)(struct class *class);void(*dev_release)(struct device *dev);int(*suspend)(struct device *, pm_message_t state);int(*resume)(struct device *);} 然后使用 完成对类的注册。其中第一个参数一般为:THIS_MODULE。第二个参数为:设备节点的名称举个例子:★创建设备节点创建设备节点的函数: