diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /fs/sysfs/group.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'fs/sysfs/group.c')
-rw-r--r-- | fs/sysfs/group.c | 59 |
1 files changed, 56 insertions, 3 deletions
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c index 23c1e598792a..194414f8298c 100644 --- a/fs/sysfs/group.c +++ b/fs/sysfs/group.c | |||
@@ -101,9 +101,9 @@ int sysfs_create_group(struct kobject *kobj, | |||
101 | } | 101 | } |
102 | 102 | ||
103 | /** | 103 | /** |
104 | * sysfs_update_group - given a directory kobject, create an attribute group | 104 | * sysfs_update_group - given a directory kobject, update an attribute group |
105 | * @kobj: The kobject to create the group on | 105 | * @kobj: The kobject to update the group on |
106 | * @grp: The attribute group to create | 106 | * @grp: The attribute group to update |
107 | * | 107 | * |
108 | * This function updates an attribute group. Unlike | 108 | * This function updates an attribute group. Unlike |
109 | * sysfs_create_group(), it will explicitly not warn or error if any | 109 | * sysfs_create_group(), it will explicitly not warn or error if any |
@@ -148,6 +148,59 @@ void sysfs_remove_group(struct kobject * kobj, | |||
148 | sysfs_put(sd); | 148 | sysfs_put(sd); |
149 | } | 149 | } |
150 | 150 | ||
151 | /** | ||
152 | * sysfs_merge_group - merge files into a pre-existing attribute group. | ||
153 | * @kobj: The kobject containing the group. | ||
154 | * @grp: The files to create and the attribute group they belong to. | ||
155 | * | ||
156 | * This function returns an error if the group doesn't exist or any of the | ||
157 | * files already exist in that group, in which case none of the new files | ||
158 | * are created. | ||
159 | */ | ||
160 | int sysfs_merge_group(struct kobject *kobj, | ||
161 | const struct attribute_group *grp) | ||
162 | { | ||
163 | struct sysfs_dirent *dir_sd; | ||
164 | int error = 0; | ||
165 | struct attribute *const *attr; | ||
166 | int i; | ||
167 | |||
168 | dir_sd = sysfs_get_dirent(kobj->sd, NULL, grp->name); | ||
169 | if (!dir_sd) | ||
170 | return -ENOENT; | ||
171 | |||
172 | for ((i = 0, attr = grp->attrs); *attr && !error; (++i, ++attr)) | ||
173 | error = sysfs_add_file(dir_sd, *attr, SYSFS_KOBJ_ATTR); | ||
174 | if (error) { | ||
175 | while (--i >= 0) | ||
176 | sysfs_hash_and_remove(dir_sd, NULL, (*--attr)->name); | ||
177 | } | ||
178 | sysfs_put(dir_sd); | ||
179 | |||
180 | return error; | ||
181 | } | ||
182 | EXPORT_SYMBOL_GPL(sysfs_merge_group); | ||
183 | |||
184 | /** | ||
185 | * sysfs_unmerge_group - remove files from a pre-existing attribute group. | ||
186 | * @kobj: The kobject containing the group. | ||
187 | * @grp: The files to remove and the attribute group they belong to. | ||
188 | */ | ||
189 | void sysfs_unmerge_group(struct kobject *kobj, | ||
190 | const struct attribute_group *grp) | ||
191 | { | ||
192 | struct sysfs_dirent *dir_sd; | ||
193 | struct attribute *const *attr; | ||
194 | |||
195 | dir_sd = sysfs_get_dirent(kobj->sd, NULL, grp->name); | ||
196 | if (dir_sd) { | ||
197 | for (attr = grp->attrs; *attr; ++attr) | ||
198 | sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name); | ||
199 | sysfs_put(dir_sd); | ||
200 | } | ||
201 | } | ||
202 | EXPORT_SYMBOL_GPL(sysfs_unmerge_group); | ||
203 | |||
151 | 204 | ||
152 | EXPORT_SYMBOL_GPL(sysfs_create_group); | 205 | EXPORT_SYMBOL_GPL(sysfs_create_group); |
153 | EXPORT_SYMBOL_GPL(sysfs_update_group); | 206 | EXPORT_SYMBOL_GPL(sysfs_update_group); |