public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* RFC-patch - make sysfs_create_group skip members with attr.mode == 0
@ 2006-08-17 22:50 Jim Cromie
  2006-08-18  1:49 ` Alexey Dobriyan
  0 siblings, 1 reply; 4+ messages in thread
From: Jim Cromie @ 2006-08-17 22:50 UTC (permalink / raw)
  To: Linux kernel


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);



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-08-19  5:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-17 22:50 RFC-patch - make sysfs_create_group skip members with attr.mode == 0 Jim Cromie
2006-08-18  1:49 ` Alexey Dobriyan
2006-08-18  4:25   ` Jim Cromie
     [not found]     ` <200608190019.01389.dtor@insightbb.com>
2006-08-19  5:21       ` Jim Cromie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox