[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <55304d1f13f19ca4fc860eb7fe2ffbd8fc038e02.1520292208.git.tgnottingham@gmail.com>
Date: Mon, 5 Mar 2018 16:04:34 -0800
From: Tyson Nottingham <tgnottingham@...il.com>
To: linux-ext4@...r.kernel.org
Cc: tytso@....edu, adilger.kernel@...ger.ca, sirmy15@...il.com,
Tyson Nottingham <tgnottingham@...il.com>
Subject: [PATCH 3/3] ext4: simplify kobject usage
Replace kset with generic kobject provided by kobject_create_and_add(),
since the latter is sufficient.
Signed-off-by: Tyson Nottingham <tgnottingham@...il.com>
---
As far as I can tell, we're not using any kset-specific functionality
here, so replace it with the simpler generic kobject.
---
fs/ext4/sysfs.c | 45 ++++++++++++---------------------------------
1 file changed, 12 insertions(+), 33 deletions(-)
diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
index 3b6b3ab..9ebd26c 100644
--- a/fs/ext4/sysfs.c
+++ b/fs/ext4/sysfs.c
@@ -325,13 +325,6 @@ static void ext4_sb_release(struct kobject *kobj)
complete(&sbi->s_kobj_unregister);
}
-static void ext4_kset_release(struct kobject *kobj)
-{
- struct kset *kset = container_of(kobj, struct kset, kobj);
-
- kfree(kset);
-}
-
static const struct sysfs_ops ext4_attr_ops = {
.show = ext4_attr_show,
.store = ext4_attr_store,
@@ -343,19 +336,14 @@ static struct kobj_type ext4_sb_ktype = {
.release = ext4_sb_release,
};
-static struct kobj_type ext4_ktype = {
- .sysfs_ops = &ext4_attr_ops,
- .release = ext4_kset_release,
-};
-
-static struct kset *ext4_kset;
-
static struct kobj_type ext4_feat_ktype = {
.default_attrs = ext4_feat_attrs,
.sysfs_ops = &ext4_attr_ops,
.release = (void (*)(struct kobject *))kfree,
};
+static struct kobject *ext4_root;
+
static struct kobject *ext4_feat;
#define PROC_FILE_SHOW_DEFN(name) \
@@ -393,9 +381,8 @@ int ext4_register_sysfs(struct super_block *sb)
const struct ext4_proc_files *p;
int err;
- sbi->s_kobj.kset = ext4_kset;
init_completion(&sbi->s_kobj_unregister);
- err = kobject_init_and_add(&sbi->s_kobj, &ext4_sb_ktype, NULL,
+ err = kobject_init_and_add(&sbi->s_kobj, &ext4_sb_ktype, ext4_root,
"%s", sb->s_id);
if (err) {
kobject_put(&sbi->s_kobj);
@@ -431,26 +418,18 @@ int __init ext4_init_sysfs(void)
{
int ret;
- ext4_kset = kzalloc(sizeof(*ext4_kset), GFP_KERNEL);
- if (!ext4_kset)
+ ext4_root = kobject_create_and_add("ext4", fs_kobj);
+ if (!ext4_root)
return -ENOMEM;
- kobject_set_name(&ext4_kset->kobj, "ext4");
- ext4_kset->kobj.parent = fs_kobj;
- ext4_kset->kobj.ktype = &ext4_ktype;
- ret = kset_register(ext4_kset);
- if (ret)
- goto kset_err;
-
ext4_feat = kzalloc(sizeof(*ext4_feat), GFP_KERNEL);
if (!ext4_feat) {
ret = -ENOMEM;
- goto kset_err;
+ goto root_err;
}
- ext4_feat->kset = ext4_kset;
ret = kobject_init_and_add(ext4_feat, &ext4_feat_ktype,
- NULL, "features");
+ ext4_root, "features");
if (ret)
goto feat_err;
@@ -460,9 +439,9 @@ int __init ext4_init_sysfs(void)
feat_err:
kobject_put(ext4_feat);
ext4_feat = NULL;
-kset_err:
- kset_unregister(ext4_kset);
- ext4_kset = NULL;
+root_err:
+ kobject_put(ext4_root);
+ ext4_root = NULL;
return ret;
}
@@ -470,8 +449,8 @@ void ext4_exit_sysfs(void)
{
kobject_put(ext4_feat);
ext4_feat = NULL;
- kset_unregister(ext4_kset);
- ext4_kset = NULL;
+ kobject_put(ext4_root);
+ ext4_root = NULL;
remove_proc_entry(proc_dirname, NULL);
ext4_proc_root = NULL;
}
--
2.7.4
Powered by blists - more mailing lists