[PATCH v1] ALSA: aoa: Constify struct codec_connection
From: Christophe JAILLET <hidden>
Date: 2026-02-26 20:44:22
'struct codec_connection' are not modified in this driver. Constifying these structures moves some data to a read-only section, so increases overall security. On a x86_64, with allmodconfig: Before: ====== text data bss dec hex filename 10034 3392 12 13438 347e sound/aoa/fabrics/layout.o After: ===== text data bss dec hex filename 10370 3040 12 13422 346e sound/aoa/fabrics/layout.o Signed-off-by: Christophe JAILLET <redacted> --- Compile tested only. The fabric_data field in struct aoa_codecis is only used in sound/aoa/fabrics/layout.c, so there should be no side effect for other files that include sound/aoa/aoa.h --- sound/aoa/aoa.h | 2 +- sound/aoa/fabrics/layout.c | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/sound/aoa/aoa.h b/sound/aoa/aoa.h
index badff9f7cd54..b92593f170ca 100644
--- a/sound/aoa/aoa.h
+++ b/sound/aoa/aoa.h@@ -48,7 +48,7 @@ struct aoa_codec { u32 connected; /* data the fabric can associate with this structure */ - void *fabric_data; + const void *fabric_data; /* private! */ struct list_head list;
diff --git a/sound/aoa/fabrics/layout.c b/sound/aoa/fabrics/layout.c
index c18b55305294..c3ebb6de4789 100644
--- a/sound/aoa/fabrics/layout.c
+++ b/sound/aoa/fabrics/layout.c@@ -55,7 +55,7 @@ struct codec_connection { struct codec_connect_info { char *name; - struct codec_connection *connections; + const struct codec_connection *connections; }; #define LAYOUT_FLAG_COMBO_LINEOUT_SPDIF (1<<0)
@@ -116,7 +116,7 @@ MODULE_ALIAS("aoa-device-id-35"); MODULE_ALIAS("aoa-device-id-44"); /* onyx with all but microphone connected */ -static struct codec_connection onyx_connections_nomic[] = { +static const struct codec_connection onyx_connections_nomic[] = { { .connected = CC_SPEAKERS | CC_HEADPHONE | CC_LINEOUT, .codec_bit = 0,
@@ -133,7 +133,7 @@ static struct codec_connection onyx_connections_nomic[] = { }; /* onyx on machines without headphone */ -static struct codec_connection onyx_connections_noheadphones[] = { +static const struct codec_connection onyx_connections_noheadphones[] = { { .connected = CC_SPEAKERS | CC_LINEOUT | CC_LINEOUT_LABELLED_HEADPHONE,
@@ -157,7 +157,7 @@ static struct codec_connection onyx_connections_noheadphones[] = { }; /* onyx on machines with real line-out */ -static struct codec_connection onyx_connections_reallineout[] = { +static const struct codec_connection onyx_connections_reallineout[] = { { .connected = CC_SPEAKERS | CC_LINEOUT | CC_HEADPHONE, .codec_bit = 0,
@@ -174,7 +174,7 @@ static struct codec_connection onyx_connections_reallineout[] = { }; /* tas on machines without line out */ -static struct codec_connection tas_connections_nolineout[] = { +static const struct codec_connection tas_connections_nolineout[] = { { .connected = CC_SPEAKERS | CC_HEADPHONE, .codec_bit = 0,
@@ -191,7 +191,7 @@ static struct codec_connection tas_connections_nolineout[] = { }; /* tas on machines with neither line out nor line in */ -static struct codec_connection tas_connections_noline[] = { +static const struct codec_connection tas_connections_noline[] = { { .connected = CC_SPEAKERS | CC_HEADPHONE, .codec_bit = 0,
@@ -204,7 +204,7 @@ static struct codec_connection tas_connections_noline[] = { }; /* tas on machines without microphone */ -static struct codec_connection tas_connections_nomic[] = { +static const struct codec_connection tas_connections_nomic[] = { { .connected = CC_SPEAKERS | CC_HEADPHONE | CC_LINEOUT, .codec_bit = 0,
@@ -217,7 +217,7 @@ static struct codec_connection tas_connections_nomic[] = { }; /* tas on machines with everything connected */ -static struct codec_connection tas_connections_all[] = { +static const struct codec_connection tas_connections_all[] = { { .connected = CC_SPEAKERS | CC_HEADPHONE | CC_LINEOUT, .codec_bit = 0,
@@ -233,7 +233,7 @@ static struct codec_connection tas_connections_all[] = { {} /* terminate array by .connected == 0 */ }; -static struct codec_connection toonie_connections[] = { +static const struct codec_connection toonie_connections[] = { { .connected = CC_SPEAKERS | CC_HEADPHONE, .codec_bit = 0,
@@ -241,7 +241,7 @@ static struct codec_connection toonie_connections[] = { {} /* terminate array by .connected == 0 */ }; -static struct codec_connection topaz_input[] = { +static const struct codec_connection topaz_input[] = { { .connected = CC_DIGITALIN, .codec_bit = 0,
@@ -249,7 +249,7 @@ static struct codec_connection topaz_input[] = { {} /* terminate array by .connected == 0 */ }; -static struct codec_connection topaz_output[] = { +static const struct codec_connection topaz_output[] = { { .connected = CC_DIGITALOUT, .codec_bit = 1,
@@ -257,7 +257,7 @@ static struct codec_connection topaz_output[] = { {} /* terminate array by .connected == 0 */ }; -static struct codec_connection topaz_inout[] = { +static const struct codec_connection topaz_inout[] = { { .connected = CC_DIGITALIN, .codec_bit = 0,
@@ -772,7 +772,7 @@ static int check_codec(struct aoa_codec *codec, { const u32 *ref; char propname[32]; - struct codec_connection *cc; + const struct codec_connection *cc; /* if the codec has a 'codec' node, we require a reference */ if (of_node_name_eq(codec->node, "codec")) {
@@ -895,7 +895,7 @@ static void layout_notify(void *data) static void layout_attached_codec(struct aoa_codec *codec) { - struct codec_connection *cc; + const struct codec_connection *cc; struct snd_kcontrol *ctl; int headphones, lineout; struct layout_dev *ldev = layout_device;
--
2.53.0