Skip to contentSkip to conversation

ALSA: Constify static attribute_group structs

PATCH Applied Rikard Falkeborn 2 participants 5 messages Jan 31, 2021 Sound

lore
Share & tools
lore
#0 lore raw

cover 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(-)
Signature · 1 line
2.30.0
#1 lore raw

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.

---
 sound/ac97/bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/ac97/bus.c +1 -1
index 7985dd8198b6..d9077e91382b 100644
@@ -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,
 };
Signature · 1 line
2.30.0
Applied
#2 lore raw

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

Quoted 6 lines · Rikard Falkeborn

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.

Thanks, applied.

Takashi

#3 lore raw

PATCH 2/2 ALSA: hda: Constify static attribute_group

In reply to Rikard Falkeborn

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.

---
 sound/hda/hdac_sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/hda/hdac_sysfs.c +1 -1
index e56e83325903..0d7771fca9f0 100644
@@ -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,
 };
 
Signature · 1 line
2.30.0
Applied
#4 lore raw

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

Quoted 6 lines · Rikard Falkeborn

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.

Thanks, applied.

Takashi