~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to fs/sysfs/group.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
        int i;
24
24
 
25
25
        for (i = 0, attr = grp->attrs; *attr; i++, attr++)
26
 
                sysfs_hash_and_remove(dir_sd, (*attr)->name);
 
26
                sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name);
27
27
}
28
28
 
29
29
static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
39
39
                 * visibility.  Do this by first removing then
40
40
                 * re-adding (if required) the file */
41
41
                if (update)
42
 
                        sysfs_hash_and_remove(dir_sd, (*attr)->name);
 
42
                        sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name);
43
43
                if (grp->is_visible) {
44
44
                        mode = grp->is_visible(kobj, *attr, i);
45
45
                        if (!mode)
132
132
        struct sysfs_dirent *sd;
133
133
 
134
134
        if (grp->name) {
135
 
                sd = sysfs_get_dirent(dir_sd, grp->name);
 
135
                sd = sysfs_get_dirent(dir_sd, NULL, grp->name);
136
136
                if (!sd) {
137
137
                        WARN(!sd, KERN_WARNING "sysfs group %p not found for "
138
138
                                "kobject '%s'\n", grp, kobject_name(kobj));
148
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
205
EXPORT_SYMBOL_GPL(sysfs_create_group);
153
206
EXPORT_SYMBOL_GPL(sysfs_update_group);