[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1313576222-27743-3-git-send-email-jic23@cam.ac.uk>
Date: Wed, 17 Aug 2011 11:17:02 +0100
From: Jonathan Cameron <jic23@....ac.uk>
To: linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: greg@...ah.com, Jonathan Cameron <jic23@....ac.uk>
Subject: [PATCH 2/2] sysfs: Allow for groups with no attributes - grp->attrs = NULL.
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@....ac.uk>
---
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-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists