[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / fs / sysfs / group.c
blobf11ac5ea7021c4b325211b2f7e58b6e29fbbc60c
1 /*
2 * fs/sysfs/group.c - Operations for adding/removing multiple files at once.
4 * Copyright (c) 2003 Patrick Mochel
5 * Copyright (c) 2003 Open Source Development Lab
7 * This file is released undert the GPL v2.
9 */
11 #include <linux/kobject.h>
12 #include <linux/module.h>
13 #include <linux/dcache.h>
14 #include <linux/err.h>
15 #include "sysfs.h"
18 static void remove_files(struct dentry * dir,
19 const struct attribute_group * grp)
21 struct attribute *const* attr;
23 for (attr = grp->attrs; *attr; attr++)
24 sysfs_hash_and_remove(dir,(*attr)->name);
27 static int create_files(struct dentry * dir,
28 const struct attribute_group * grp)
30 struct attribute *const* attr;
31 int error = 0;
33 for (attr = grp->attrs; *attr && !error; attr++) {
34 error = sysfs_add_file(dir, *attr, SYSFS_KOBJ_ATTR);
36 if (error)
37 remove_files(dir,grp);
38 return error;
42 int sysfs_create_group(struct kobject * kobj,
43 const struct attribute_group * grp)
45 struct dentry * dir;
46 int error;
48 BUG_ON(!kobj || !kobj->dentry);
50 if (grp->name) {
51 error = sysfs_create_subdir(kobj,grp->name,&dir);
52 if (error)
53 return error;
54 } else
55 dir = kobj->dentry;
56 dir = dget(dir);
57 if ((error = create_files(dir,grp))) {
58 if (grp->name)
59 sysfs_remove_subdir(dir);
61 dput(dir);
62 return error;
65 void sysfs_remove_group(struct kobject * kobj,
66 const struct attribute_group * grp)
68 struct dentry * dir;
70 if (grp->name)
71 dir = sysfs_get_dentry(kobj->dentry,grp->name);
72 else
73 dir = dget(kobj->dentry);
75 remove_files(dir,grp);
76 if (grp->name)
77 sysfs_remove_subdir(dir);
78 /* release the ref. taken in this routine */
79 dput(dir);
83 EXPORT_SYMBOL_GPL(sysfs_create_group);
84 EXPORT_SYMBOL_GPL(sysfs_remove_group);