Pull driver core updates from Greg KH: "Here are two small driver core changes for 5.18-rc2. They are the final bits in the removal of the default_attrs field in struct kobj_type. I had to wait until after 5.18-rc1 for all of the changes to do this came in through different development trees, and then one new user snuck in. So this series has two changes: - removal of the default_attrs field in the powerpc/pseries/vas code. The change has been acked by the PPC maintainers to come through this tree - removal of default_attrs from struct kobj_type now that all in-kernel users are removed. This cleans up the kobject code a little bit and removes some duplicated functionality that confused people (now there is only one way to do default groups) Both of these have been in linux-next for all of this week with no reported problems" * tag 'driver-core-5.18-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: kobject: kobj_type: remove default_attrs powerpc/pseries/vas: use default_groups in kobj_type
Unified · Split
| @@ -99,6 +99,7 @@ static struct attribute *vas_def_capab_attrs[] = { · 98 unmodified lines | |||
| 99 | &nr_used_credits_attribute.attr, | 99 | &nr_used_credits_attribute.attr, |
| 100 | NULL, | 100 | NULL, |
| 101 | }; | 101 | }; |
| 102 | ATTRIBUTE_GROUPS(vas_def_capab); | ||
| 102 | 103 | ||
| 103 | static struct attribute *vas_qos_capab_attrs[] = { | 104 | static struct attribute *vas_qos_capab_attrs[] = { |
| 104 | &nr_total_credits_attribute.attr, | 105 | &nr_total_credits_attribute.attr, |
| @@ -106,6 +107,7 @@ static struct attribute *vas_qos_capab_attrs[] = { · 1 unmodified line | |||
| 106 | &update_total_credits_attribute.attr, | 107 | &update_total_credits_attribute.attr, |
| 107 | NULL, | 108 | NULL, |
| 108 | }; | 109 | }; |
| 110 | ATTRIBUTE_GROUPS(vas_qos_capab); | ||
| 109 | 111 | ||
| 110 | static ssize_t vas_type_show(struct kobject *kobj, struct attribute *attr, | 112 | static ssize_t vas_type_show(struct kobject *kobj, struct attribute *attr, |
| 111 | char *buf) | 113 | char *buf) |
| @@ -154,13 +156,13 @@ static const struct sysfs_ops vas_sysfs_ops = { · 42 unmodified lines | |||
| 154 | static struct kobj_type vas_def_attr_type = { | 156 | static struct kobj_type vas_def_attr_type = { |
| 155 | .release = vas_type_release, | 157 | .release = vas_type_release, |
| 156 | .sysfs_ops = &vas_sysfs_ops, | 158 | .sysfs_ops = &vas_sysfs_ops, |
| 157 | .default_attrs = vas_def_capab_attrs, | 159 | .default_groups = vas_def_capab_groups, |
| 158 | }; | 160 | }; |
| 159 | 161 | ||
| 160 | static struct kobj_type vas_qos_attr_type = { | 162 | static struct kobj_type vas_qos_attr_type = { |
| 161 | .release = vas_type_release, | 163 | .release = vas_type_release, |
| 162 | .sysfs_ops = &vas_sysfs_ops, | 164 | .sysfs_ops = &vas_sysfs_ops, |
| 163 | .default_attrs = vas_qos_capab_attrs, | 165 | .default_groups = vas_qos_capab_groups, |
| 164 | }; | 166 | }; |
| 165 | 167 | ||
| 166 | static char *vas_caps_kobj_name(struct vas_caps_entry *centry, | 168 | static char *vas_caps_kobj_name(struct vas_caps_entry *centry, |
| @@ -703,19 +703,6 @@ int sysfs_change_owner(struct kobject *kobj, kuid_t kuid, kgid_t kgid) · 702 unmodified lines | |||
| 703 | 703 | ||
| 704 | ktype = get_ktype(kobj); | 704 | ktype = get_ktype(kobj); |
| 705 | if (ktype) { | 705 | 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 | |||
| 719 | /* | 706 | /* |
| 720 | * Change owner of the default groups associated with the | 707 | * Change owner of the default groups associated with the |
| 721 | * ktype of @kobj. | 708 | * ktype of @kobj. |
| @@ -120,7 +120,6 @@ extern char *kobject_get_path(struct kobject *kobj, gfp_t flag); · 119 unmodified lines | |||
| 120 | struct kobj_type { | 120 | struct kobj_type { |
| 121 | void (*release)(struct kobject *kobj); | 121 | void (*release)(struct kobject *kobj); |
| 122 | const struct sysfs_ops *sysfs_ops; | 122 | const struct sysfs_ops *sysfs_ops; |
| 123 | struct attribute **default_attrs; /* use default_groups instead */ | ||
| 124 | const struct attribute_group **default_groups; | 123 | const struct attribute_group **default_groups; |
| 125 | const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj); | 124 | const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj); |
| 126 | const void *(*namespace)(struct kobject *kobj); | 125 | const void *(*namespace)(struct kobject *kobj); |
| @@ -54,32 +54,6 @@ void kobject_get_ownership(struct kobject *kobj, kuid_t *uid, kgid_t *gid) · 53 unmodified lines | |||
| 54 | kobj->ktype->get_ownership(kobj, uid, gid); | 54 | kobj->ktype->get_ownership(kobj, uid, gid); |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 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 | |||
| 83 | static int create_dir(struct kobject *kobj) | 57 | static int create_dir(struct kobject *kobj) |
| 84 | { | 58 | { |
| 85 | const struct kobj_type *ktype = get_ktype(kobj); | 59 | const struct kobj_type *ktype = get_ktype(kobj); |
| @@ -90,12 +64,6 @@ static int create_dir(struct kobject *kobj) · 4 unmodified lines | |||
| 90 | if (error) | 64 | if (error) |
| 91 | return error; | 65 | return error; |
| 92 | 66 | ||
| 93 | error = populate_dir(kobj); | ||
| 94 | if (error) { | ||
| 95 | sysfs_remove_dir(kobj); | ||
| 96 | return error; | ||
| 97 | } | ||
| 98 | |||
| 99 | if (ktype) { | 67 | if (ktype) { |
| 100 | error = sysfs_create_groups(kobj, ktype->default_groups); | 68 | error = sysfs_create_groups(kobj, ktype->default_groups); |
| 101 | if (error) { | 69 | if (error) { |