亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Linux混雜設備驅動學習

Original 2016-11-09 13:31:31 442
abstract:Linux混雜設備是字符設備的一類,主要是混雜設備擁有相同的主設備號(10),但是次設備號是不同的。所有的混雜設備行程一個鏈表,對設備訪問時內(nèi)核更據(jù)次設備號查找到相應的混雜設備?;祀s設備用struct miscdevice來描述一個混雜設備。struct miscdevice  {     int minor;  /*

Linux混雜設備是字符設備的一類,主要是混雜設備擁有相同的主設備號(10),但是次設備號是不同的。所有的混雜設備行程一個鏈表,對設備訪問時內(nèi)核更據(jù)次設備號查找到相應的混雜設備。

混雜設備用struct miscdevice來描述一個混雜設備。

struct miscdevice  {
    int minor;  /*次設備號*/
    const char *name;  /*設備名*/
    const struct file_operations *fops;  /*文件操作 其他由內(nèi)核來完成*/
    struct list_head list;
    struct device *parent;
    struct device *this_device;
    const char *nodename;
    mode_t mode;
};

首先初始化結構體struct miscdevice 

  初始化struct file_operations *

  完成 struct file_operations * 對應的函數(shù)

在模塊初始化函數(shù)中,注冊設備驅動mis_register()即可

注銷mis_deregister()

#include <linux/miscdevice.h>


Release Notes

Popular Entries