static int internal_create_group(struct kobject *kobj, int update, const struct attribute_group *grp) { struct sysfs_dirent *sd; int error; BUG_ON(!kobj || (!update && !kobj->sd)); /* Updates may happen before the object has been instantiated */ if (unlikely(update && !kobj->sd)) return -EINVAL; if (grp->name) { error = sysfs_create_subdir(kobj, grp->name, &sd); if (error) return error; } else sd = kobj->sd; sysfs_get(sd); error = create_files(sd, kobj, grp, update); if (error) { if (grp->name) sysfs_remove_subdir(sd); } sysfs_put(sd); return error; }
static int internal_create_group(struct kobject *kobj, int update, const struct attribute_group *grp) { struct sysfs_dirent *sd; int error; BUG_ON(!kobj || (!update && !kobj->sd)); /* Updates may happen before the object has been instantiated */ if (unlikely(update && !kobj->sd)) return -EINVAL; if (!grp->attrs && !grp->bin_attrs) { WARN(1, "sysfs: (bin_)attrs not set by subsystem for group: %s/%s\n", kobj->name, grp->name ? "" : grp->name); return -EINVAL; } if (grp->name) { error = sysfs_create_subdir(kobj, grp->name, &sd); if (error) return error; } else sd = kobj->sd; sysfs_get(sd); error = create_files(sd, kobj, grp, update); if (error) { if (grp->name) sysfs_remove_subdir(sd); } sysfs_put(sd); return error; }
void sysfs_remove_group(struct kobject * kobj, const struct attribute_group * grp) { struct dentry * dir; if (grp->name) dir = lookup_one_len(grp->name, kobj->dentry, strlen(grp->name)); else dir = dget(kobj->dentry); remove_files(dir,grp); if (grp->name) sysfs_remove_subdir(dir); /* release the ref. taken in this routine */ dput(dir); }
void sysfs_remove_group(struct kobject * kobj, const struct attribute_group * grp) { struct sysfs_dirent *dir_sd = kobj->sd; struct sysfs_dirent *sd; if (grp->name) { sd = sysfs_get_dirent(dir_sd, grp->name); BUG_ON(!sd); } else sd = sysfs_get(dir_sd); remove_files(sd, grp); if (grp->name) sysfs_remove_subdir(sd); sysfs_put(sd); }
void sysfs_remove_group(struct kobject * kobj, const struct attribute_group * grp) { struct sysfs_dirent *dir_sd = kobj->sd; struct sysfs_dirent *sd; if (grp->name) { sd = sysfs_get_dirent(dir_sd, NULL, grp->name); if (!sd) { WARN(!sd, KERN_WARNING "sysfs group %p not found for " "kobject '%s'\n", grp, kobject_name(kobj)); return; } } else sd = sysfs_get(dir_sd); remove_files(sd, kobj, grp); if (grp->name) sysfs_remove_subdir(sd); sysfs_put(sd); }
/**ltl * 功能: 创建一个文件组 * 参数: * 返回值: * 说明: 在/sys下创建一下目录,并在此目录新建文件 */ int sysfs_create_group(struct kobject * kobj, const struct attribute_group * grp) { struct dentry * dir; int error; BUG_ON(!kobj || !kobj->dentry); if (grp->name) { /* 创建目录 */ error = sysfs_create_subdir(kobj,grp->name,&dir); if (error) return error; } else dir = kobj->dentry; dir = dget(dir); if ((error = create_files(dir,grp))) { /* 创建文件 */ if (grp->name) sysfs_remove_subdir(dir); } dput(dir); return error; }
int sysfs_create_group(struct kobject * kobj, const struct attribute_group * grp) { struct sysfs_dirent *sd; int error; BUG_ON(!kobj || !kobj->sd); if (grp->name) { error = sysfs_create_subdir(kobj, grp->name, &sd); if (error) return error; } else sd = kobj->sd; sysfs_get(sd); error = create_files(sd, grp); if (error) { if (grp->name) sysfs_remove_subdir(sd); } sysfs_put(sd); return error; }