lkml.org 
[lkml]   [2006]   [Aug]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRFC-patch - make sysfs_create_group skip members with attr.mode == 0

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@gmail.com>

$ 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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-08-18 00:53    [W:0.080 / U:0.244 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site