One approach to handling case where all attributes of a subdir are added independently via sysfs_add_file. Usecase - iio_chan_spec device registration sometimes creates all the elements of a subdirectory (e.g. scan_elements) rather than adding them to an existing subdirectory. Right now the core provides 'dummy' groups for this purpose, but that's uggly. Signed-off-by: Jonathan Cameron <jic23@xxxxxxxxx> --- fs/sysfs/group.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c index 65d6d78..25fe548 100644 --- a/fs/sysfs/group.c +++ b/fs/sysfs/group.c @@ -22,6 +22,8 @@ static void remove_files(struct sysfs_dirent *dir_sd, struct kobject *kobj, struct attribute *const* attr; int i; + if (grp->attrs == NULL) + return; for (i = 0, attr = grp->attrs; *attr; i++, attr++) sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name); } @@ -32,6 +34,8 @@ static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj, struct attribute *const* attr; int error = 0, i; + if (grp->attrs == NULL) + return 0; for (i = 0, attr = grp->attrs; *attr && !error; i++, attr++) { mode_t mode = 0; -- 1.7.3.4 -- To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html