| From 57b42d920db61d9165e8868320e7b0ee39095783 Mon Sep 17 00:00:00 2001 |
| From: Sasha Levin <sashal@kernel.org> |
| Date: Mon, 6 Mar 2023 01:43:30 +0000 |
| Subject: ASoC: soc-dai.c: add missing flag check at snd_soc_pcm_dai_probe() |
| |
| From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> |
| |
| [ Upstream commit 5c5a7521e9364a40fe2c1b67ab79991e3e9085df ] |
| |
| dai->probed is used at snd_soc_pcm_dai_probe/remove(), |
| and used to call real remove() function only when it was probed. |
| |
| int snd_soc_pcm_dai_probe(...) |
| { |
| ... |
| for_each_rtd_dais(rtd, i, dai) { |
| ... |
| |
| if (dai->driver->probe) { |
| (A) int ret = dai->driver->probe(dai); |
| |
| if (ret < 0) |
| return soc_dai_ret(dai, ret); |
| } |
| |
| => dai->probed = 1; |
| } |
| ... |
| } |
| |
| int snd_soc_pcm_dai_remove(...) |
| { |
| ... |
| for_each_rtd_dais(rtd, i, dai) { |
| ... |
| => if (dai->probed && |
| ...) { |
| ... |
| } |
| |
| => dai->probed = 0; |
| } |
| ... |
| } |
| |
| But on probe() case, we need to check dai->probed before calling |
| real probe() function at (A), otherwise real probe() might be called |
| multi times (but real remove() will be called only once). |
| This patch checks it at probe(). |
| |
| Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> |
| Link: https://lore.kernel.org/r/87wn3u64e6.wl-kuninori.morimoto.gx@renesas.com |
| Signed-off-by: Mark Brown <broonie@kernel.org> |
| Stable-dep-of: 0e270f32975f ("ASoC: fsl_sai: replace regmap_write with regmap_update_bits") |
| Signed-off-by: Sasha Levin <sashal@kernel.org> |
| --- |
| sound/soc/soc-dai.c | 3 +++ |
| 1 file changed, 3 insertions(+) |
| |
| diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c |
| index ba8a99124869..5eac6a7559c7 100644 |
| --- a/sound/soc/soc-dai.c |
| +++ b/sound/soc/soc-dai.c |
| @@ -548,6 +548,9 @@ int snd_soc_pcm_dai_probe(struct snd_soc_pcm_runtime *rtd, int order) |
| if (dai->driver->probe_order != order) |
| continue; |
| |
| + if (dai->probed) |
| + continue; |
| + |
| if (dai->driver->probe) { |
| int ret = dai->driver->probe(dai); |
| |
| -- |
| 2.50.1 |
| |