Sys节点创建
主要结构体
struct attribute {
const char *name; //属性文件的名字
struct module *owner; //属性文件的所有者
mode_t mode;
#ifdef CONFIG_DEBUG_LOCK_ALLOC
struct lock_class_key *key;
struct lock_class_key skey;
#endif
};
struct device_attribute { //设备属性文件
struct attribute attr; // 内置的attribute 结构体
ssize_t (*show)(struct device *dev, struct device_attribute *attr, char *buf);//属性文件的show方法(也就是读),可通过cat查看
ssize_t (*store)(struct device *dev, struct device_attribute *attr,const char *buf, size_t count);//属性文件的store方法(也就是写),可通过echo去写
};
可通过
static ssize_t direction_show(struct