Merge btrfs_sysfs_add_fsid() and btrfs_sysfs_add_devices_kobj() functions
as these two are small and they are called one after the other.
Signed-off-by: Anand Jain <anand.jain@xxxxxxxxxx>
---
v2: nothing in specific to this patch actually, but the changes
before this patch makes v1 apply fail. So fixed in v2.
fs/btrfs/disk-io.c | 7 -------
fs/btrfs/sysfs.c | 21 +++++++++------------
fs/btrfs/sysfs.h | 1 -
3 files changed, 9 insertions(+), 20 deletions(-)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index c4cebc44f683..d93eeb048193 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3090,13 +3090,6 @@ int __cold open_ctree(struct super_block *sb,
goto fail_block_groups;
}
- ret = btrfs_sysfs_add_devices_kobj(fs_devices);
- if (ret) {
- btrfs_err(fs_info, "failed to init sysfs device interface: %d",
- ret);
- goto fail_fsdev_sysfs;
- }
-
ret = btrfs_sysfs_add_mounted(fs_info);
if (ret) {
btrfs_err(fs_info, "failed to init sysfs interface: %d", ret);
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index e8dfa2561909..61b4c04f5a1c 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -997,18 +997,6 @@ int btrfs_sysfs_remove_devices_attr(struct btrfs_fs_devices *fs_devices,
return 0;
}
-int btrfs_sysfs_add_devices_kobj(struct btrfs_fs_devices *fs_devs)
-{
- if (!fs_devs->devices_kobj)
- fs_devs->devices_kobj = kobject_create_and_add("devices",
- &fs_devs->fsid_kobj);
-
- if (!fs_devs->devices_kobj)
- return -ENOMEM;
-
- return 0;
-}
-
int btrfs_sysfs_add_devices_attr(struct btrfs_fs_devices *fs_devices,
struct btrfs_device *one_device)
{
@@ -1085,6 +1073,15 @@ int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs)
return error;
}
+ fs_devs->devices_kobj = kobject_create_and_add("devices",
+ &fs_devs->fsid_kobj);
+ if (!fs_devs->devices_kobj) {
+ btrfs_err(fs_devs->fs_info,
+ "failed to init sysfs device interface");
+ kobject_put(&fs_devs->fsid_kobj);
+ return -ENOMEM;
+ }
+
return 0;
}
diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h
index f7ddcbf4a40d..9d97b3c8db4e 100644
--- a/fs/btrfs/sysfs.h
+++ b/fs/btrfs/sysfs.h
@@ -19,7 +19,6 @@ int btrfs_sysfs_add_devices_attr(struct btrfs_fs_devices *fs_devices,
int btrfs_sysfs_remove_devices_attr(struct btrfs_fs_devices *fs_devices,
struct btrfs_device *one_device);
int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs);
-int btrfs_sysfs_add_devices_kobj(struct btrfs_fs_devices *fs_devs);
void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs);
void btrfs_sysfs_update_sprout_fsid(struct btrfs_fs_devices *fs_devices,
const u8 *fsid);
--
1.8.3.1