static ssize_t display_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
//unsigned long val;
//if (kstrtoul(buf, 10, &val))
// return -EINVAL;
pr_err("displayd write debug buf\n");
return count;
}
static ssize_t display_show(struct device *dev, struct device_attribute *attr, char *buf)
{
pr_err("displayd read debug buf\n");
return 0;
}
static DEVICE_ATTR(displayd, 0660, display_show, display_store);
static int init_sys_node()
{
int ret;
struct kobject *kobj = kobject_create_and_add("displayd_debug", NULL);
if(kobj == NULL){
return -ENOMEM;
}
ret = sysfs_create_file(kobj, &dev_attr_displayd.attr);
if(ret < 0) {
return -1;
}
return ret;
}
调用init_sys_node 函数即可创建文件节点:/sys/displayd_debug/displayd
next:sysfs_create_group批量创建sys文件节点.
|