ALSA: aoa: Constify struct codec_connection

'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 <christophe.jaillet@wanadoo.fr>
Link: https://patch.msgid.link/4009c337cc1a1a57795562279270c03687973b3b.1772138640.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Christophe JAILLET 2026-02-26 21:44:10 +01:00 committed by Takashi Iwai
commit a69f677020
2 changed files with 15 additions and 15 deletions

View file

@ -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;

View file

@ -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;