x86/CPU/AMD: use default_groups in kobj_type
Subsystems (3)
PATCH v2 1/1 x86/CPU/AMD: use default_groups in kobj_type
There are currently 2 ways to create a set of sysfs files for a kobj_type, through the default_attrs field, and the default_groups field. Move the AMD mce sysfs code to use default_groups field which has been the preferred way since aa30f47cf666 ("kobject: Add support for default attribute groups to kobj_type") so that we can soon get rid of the obsolete default_attrs field.
---
v2: fix up direct pointers through the kobj_type to the default_attrs
The logic here still isn't all that nice, ideally the is_visible() callback for the attribute group should be used instead as that is what it is for.
arch/x86/kernel/cpu/mce/amd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/mce/amd.c +4 -3
@@ -1171,6 +1171,7 @@ static struct attribute *default_attrs[] = {NULL ,/* possibly interrupt_enable if supported, see below */ NULL , }; +ATTRIBUTE_GROUPS (default);#define to_block (k) container_of(k, struct threshold_block, kobj)#define to_attr (a) container_of(a, struct threshold_attr, attr)
@@ -1207,7 +1208,7 @@ static void threshold_block_release(struct kobject *kobj);static struct kobj_type threshold_ktype = { .sysfs_ops = &threshold_ops, - .default_attrs = default_attrs, + .default_groups = default_groups, .release = threshold_block_release, };
@@ -1279,10 +1280,10 @@ static int allocate_threshold_blocks(unsigned int cpu, struct threshold_bank *tb b->threshold_limit =THRESHOLD_MAX ;if (b->interrupt_capable) { - threshold_ktype.default_attrs[2 ] = &interrupt_enable.attr; + default_attrs[2 ] = &interrupt_enable.attr; b->interrupt_enable =1 ; }else { - threshold_ktype.default_attrs[2 ] =NULL ; + default_attrs[2 ] =NULL ; }INIT_LIST_HEAD (&b->miscj);
Signature · 1 line
2.34.1
Quoted 7 lines · Greg Kroah-Hartman
There are currently 2 ways to create a set of sysfs files for a
kobj_type, through thedefault_attrsfield, and thedefault_groupsfield. Move the AMD mce sysfs code to usedefault_groupsfield which has been the preferred way sinceaa30f47cf666("kobject: Add support for default attribute groups tokobj_type") so that we can soon get rid of the obsoletedefault_attrsfield.
Quoted 9 lines
Cc Tony Luck <[email protected]>Cc Borislav Petkov <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc Dave Hansen <[email protected]>Cc "H. Peter Anvin" <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 6 lines
---
v2: fix up direct pointers through thekobj_typeto thedefault_attrs
The logic here still isn't all that nice, ideally theis_visible()callback for the attribute group should be used instead as that is what it is for.
I'll check that out. Thanks!
-Yazen
[tip: x86/cpu] x86/CPU/AMD: Use default_groups in kobj_type
In reply to Greg Kroah-HartmanThe following commit has been merged into the x86/cpu branch of tip:
The following commit has been merged into the x86/cpu branch of tip:
Commit-ID: 7237727f8c4415fa925c723fc03be373834c21b9 Gitweb: https://git.kernel.org/tip/7237727f8c4415fa925c723fc03be373834c21b9 Author: Greg Kroah-Hartman <[email protected]> AuthorDate: Thu, 06 Jan 2022 11:35:37 +01:00 Committer: Borislav Petkov <[email protected]> CommitterDate: Sun, 23 Jan 2022 20:30:27 +01:00
x86/CPU/AMD: Use default_groups in kobj_type
There are currently 2 ways to create a set of sysfs files for a kobj_type, through the default_attrs field, and the default_groups field. Move the AMD mce sysfs code to use default_groups field which has been the preferred way since
aa30f47cf666 ("kobject: Add support for default attribute groups to kobj_type")
so that the obsolete default_attrs field can be removed soon.
--- arch/x86/kernel/cpu/mce/amd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/mce/amd.c +4 -3
@@ -993,6 +993,7 @@ static struct attribute *default_attrs[] = {NULL ,/* possibly interrupt_enable if supported, see below */ NULL , }; +ATTRIBUTE_GROUPS (default);#define to_block (k) container_of(k, struct threshold_block, kobj)#define to_attr (a) container_of(a, struct threshold_attr, attr)
@@ -1029,7 +1030,7 @@ static void threshold_block_release(struct kobject *kobj);static struct kobj_type threshold_ktype = { .sysfs_ops = &threshold_ops, - .default_attrs = default_attrs, + .default_groups = default_groups, .release = threshold_block_release, };
@@ -1101,10 +1102,10 @@ static int allocate_threshold_blocks(unsigned int cpu, struct threshold_bank *tb b->threshold_limit =THRESHOLD_MAX ;if (b->interrupt_capable) { - threshold_ktype.default_attrs[2 ] = &interrupt_enable.attr; + default_attrs[2 ] = &interrupt_enable.attr; b->interrupt_enable =1 ; }else { - threshold_ktype.default_attrs[2 ] =NULL ; + default_attrs[2 ] =NULL ; }INIT_LIST_HEAD (&b->miscj);
[tip: x86/cpu] x86/CPU/AMD: Use default_groups in kobj_type
In reply to Greg Kroah-HartmanThe following commit has been merged into the x86/cpu branch of tip:
The following commit has been merged into the x86/cpu branch of tip:
Commit-ID: 7f99cb5e60392fc3494c610776e733b68784280c Gitweb: https://git.kernel.org/tip/7f99cb5e60392fc3494c610776e733b68784280c Author: Greg Kroah-Hartman <[email protected]> AuthorDate: Thu, 06 Jan 2022 11:35:37 +01:00 Committer: Borislav Petkov <[email protected]> CommitterDate: Tue, 01 Feb 2022 12:41:24 +01:00
x86/CPU/AMD: Use default_groups in kobj_type
There are currently 2 ways to create a set of sysfs files for a kobj_type, through the default_attrs field, and the default_groups field. Move the AMD mce sysfs code to use default_groups field which has been the preferred way since
aa30f47cf666 ("kobject: Add support for default attribute groups to kobj_type")
so that the obsolete default_attrs field can be removed soon.
--- arch/x86/kernel/cpu/mce/amd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/mce/amd.c +4 -3
@@ -993,6 +993,7 @@ static struct attribute *default_attrs[] = {NULL ,/* possibly interrupt_enable if supported, see below */ NULL , }; +ATTRIBUTE_GROUPS (default);#define to_block (k) container_of(k, struct threshold_block, kobj)#define to_attr (a) container_of(a, struct threshold_attr, attr)
@@ -1029,7 +1030,7 @@ static void threshold_block_release(struct kobject *kobj);static struct kobj_type threshold_ktype = { .sysfs_ops = &threshold_ops, - .default_attrs = default_attrs, + .default_groups = default_groups, .release = threshold_block_release, };
@@ -1101,10 +1102,10 @@ static int allocate_threshold_blocks(unsigned int cpu, struct threshold_bank *tb b->threshold_limit =THRESHOLD_MAX ;if (b->interrupt_capable) { - threshold_ktype.default_attrs[2 ] = &interrupt_enable.attr; + default_attrs[2 ] = &interrupt_enable.attr; b->interrupt_enable =1 ; }else { - threshold_ktype.default_attrs[2 ] =NULL ; + default_attrs[2 ] =NULL ; }INIT_LIST_HEAD (&b->miscj);