Skip to content

Commit 5aa2a02

Browse files
t-8chVlastimil Babka (SUSE)
authored andcommitted
mm/slab: create sysfs attribute through default_groups
The driver core can automatically create custom type attributes. This makes the code and error-handling shorter. Signed-off-by: Thomas Weißschuh <[email protected]> Reviewed-by: Harry Yoo <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Vlastimil Babka (SUSE) <[email protected]>
1 parent 6de23f8 commit 5aa2a02

1 file changed

Lines changed: 2 additions & 10 deletions

File tree

mm/slub.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9317,9 +9317,7 @@ static struct attribute *slab_attrs[] = {
93179317
NULL
93189318
};
93199319

9320-
static const struct attribute_group slab_attr_group = {
9321-
.attrs = slab_attrs,
9322-
};
9320+
ATTRIBUTE_GROUPS(slab);
93239321

93249322
static ssize_t slab_attr_show(struct kobject *kobj,
93259323
struct attribute *attr,
@@ -9366,6 +9364,7 @@ static const struct sysfs_ops slab_sysfs_ops = {
93669364
static const struct kobj_type slab_ktype = {
93679365
.sysfs_ops = &slab_sysfs_ops,
93689366
.release = kmem_cache_release,
9367+
.default_groups = slab_groups,
93699368
};
93709369

93719370
static struct kset *slab_kset;
@@ -9453,10 +9452,6 @@ static int sysfs_slab_add(struct kmem_cache *s)
94539452
if (err)
94549453
goto out;
94559454

9456-
err = sysfs_create_group(&s->kobj, &slab_attr_group);
9457-
if (err)
9458-
goto out_del_kobj;
9459-
94609455
if (!unmergeable) {
94619456
/* Setup first alias */
94629457
sysfs_slab_alias(s, s->name);
@@ -9465,9 +9460,6 @@ static int sysfs_slab_add(struct kmem_cache *s)
94659460
if (!unmergeable)
94669461
kfree(name);
94679462
return err;
9468-
out_del_kobj:
9469-
kobject_del(&s->kobj);
9470-
goto out;
94719463
}
94729464

94739465
void sysfs_slab_unlink(struct kmem_cache *s)

0 commit comments

Comments
 (0)