调用函数:
int class_register(struct class *cls);
用于注册
void class_unregister(struct class *cls);
用于注销
class可以看成是一个容器,容器总包含了很多的class_device,每个都对应着一个具体的逻辑设备,并通过成员变量dev关联一个物理设备。定义为:
struct class_device
{
struct list_head node;
struct kobject kobj; //内嵌的kobject,用于计数
struct class *class; //所属的类;
dev_t devt; //dev_t设备号
struct class_device_attribute *devt_attr;
struct class_device_attribute uevent_attr;
struct device *dev; //如果存在,创建到/sys/devices相应入口的符号链接
void *class_data; //私有数据
struct class_device *parent; //父设备
void (*release)(struct class_device *dev); //释放对应类实际设备的方法
int(*uevent)(struct class_device *dev,char **envp,
int num_envp,char *buffer,int buffer_size);
char class_id[BUS_IO_SIZE]; //类标志
}
调用函数:
int class_device_register(struct class_device *class_dev);
用于注册
void class_device_unregister(struct class_device *class_dev);
用于注销
相关结构体
struct class_interface
{
struct list_head node;
struct class *class; //所属的class
int (*add)(struct class_device *,struct class_interface *); //设备加入时触发
void (*remove)(struct class_device *,struct class_interface *);//设备移出时触发
}
调用函数:
int class_interface_register(struct class_interface *class_intf);
用于注册
void class_interface_unregister(struct class_interface *class_intf);
用于注销
联系客服