All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jim Cromie <jim.cromie@gmail.com>
To: Linux kernel <linux-kernel@vger.kernel.org>
Subject: RFC-patch - make sysfs_create_group skip members with attr.mode == 0
Date: Thu, 17 Aug 2006 16:50:25 -0600	[thread overview]
Message-ID: <44E4F2B1.30408@gmail.com> (raw)


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



             reply	other threads:[~2006-08-17 22:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-17 22:50 Jim Cromie [this message]
2006-08-18  1:49 ` RFC-patch - make sysfs_create_group skip members with attr.mode == 0 Alexey Dobriyan
2006-08-18  4:25   ` Jim Cromie
     [not found]     ` <200608190019.01389.dtor@insightbb.com>
2006-08-19  5:21       ` Jim Cromie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44E4F2B1.30408@gmail.com \
    --to=jim.cromie@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.