diff options
| author | Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com> | 2025-01-14 13:43:14 -0500 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2025-01-15 13:11:12 +0000 |
| commit | 04e97fa7dd7e3eda754712f92df2136acd1d9088 (patch) | |
| tree | 92693be23e941e376de4b319604cba24ff220e40 /include/sound/simple_card_utils.h | |
| parent | ASoC: codecs: nau8824: fix max volume for Speaker output (diff) | |
| download | linux-04e97fa7dd7e3eda754712f92df2136acd1d9088.tar.gz linux-04e97fa7dd7e3eda754712f92df2136acd1d9088.zip | |
ASoC: simple-card-utils: fix priv->dai_props indexing
As of commit cb18cd26039f ("ASoC: soc-core: do rtd->id trick at
snd_soc_add_pcm_runtime()") the ID stored in the PCM runtime data can
no longer be safely used to index the priv->dai_props array. This is
because the ID may be modified during snd_soc_add_pcm_runtime(), thus
resulting in an ID that's no longer a valid array index.
To fix this, use the position of the dai_link stored inside the PCM
runtime data relative to the start of the dai_link array as index into
the priv->dai_props array.
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://patch.msgid.link/20250114184314.3583-2-laurentiumihalcea111@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'include/sound/simple_card_utils.h')
| -rw-r--r-- | include/sound/simple_card_utils.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 3360d9eab068..36a485571142 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -89,6 +89,13 @@ struct simple_util_priv { #define simple_props_to_dai_codec(props, i) ((props)->codec_dai + i) #define simple_props_to_codec_conf(props, i) ((props)->codec_conf + i) +/* has the same effect as simple_priv_to_props(). Preferred over + * simple_priv_to_props() when dealing with PCM runtime data as + * the ID stored in rtd->id may not be a valid array index. + */ +#define runtime_simple_priv_to_props(priv, rtd) \ + ((priv)->dai_props + ((rtd)->dai_link - (priv)->dai_link)) + #define for_each_prop_dlc_cpus(props, i, cpu) \ for ((i) = 0; \ ((i) < (props)->num.cpus) && \ |
