RFC-patch - make sysfs_create_group skip members with attr.mode ==0
From: Jim Cromie
Date: Thu Aug 17 2006 - 18:47:48 EST
Currently, code in hwmon/*.c uses sysfs_create_group less than it could.
A contributing reason is that many individual attr-files are created
conditionally,
depending upon both underlying hardware, driver configuration, etc.
With proposed patch, the members of a group are conditionally created,
based upon the mode of the underlying attribute. mode == 0 suppresses
attr-file
creation, allowing run-time tweaks of compile-time defined groups.
The driver defining the group need only disable the unwanted members
before calling sysfs_create_group() (theyre 'enabled' by initialization
macros,
since thats the most useful default)
Specifically
- only group members are created conditionally,
theres no effect on calls to device_create_file.
- only mode == 0 disables member creation,
common values like S_IWUSR | S_IRUGO have un-altered behavior.
Signed-off-by: Jim Cromie <jim.cromie@xxxxxxxxx>
$ diffstat diff.sys-grp-conditional-members
group.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletion(-)
diff -ruNp -X dontdiff -X exclude-diffs try1/fs/sysfs/group.c try2/fs/sysfs/group.c
--- try1/fs/sysfs/group.c 2006-06-17 19:49:35.000000000 -0600
+++ try2/fs/sysfs/group.c 2006-08-17 10:06:26.000000000 -0600
@@ -32,7 +33,8 @@ static int create_files(struct dentry *
int error = 0;
for (attr = grp->attrs; *attr && !error; attr++) {
- error = sysfs_add_file(dir, *attr, SYSFS_KOBJ_ATTR);
+ if ((*attr)->mode)
+ error = sysfs_add_file(dir, *attr, SYSFS_KOBJ_ATTR);
}
if (error)
remove_files(dir,grp);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/