aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs/dir.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-07-18 03:38:11 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-07-18 18:49:50 -0400
commit967e35dcc9ac194b4a6fad69a5a51f93d69bb0d1 (patch)
tree218c6fc093ec110ee6f4c5d7f0aae448e5f82173 /fs/sysfs/dir.c
parenta1da4dfe35bc36c3bc9716d995c85b7983c38a76 (diff)
sysfs: cosmetic clean up on node creation failure paths
Node addition failure is detected by testing return value of sysfs_addfm_finish() which returns the number of added and removed nodes. As the function is called as the last step of addition right on top of error handling block, the if blocks looked like the following. if (sysfs_addrm_finish(&acxt)) success handling, usually return; /* fall through to error handling */ This is the opposite of usual convention in sysfs and makes the code difficult to understand. This patch inverts the test and makes those blocks look more like others. Signed-off-by: Tejun Heo <htejun@gmail.com> Cc: Gabriel C <nix.or.die@googlemail.com> Cc: Miles Lane <miles.lane@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/sysfs/dir.c')
-rw-r--r--fs/sysfs/dir.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 2e6775a836f2..048e6054c2fd 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -699,17 +699,19 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
699 699
700 /* link in */ 700 /* link in */
701 sysfs_addrm_start(&acxt, parent_sd); 701 sysfs_addrm_start(&acxt, parent_sd);
702
702 if (!sysfs_find_dirent(parent_sd, name)) { 703 if (!sysfs_find_dirent(parent_sd, name)) {
703 sysfs_add_one(&acxt, sd); 704 sysfs_add_one(&acxt, sd);
704 sysfs_link_sibling(sd); 705 sysfs_link_sibling(sd);
705 } 706 }
706 if (sysfs_addrm_finish(&acxt)) { 707
707 *p_sd = sd; 708 if (!sysfs_addrm_finish(&acxt)) {
708 return 0; 709 sysfs_put(sd);
710 return -EEXIST;
709 } 711 }
710 712
711 sysfs_put(sd); 713 *p_sd = sd;
712 return -EEXIST; 714 return 0;
713} 715}
714 716
715int sysfs_create_subdir(struct kobject *kobj, const char *name, 717int sysfs_create_subdir(struct kobject *kobj, const char *name,