日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

class_create和class_device_create

發布時間:2023/12/20 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 class_create和class_device_create 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
//主要是在/sys/class/ 下創建一個 “name”的文件夾 !從linux內核2.6的某個版本之后,devfs不復存在,udev成為devfs的替代。相比devfs,udev有很多優勢,在此就不羅嗦了,提醒一點,udev是應用層的東東,不要試圖在內核的配置選項里找到它;加入對udev的支持很簡單,以作者所寫的一個字符設備驅動為例,在驅動初始化的代碼里調用class_create為該設備創建一個class,再為每個設備調用 class_device_create創建對應的設備。大致用法如下: struct class *myclass = class_create(THIS_MODULE, “my_device_driver”); class_device_create(myclass, NULL, MKDEV(major_num, 0), NULL, “my_device”); 這樣的module被加載時,udev daemon就會自動在/dev下創建my_device設備文件。class_create() ------------------------------------------------- linux-2.6.22/include/linux/device.h struct class *class_create(struct module *owner, const char *name)class_create - create a struct class structure@owner: pointer to the module that is to "own" this struct class@name: pointer to a string for the name of this class. 在/sys/class/下創建類目錄class_device_create() ------------------------------------------------- linux-2.6.22/include/linux/device.h struct class_device *class_device_create(struct class *cls,struct class_device *parent,dev_t devt,struct device *device,const char *fmt, ...)class_device_create - creates a class device and registers it with sysfs@cls: pointer to the struct class that this device should be registered to.@parent: pointer to the parent struct class_device of this new device, if any.@devt: the dev_t for the char device to be added.@device: a pointer to a struct device that is assiociated with this class device.@fmt: string for the class device's name //主要是在/sys/class/ 下創建一個 “name”的文件夾 !從linux內核2.6的某個版本之后,devfs不復存在,udev成為devfs的替代。相比devfs,udev有很多優勢,在此就不羅嗦了,提醒一點,udev是應用層的東東,不要試圖在內核的配置選項里找到它;加入對udev的支持很簡單,以作者所寫的一個字符設備驅動為例,在驅動初始化的代碼里調用class_create為該設備創建一個class,再為每個設備調用 class_device_create創建對應的設備。大致用法如下: struct class *myclass = class_create(THIS_MODULE, “my_device_driver”); class_device_create(myclass, NULL, MKDEV(major_num, 0), NULL, “my_device”); 這樣的module被加載時,udev daemon就會自動在/dev下創建my_device設備文件。class_create() ------------------------------------------------- linux-2.6.22/include/linux/device.h struct class *class_create(struct module *owner, const char *name)class_create - create a struct class structure@owner: pointer to the module that is to "own" this struct class@name: pointer to a string for the name of this class. 在/sys/class/下創建類目錄class_device_create() ------------------------------------------------- linux-2.6.22/include/linux/device.h struct class_device *class_device_create(struct class *cls,struct class_device *parent,dev_t devt,struct device *device,const char *fmt, ...)class_device_create - creates a class device and registers it with sysfs@cls: pointer to the struct class that this device should be registered to.@parent: pointer to the parent struct class_device of this new device, if any.@devt: the dev_t for the char device to be added.@device: a pointer to a struct device that is assiociated with this class device.@fmt: string for the class device's name

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的class_create和class_device_create的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。