diff options
Diffstat (limited to 'fs/sysfs/file.c')
-rw-r--r-- | fs/sysfs/file.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index d0deed3e60b5..69bacf1db596 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
@@ -416,6 +416,7 @@ int sysfs_add_file(struct sysfs_dirent *dir_sd, const struct attribute *attr, | |||
416 | int type) | 416 | int type) |
417 | { | 417 | { |
418 | umode_t mode = (attr->mode & S_IALLUGO) | S_IFREG; | 418 | umode_t mode = (attr->mode & S_IALLUGO) | S_IFREG; |
419 | struct sysfs_addrm_cxt acxt; | ||
419 | struct sysfs_dirent *sd; | 420 | struct sysfs_dirent *sd; |
420 | 421 | ||
421 | sd = sysfs_new_dirent(attr->name, mode, type); | 422 | sd = sysfs_new_dirent(attr->name, mode, type); |
@@ -423,20 +424,18 @@ int sysfs_add_file(struct sysfs_dirent *dir_sd, const struct attribute *attr, | |||
423 | return -ENOMEM; | 424 | return -ENOMEM; |
424 | sd->s_elem.attr.attr = (void *)attr; | 425 | sd->s_elem.attr.attr = (void *)attr; |
425 | 426 | ||
426 | mutex_lock(&sysfs_mutex); | 427 | sysfs_addrm_start(&acxt, dir_sd); |
427 | 428 | ||
428 | if (!sysfs_find_dirent(dir_sd, attr->name)) { | 429 | if (!sysfs_find_dirent(dir_sd, attr->name)) { |
429 | sysfs_attach_dirent(sd, dir_sd, NULL); | 430 | sysfs_add_one(&acxt, sd); |
430 | sd = NULL; | 431 | sysfs_link_sibling(sd); |
431 | } | 432 | } |
432 | 433 | ||
433 | mutex_unlock(&sysfs_mutex); | 434 | if (sysfs_addrm_finish(&acxt)) |
435 | return 0; | ||
434 | 436 | ||
435 | if (sd) { | 437 | sysfs_put(sd); |
436 | sysfs_put(sd); | 438 | return -EEXIST; |
437 | return -EEXIST; | ||
438 | } | ||
439 | return 0; | ||
440 | } | 439 | } |
441 | 440 | ||
442 | 441 | ||