Skip to content

Commit cdb4f26

Browse files
committed
kobject: kobj_type: remove default_attrs
Now that all in-kernel users of default_attrs for the kobj_type are gone and converted to properly use the default_groups pointer instead, it can be safely removed. There is one standard way to create sysfs files in a kobj_type, and not two like before, causing confusion as to which should be used. Cc: "Rafael J. Wysocki" <rafael@kernel.org> Link: https://lore.kernel.org/r/20220106133151.607703-1-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c31bc04 commit cdb4f26

File tree

3 files changed

+0
-46
lines changed

3 files changed

+0
-46
lines changed

fs/sysfs/file.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -703,19 +703,6 @@ int sysfs_change_owner(struct kobject *kobj, kuid_t kuid, kgid_t kgid)
703703

704704
ktype = get_ktype(kobj);
705705
if (ktype) {
706-
struct attribute **kattr;
707-
708-
/*
709-
* Change owner of the default attributes associated with the
710-
* ktype of @kobj.
711-
*/
712-
for (kattr = ktype->default_attrs; kattr && *kattr; kattr++) {
713-
error = sysfs_file_change_owner(kobj, (*kattr)->name,
714-
kuid, kgid);
715-
if (error)
716-
return error;
717-
}
718-
719706
/*
720707
* Change owner of the default groups associated with the
721708
* ktype of @kobj.

include/linux/kobject.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ extern char *kobject_get_path(struct kobject *kobj, gfp_t flag);
120120
struct kobj_type {
121121
void (*release)(struct kobject *kobj);
122122
const struct sysfs_ops *sysfs_ops;
123-
struct attribute **default_attrs; /* use default_groups instead */
124123
const struct attribute_group **default_groups;
125124
const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
126125
const void *(*namespace)(struct kobject *kobj);

lib/kobject.c

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -54,32 +54,6 @@ void kobject_get_ownership(struct kobject *kobj, kuid_t *uid, kgid_t *gid)
5454
kobj->ktype->get_ownership(kobj, uid, gid);
5555
}
5656

57-
/*
58-
* populate_dir - populate directory with attributes.
59-
* @kobj: object we're working on.
60-
*
61-
* Most subsystems have a set of default attributes that are associated
62-
* with an object that registers with them. This is a helper called during
63-
* object registration that loops through the default attributes of the
64-
* subsystem and creates attributes files for them in sysfs.
65-
*/
66-
static int populate_dir(struct kobject *kobj)
67-
{
68-
const struct kobj_type *t = get_ktype(kobj);
69-
struct attribute *attr;
70-
int error = 0;
71-
int i;
72-
73-
if (t && t->default_attrs) {
74-
for (i = 0; (attr = t->default_attrs[i]) != NULL; i++) {
75-
error = sysfs_create_file(kobj, attr);
76-
if (error)
77-
break;
78-
}
79-
}
80-
return error;
81-
}
82-
8357
static int create_dir(struct kobject *kobj)
8458
{
8559
const struct kobj_type *ktype = get_ktype(kobj);
@@ -90,12 +64,6 @@ static int create_dir(struct kobject *kobj)
9064
if (error)
9165
return error;
9266

93-
error = populate_dir(kobj);
94-
if (error) {
95-
sysfs_remove_dir(kobj);
96-
return error;
97-
}
98-
9967
if (ktype) {
10068
error = sysfs_create_groups(kobj, ktype->default_groups);
10169
if (error) {

0 commit comments

Comments
 (0)