ASoC: intel: Constify struct snd_soc_ops
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Mon, 13 May 2024 17:57:16 +0000 (19:57 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 27 May 2024 00:31:24 +0000 (01:31 +0100)
Constifying "struct snd_soc_ops" moves some data to a read-only section, so
increase overall security.

This structure is also part of scripts/const_structs.checkpatch.

As an example, on a x86_64, with allmodconfig:
Before:
   text    data     bss     dec     hex filename
   6315    3696       0   10011    271b sound/soc/intel/boards/ehl_rt5660.o

After:
   text    data     bss     dec     hex filename
   6379    3648       0   10027    272b sound/soc/intel/boards/ehl_rt5660.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://msgid.link/r/2f0613bf4c6018569cdaac876d0589e49cf38a80.1715622793.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
14 files changed:
sound/soc/intel/boards/bdw-rt5650.c
sound/soc/intel/boards/ehl_rt5660.c
sound/soc/intel/boards/kbl_da7219_max98357a.c
sound/soc/intel/boards/kbl_da7219_max98927.c
sound/soc/intel/boards/kbl_rt5660.c
sound/soc/intel/boards/kbl_rt5663_max98927.c
sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
sound/soc/intel/boards/sof_es8336.c
sound/soc/intel/boards/sof_nau8825.c
sound/soc/intel/boards/sof_realtek_common.c
sound/soc/intel/boards/sof_rt5682.c
sound/soc/intel/boards/sof_sdw_common.h
sound/soc/intel/boards/sof_sdw_rt_amp.c
sound/soc/intel/boards/sof_wm8804.c

index 3ae26f21458f332019c69f6f39328b50a6aa00f6..3c7cee03a02e6485c833fffa14c49d0fa3193967 100644 (file)
@@ -131,7 +131,7 @@ static int bdw_rt5650_hw_params(struct snd_pcm_substream *substream,
        return ret;
 }
 
-static struct snd_soc_ops bdw_rt5650_ops = {
+static const struct snd_soc_ops bdw_rt5650_ops = {
        .hw_params = bdw_rt5650_hw_params,
 };
 
index 686e603212243d6802c16f53dc882f79c4fa40af..26289e8fdd873e76e6ff6f6626c73aeb662e2e36 100644 (file)
@@ -132,7 +132,7 @@ static int rt5660_hw_params(struct snd_pcm_substream *substream,
        return ret;
 }
 
-static struct snd_soc_ops rt5660_ops = {
+static const struct snd_soc_ops rt5660_ops = {
        .hw_params = rt5660_hw_params,
 };
 
index 9dbc15f9d1c9b69f64360399dc5cf8a08461f487..154f6a74ed151f9318d2c6f3f13550f503b559d8 100644 (file)
@@ -354,7 +354,7 @@ static int kabylake_dmic_startup(struct snd_pcm_substream *substream)
                        SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
 }
 
-static struct snd_soc_ops kabylake_dmic_ops = {
+static const struct snd_soc_ops kabylake_dmic_ops = {
        .startup = kabylake_dmic_startup,
 };
 
@@ -388,7 +388,7 @@ static int kabylake_refcap_startup(struct snd_pcm_substream *substream)
                                        &constraints_16000);
 }
 
-static struct snd_soc_ops skylake_refcap_ops = {
+static const struct snd_soc_ops skylake_refcap_ops = {
        .startup = kabylake_refcap_startup,
 };
 
index e662da5af83b591e6cf648ebebd3479202a6a1e9..02ed77a07e23d69be91899ec27cdaa1f62f4072c 100644 (file)
@@ -288,7 +288,7 @@ static int kabylake_ssp0_trigger(struct snd_pcm_substream *substream, int cmd)
        return 0;
 }
 
-static struct snd_soc_ops kabylake_ssp0_ops = {
+static const struct snd_soc_ops kabylake_ssp0_ops = {
        .hw_params = kabylake_ssp0_hw_params,
        .trigger = kabylake_ssp0_trigger,
 };
@@ -535,7 +535,7 @@ static int kabylake_dmic_startup(struct snd_pcm_substream *substream)
                        SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
 }
 
-static struct snd_soc_ops kabylake_dmic_ops = {
+static const struct snd_soc_ops kabylake_dmic_ops = {
        .startup = kabylake_dmic_startup,
 };
 
@@ -569,7 +569,7 @@ static int kabylake_refcap_startup(struct snd_pcm_substream *substream)
 }
 
 
-static struct snd_soc_ops skylake_refcap_ops = {
+static const struct snd_soc_ops skylake_refcap_ops = {
        .startup = kabylake_refcap_startup,
 };
 
index 894d127c482a3beacba85b6b24434ac31213144c..66885cb36f2489a07de5c0ecebc39bcbe0f44b59 100644 (file)
@@ -277,7 +277,7 @@ static int kabylake_rt5660_hw_params(struct snd_pcm_substream *substream,
        return ret;
 }
 
-static struct snd_soc_ops kabylake_rt5660_ops = {
+static const struct snd_soc_ops kabylake_rt5660_ops = {
        .hw_params = kabylake_rt5660_hw_params,
 };
 
index e16c42e81ecaa8b62ad603ce26d1b1fefa923b1c..9da89436a917b02a36d7dfd7a2ca3a2e7ed7060e 100644 (file)
@@ -489,7 +489,7 @@ static int kabylake_rt5663_hw_params(struct snd_pcm_substream *substream,
        return ret;
 }
 
-static struct snd_soc_ops kabylake_rt5663_ops = {
+static const struct snd_soc_ops kabylake_rt5663_ops = {
        .hw_params = kabylake_rt5663_hw_params,
 };
 
@@ -539,7 +539,7 @@ static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream,
        return ret;
 }
 
-static struct snd_soc_ops kabylake_ssp0_ops = {
+static const struct snd_soc_ops kabylake_ssp0_ops = {
        .hw_params = kabylake_ssp0_hw_params,
 };
 
@@ -575,7 +575,7 @@ static int kabylake_dmic_startup(struct snd_pcm_substream *substream)
                        SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
 }
 
-static struct snd_soc_ops kabylake_dmic_ops = {
+static const struct snd_soc_ops kabylake_dmic_ops = {
        .startup = kabylake_dmic_startup,
 };
 
@@ -609,7 +609,7 @@ static int kabylake_refcap_startup(struct snd_pcm_substream *substream)
                                &constraints_16000);
 }
 
-static struct snd_soc_ops skylake_refcap_ops = {
+static const struct snd_soc_ops skylake_refcap_ops = {
        .startup = kabylake_refcap_startup,
 };
 
index a9501cd106ff2c4b1819a880e237a8797b7796a5..a32ce8f972f39888e66fdf44a4388c6bc01bf66e 100644 (file)
@@ -424,7 +424,7 @@ static int kabylake_rt5663_hw_params(struct snd_pcm_substream *substream,
        return ret;
 }
 
-static struct snd_soc_ops kabylake_rt5663_ops = {
+static const struct snd_soc_ops kabylake_rt5663_ops = {
        .hw_params = kabylake_rt5663_hw_params,
 };
 
@@ -469,7 +469,7 @@ static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream,
        return ret;
 }
 
-static struct snd_soc_ops kabylake_ssp0_ops = {
+static const struct snd_soc_ops kabylake_ssp0_ops = {
        .hw_params = kabylake_ssp0_hw_params,
 };
 
@@ -508,7 +508,7 @@ static int kabylake_dmic_startup(struct snd_pcm_substream *substream)
                        SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
 }
 
-static struct snd_soc_ops kabylake_dmic_ops = {
+static const struct snd_soc_ops kabylake_dmic_ops = {
        .startup = kabylake_dmic_startup,
 };
 
index c1fcc156a5752c24909afb0326205528fdbdc0bb..2a88efaa6d26bd1d553c4b4919091663e979100a 100644 (file)
@@ -371,7 +371,7 @@ static int sof_es8336_hw_params(struct snd_pcm_substream *substream,
 }
 
 /* machine stream operations */
-static struct snd_soc_ops sof_es8336_ops = {
+static const struct snd_soc_ops sof_es8336_ops = {
        .hw_params = sof_es8336_hw_params,
        .trigger = sof_8336_trigger,
 };
index c08b4eef0bcbe6847c80b6962a871a4bce533e10..bfe17acbc161f7fab277b635c9ca2b11fae698ef 100644 (file)
@@ -115,7 +115,7 @@ static int sof_nau8825_hw_params(struct snd_pcm_substream *substream,
        return ret;
 }
 
-static struct snd_soc_ops sof_nau8825_ops = {
+static const struct snd_soc_ops sof_nau8825_ops = {
        .hw_params = sof_nau8825_hw_params,
 };
 
index dda346e0f7374ee6f2c9edc99aa58ee48e0379e2..f52e25083905882fc8f1f424d497173e290cfed0 100644 (file)
@@ -452,7 +452,7 @@ static int rt1015_hw_params(struct snd_pcm_substream *substream,
        return ret;
 }
 
-static struct snd_soc_ops rt1015_ops = {
+static const struct snd_soc_ops rt1015_ops = {
        .hw_params = rt1015_hw_params,
 };
 
index 6fc6eb0c5172ca4916a221d89a24f56f2d2882e2..23a40b913290a2f871d23e7fc4dd2af2b68da9df 100644 (file)
@@ -397,7 +397,7 @@ static int sof_rt5682_hw_params(struct snd_pcm_substream *substream,
        return ret;
 }
 
-static struct snd_soc_ops sof_rt5682_ops = {
+static const struct snd_soc_ops sof_rt5682_ops = {
        .hw_params = sof_rt5682_hw_params,
 };
 
index 3dfba6f6b95dc64ef493892193b9dae1af414205..7dedac9180658e4e06ae77d04fed80ea182ebceb 100644 (file)
@@ -169,7 +169,7 @@ int sof_sdw_rt_sdca_jack_init(struct snd_soc_card *card,
 int sof_sdw_rt_sdca_jack_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link);
 
 /* RT1308 I2S support */
-extern struct snd_soc_ops sof_sdw_rt1308_i2s_ops;
+extern const struct snd_soc_ops sof_sdw_rt1308_i2s_ops;
 
 /* generic amp support */
 int sof_sdw_rt_amp_init(struct snd_soc_card *card,
index 797ea9ffa77afd6d17e7f85479c655e24f0e5ae3..d1c0f91ce5897909b7fae3c9a63e7d35aa827d70 100644 (file)
@@ -233,7 +233,7 @@ static int rt1308_i2s_hw_params(struct snd_pcm_substream *substream,
 }
 
 /* machine stream operations */
-struct snd_soc_ops sof_sdw_rt1308_i2s_ops = {
+const struct snd_soc_ops sof_sdw_rt1308_i2s_ops = {
        .hw_params = rt1308_i2s_hw_params,
 };
 
index 4cb0d463bf404912e94c4f58dc1cf4bfc76bd66b..b2d02cc92a6a8dfb22d09ad23a3c1d7c1833a1a7 100644 (file)
@@ -148,7 +148,7 @@ static int sof_wm8804_hw_params(struct snd_pcm_substream *substream,
 }
 
 /* machine stream operations */
-static struct snd_soc_ops sof_wm8804_ops = {
+static const struct snd_soc_ops sof_wm8804_ops = {
        .hw_params = sof_wm8804_hw_params,
 };