From: Maneesh Soni <maneesh@in.ibm.com>
To: Al Viro <viro@parcelfarce.linux.theplanet.co.uk>,
Patrick Mochel <mochel@osdl.org>, Greg KH <gregkh@us.ibm.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Dipankar Sarma <dipankar@in.ibm.com>
Subject: [RFC 5/6] sysfs-attr_group.patch
Date: Mon, 6 Oct 2003 14:32:14 +0530 [thread overview]
Message-ID: <20031006090214.GJ4220@in.ibm.com> (raw)
In-Reply-To: <20031006090139.GI4220@in.ibm.com>
o This patch creates attribute group for the given kobject. Again here we don;t
create the sysfs directory but just links the struct attribute_group to the
kobject.
fs/sysfs/group.c | 46 ++++++++++++++++------------------------------
1 files changed, 16 insertions(+), 30 deletions(-)
diff -puN fs/sysfs/group.c~sysfs-attr_group fs/sysfs/group.c
--- linux-2.6.0-test6/fs/sysfs/group.c~sysfs-attr_group 2003-10-06 12:00:23.000000000 +0530
+++ linux-2.6.0-test6-maneesh/fs/sysfs/group.c 2003-10-06 12:00:35.000000000 +0530
@@ -24,40 +24,26 @@ static void remove_files(struct dentry *
sysfs_hash_and_remove(dir,(*attr)->name);
}
-static int create_files(struct dentry * dir,
- const struct attribute_group * grp)
-{
- struct attribute *const* attr;
- int error = 0;
-
- for (attr = grp->attrs; *attr && !error; attr++) {
- error = sysfs_add_file(dir,*attr);
- }
- if (error)
- remove_files(dir,grp);
- return error;
-}
-
-
int sysfs_create_group(struct kobject * kobj,
const struct attribute_group * grp)
{
- struct dentry * dir;
- int error;
+ struct kobject_attr_group * k_attr_group;
- if (grp->name) {
- error = sysfs_create_subdir(kobj,grp->name,&dir);
- if (error)
- return error;
- } else
- dir = kobj->dentry;
- dir = dget(dir);
- if ((error = create_files(dir,grp))) {
- if (grp->name)
- sysfs_remove_subdir(dir);
- dput(dir);
- }
- return error;
+ if (!kobj || !grp)
+ return -EINVAL;
+
+ k_attr_group = kmalloc(sizeof(k_attr_group), GFP_KERNEL);
+ if (!k_attr_group)
+ return -ENOMEM;
+ memset(k_attr_group, 0, sizeof(k_attr_group));
+ INIT_LIST_HEAD(&k_attr_group->list);
+ k_attr_group->attr_group = grp;
+
+ down_write(&kobj->k_rwsem);
+ list_add(&k_attr_group->list, &kobj->attr_group);
+ up_write(&kobj->k_rwsem);
+
+ return 0;
}
void sysfs_remove_group(struct kobject * kobj,
_
--
Maneesh Soni
Linux Technology Center,
IBM Software Lab, Bangalore, India
email: maneesh@in.ibm.com
Phone: 91-80-5044999 Fax: 91-80-5268553
T/L : 9243696
next prev parent reply other threads:[~2003-10-06 9:02 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-06 8:59 [RFC 0/6] Backing Store for sysfs Maneesh Soni
2003-10-06 9:00 ` [RFC 1/6] sysfs-kobject.patch Maneesh Soni
2003-10-06 9:00 ` [RFC 2/6] sysfs-mount.patch Maneesh Soni
2003-10-06 9:01 ` [RFC 3/6] sysfs-file.patch Maneesh Soni
2003-10-06 9:01 ` [RFC 4/6] sysfs-symlink.patch Maneesh Soni
2003-10-06 9:02 ` Maneesh Soni [this message]
2003-10-06 9:03 ` [RFC 6/6] sysfs-dir.patch Maneesh Soni
2003-10-06 13:43 ` [RFC 2/6] sysfs-mount.patch viro
2003-10-07 7:17 ` Maneesh Soni
2003-10-06 13:41 ` [RFC 1/6] sysfs-kobject.patch viro
2003-10-06 16:16 ` Greg KH
2003-10-06 17:41 ` Dipankar Sarma
2003-10-06 17:44 ` Greg KH
2003-10-06 16:08 ` [RFC 0/6] Backing Store for sysfs Greg KH
2003-10-06 17:31 ` Dipankar Sarma
2003-10-06 17:38 ` Greg KH
2003-10-06 18:01 ` Dipankar Sarma
2003-10-06 18:09 ` Greg KH
2003-10-06 18:31 ` Dipankar Sarma
2003-10-06 18:34 ` Greg KH
2003-10-07 9:08 ` Andreas Jellinghaus
2003-10-06 18:44 ` Patrick Mochel
2003-10-06 19:27 ` Dipankar Sarma
2003-10-06 19:30 ` viro
2003-10-06 20:01 ` Dipankar Sarma
2003-10-06 20:34 ` viro
2003-10-07 4:47 ` Maneesh Soni
2003-10-06 19:33 ` Patrick Mochel
2003-10-06 20:26 ` Dipankar Sarma
2003-10-06 20:29 ` Patrick Mochel
2003-10-07 4:31 ` Maneesh Soni
2003-10-07 5:25 ` Nick Piggin
2003-10-07 7:17 ` Maneesh Soni
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=20031006090214.GJ4220@in.ibm.com \
--to=maneesh@in.ibm.com \
--cc=dipankar@in.ibm.com \
--cc=gregkh@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mochel@osdl.org \
--cc=viro@parcelfarce.linux.theplanet.co.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox