2021-01-31 00:14:27

by Rikard Falkeborn

[permalink] [raw]
Subject: [PATCH 0/2] ALSA: Constify static attribute_group structs

Constify two static attribute_group structs that are never modified.
These two were the only static non-const ones in sound/.

Rikard Falkeborn (2):
ALSA: ac97: Constify static struct attribute_group
ALSA: hda: Constify static attribute_group

sound/ac97/bus.c | 2 +-
sound/hda/hdac_sysfs.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

--
2.30.0


2021-01-31 00:14:38

by Rikard Falkeborn

[permalink] [raw]
Subject: [PATCH 1/2] ALSA: ac97: Constify static struct attribute_group

The only usage of ac97_adapter_attr_group is to put its address in an
array of pointers to const attribute_group structs. Make it const to
allow the compiler to put it in read-only memory.

Signed-off-by: Rikard Falkeborn <[email protected]>
---
sound/ac97/bus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/ac97/bus.c b/sound/ac97/bus.c
index 7985dd8198b6..d9077e91382b 100644
--- a/sound/ac97/bus.c
+++ b/sound/ac97/bus.c
@@ -273,7 +273,7 @@ static struct attribute *ac97_controller_device_attrs[] = {
NULL
};

-static struct attribute_group ac97_adapter_attr_group = {
+static const struct attribute_group ac97_adapter_attr_group = {
.name = "ac97_operations",
.attrs = ac97_controller_device_attrs,
};
--
2.30.0

2021-01-31 00:16:14

by Rikard Falkeborn

[permalink] [raw]
Subject: [PATCH 2/2] ALSA: hda: Constify static attribute_group

The only usage of hdac_dev_attr_group is to put its address in an array
of pointers to const attribute_group structs. Make it const to allow the
compiler to put it in read-only memory.

Signed-off-by: Rikard Falkeborn <[email protected]>
---
sound/hda/hdac_sysfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/hda/hdac_sysfs.c b/sound/hda/hdac_sysfs.c
index e56e83325903..0d7771fca9f0 100644
--- a/sound/hda/hdac_sysfs.c
+++ b/sound/hda/hdac_sysfs.c
@@ -66,7 +66,7 @@ static struct attribute *hdac_dev_attrs[] = {
NULL
};

-static struct attribute_group hdac_dev_attr_group = {
+static const struct attribute_group hdac_dev_attr_group = {
.attrs = hdac_dev_attrs,
};

--
2.30.0

2021-01-31 10:36:41

by Takashi Iwai

[permalink] [raw]
Subject: Re: [PATCH 1/2] ALSA: ac97: Constify static struct attribute_group

On Sun, 31 Jan 2021 01:12:40 +0100,
Rikard Falkeborn wrote:
>
> The only usage of ac97_adapter_attr_group is to put its address in an
> array of pointers to const attribute_group structs. Make it const to
> allow the compiler to put it in read-only memory.
>
> Signed-off-by: Rikard Falkeborn <[email protected]>

Thanks, applied.


Takashi

2021-01-31 10:36:57

by Takashi Iwai

[permalink] [raw]
Subject: Re: [PATCH 2/2] ALSA: hda: Constify static attribute_group

On Sun, 31 Jan 2021 01:12:41 +0100,
Rikard Falkeborn wrote:
>
> The only usage of hdac_dev_attr_group is to put its address in an array
> of pointers to const attribute_group structs. Make it const to allow the
> compiler to put it in read-only memory.
>
> Signed-off-by: Rikard Falkeborn <[email protected]>

Thanks, applied.


Takashi