|
設(shè)備類struct class是一個(gè)設(shè)備的高級(jí)視圖,它抽象出低級(jí)的實(shí)現(xiàn)細(xì)節(jié)。例如,驅(qū)動(dòng)可以見到一個(gè)SCSI磁盤或者一個(gè)ATA磁盤,在類的級(jí)別,他們都是磁盤,類允許用戶空間基于它們作什么來使用設(shè)備,而不是它們?nèi)绾伪贿B接或者它們?nèi)绾喂ぷ鳌?br>struct class{ const char *name; //類名稱 struct module *owner; //對(duì)應(yīng)模塊 struct subsystem subsys; //對(duì)應(yīng)的subsystem; struct list_head children; //class_device鏈表 struct list_head interfaces; //class_interface鏈表 struct semaphore sem; //用于同步的信號(hào)鎖 struct class_attribute *class_attrs; //類屬性 int (*uevent)(struct class_device *dev,char **envp,int num_envp, char *buffer,int buffer_size); //事件 void (*release)(struct class_device *dev); //釋放類設(shè)備 void (*class_release)(struct class *class); //釋放類 }
調(diào)用函數(shù): int class_register(struct class *cls); 用于注冊(cè) 用于注銷
struct kobject kobj; //內(nèi)嵌的kobject,用于計(jì)數(shù) struct class *class; //所屬的類; dev_t devt; //dev_t設(shè)備號(hào) struct class_device_attribute *devt_attr; struct class_device_attribute uevent_attr; struct device *dev; //如果存在,創(chuàng)建到/sys/devices相應(yīng)入口的符號(hào)鏈接 void *class_data; //私有數(shù)據(jù) struct class_device *parent; //父設(shè)備 void (*release)(struct class_device *dev); //釋放對(duì)應(yīng)類實(shí)際設(shè)備的方法 int(*uevent)(struct class_device *dev,char **envp, char class_id[BUS_IO_SIZE]; //類標(biāo)志 調(diào)用函數(shù): int class_device_register(struct class_device *class_dev); 用于注冊(cè) 用于注銷
相關(guān)結(jié)構(gòu)體 struct class_interface 調(diào)用函數(shù): 用于注冊(cè) |
|
|