2022-01-05 18:37:31

by Greg Kroah-Hartman

[permalink] [raw]
Subject: [PATCH] efi: 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 firmware efi 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.

Cc: Ard Biesheuvel <[email protected]>
Cc: [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
drivers/firmware/efi/efivars.c | 3 ++-
drivers/firmware/efi/esrt.c | 4 +++-
drivers/firmware/efi/runtime-map.c | 3 ++-
3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
index e6b16b3a17a8..ea0bc39dc965 100644
--- a/drivers/firmware/efi/efivars.c
+++ b/drivers/firmware/efi/efivars.c
@@ -352,11 +352,12 @@ static struct attribute *def_attrs[] = {
&efivar_attr_raw_var.attr,
NULL,
};
+ATTRIBUTE_GROUPS(def);

static struct kobj_type efivar_ktype = {
.release = efivar_release,
.sysfs_ops = &efivar_attr_ops,
- .default_attrs = def_attrs,
+ .default_groups = def_groups,
};

static ssize_t efivar_create(struct file *filp, struct kobject *kobj,
diff --git a/drivers/firmware/efi/esrt.c b/drivers/firmware/efi/esrt.c
index d5915272141f..2a2f52b017e7 100644
--- a/drivers/firmware/efi/esrt.c
+++ b/drivers/firmware/efi/esrt.c
@@ -146,6 +146,8 @@ static struct attribute *esre1_attrs[] = {
&esre_last_attempt_status.attr,
NULL
};
+ATTRIBUTE_GROUPS(esre1);
+
static void esre_release(struct kobject *kobj)
{
struct esre_entry *entry = to_entry(kobj);
@@ -157,7 +159,7 @@ static void esre_release(struct kobject *kobj)
static struct kobj_type esre1_ktype = {
.release = esre_release,
.sysfs_ops = &esre_attr_ops,
- .default_attrs = esre1_attrs,
+ .default_groups = esre1_groups,
};


diff --git a/drivers/firmware/efi/runtime-map.c b/drivers/firmware/efi/runtime-map.c
index ad9ddefc9dcb..92a3d45a795c 100644
--- a/drivers/firmware/efi/runtime-map.c
+++ b/drivers/firmware/efi/runtime-map.c
@@ -79,6 +79,7 @@ static struct attribute *def_attrs[] = {
&map_attribute_attr.attr,
NULL
};
+ATTRIBUTE_GROUPS(def);

static const struct sysfs_ops map_attr_ops = {
.show = map_attr_show,
@@ -94,7 +95,7 @@ static void map_release(struct kobject *kobj)

static struct kobj_type __refdata map_ktype = {
.sysfs_ops = &map_attr_ops,
- .default_attrs = def_attrs,
+ .default_groups = def_groups,
.release = map_release,
};

--
2.34.1



2022-01-06 10:21:12

by Ard Biesheuvel

[permalink] [raw]
Subject: Re: [PATCH] efi: use default_groups in kobj_type

On Wed, 5 Jan 2022 at 19:37, Greg Kroah-Hartman
<[email protected]> wrote:
>
> 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 firmware efi 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.
>
> Cc: Ard Biesheuvel <[email protected]>
> Cc: [email protected]
> Signed-off-by: Greg Kroah-Hartman <[email protected]>

Queued up, thanks.

> ---
> drivers/firmware/efi/efivars.c | 3 ++-
> drivers/firmware/efi/esrt.c | 4 +++-
> drivers/firmware/efi/runtime-map.c | 3 ++-
> 3 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
> index e6b16b3a17a8..ea0bc39dc965 100644
> --- a/drivers/firmware/efi/efivars.c
> +++ b/drivers/firmware/efi/efivars.c
> @@ -352,11 +352,12 @@ static struct attribute *def_attrs[] = {
> &efivar_attr_raw_var.attr,
> NULL,
> };
> +ATTRIBUTE_GROUPS(def);
>
> static struct kobj_type efivar_ktype = {
> .release = efivar_release,
> .sysfs_ops = &efivar_attr_ops,
> - .default_attrs = def_attrs,
> + .default_groups = def_groups,
> };
>
> static ssize_t efivar_create(struct file *filp, struct kobject *kobj,
> diff --git a/drivers/firmware/efi/esrt.c b/drivers/firmware/efi/esrt.c
> index d5915272141f..2a2f52b017e7 100644
> --- a/drivers/firmware/efi/esrt.c
> +++ b/drivers/firmware/efi/esrt.c
> @@ -146,6 +146,8 @@ static struct attribute *esre1_attrs[] = {
> &esre_last_attempt_status.attr,
> NULL
> };
> +ATTRIBUTE_GROUPS(esre1);
> +
> static void esre_release(struct kobject *kobj)
> {
> struct esre_entry *entry = to_entry(kobj);
> @@ -157,7 +159,7 @@ static void esre_release(struct kobject *kobj)
> static struct kobj_type esre1_ktype = {
> .release = esre_release,
> .sysfs_ops = &esre_attr_ops,
> - .default_attrs = esre1_attrs,
> + .default_groups = esre1_groups,
> };
>
>
> diff --git a/drivers/firmware/efi/runtime-map.c b/drivers/firmware/efi/runtime-map.c
> index ad9ddefc9dcb..92a3d45a795c 100644
> --- a/drivers/firmware/efi/runtime-map.c
> +++ b/drivers/firmware/efi/runtime-map.c
> @@ -79,6 +79,7 @@ static struct attribute *def_attrs[] = {
> &map_attribute_attr.attr,
> NULL
> };
> +ATTRIBUTE_GROUPS(def);
>
> static const struct sysfs_ops map_attr_ops = {
> .show = map_attr_show,
> @@ -94,7 +95,7 @@ static void map_release(struct kobject *kobj)
>
> static struct kobj_type __refdata map_ktype = {
> .sysfs_ops = &map_attr_ops,
> - .default_attrs = def_attrs,
> + .default_groups = def_groups,
> .release = map_release,
> };
>
> --
> 2.34.1
>