ASoC: soc-core: find rtd via dai_link pointer at snd_soc_get_pcm_runtime()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tue, 10 Dec 2019 00:34:08 +0000 (09:34 +0900)
committerMark Brown <broonie@kernel.org>
Tue, 10 Dec 2019 13:15:21 +0000 (13:15 +0000)
Current snd_soc_get_pcm_runtime() is finding rtd by checking dai_link
name. But, it is strange and waste of CPU power, because its user want
to get from rtd from dai_link, not from dai_link name.
This patch find rtd via dai_link pointer instead of its name.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/87a781yq67.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc.h
sound/soc/fsl/fsl-asoc-card.c
sound/soc/pxa/mioa701_wm9713.c
sound/soc/samsung/bells.c
sound/soc/samsung/littlemill.c
sound/soc/samsung/snow.c
sound/soc/samsung/speyside.c
sound/soc/samsung/tm2_wm5110.c
sound/soc/samsung/tobermory.c
sound/soc/soc-core.c
sound/soc/tegra/tegra_wm8903.c

index 68ec5a051afefe214f84bae47293f6bbcb349154..40c2a677f53113a08fe7788fb4846a64c550bca6 100644 (file)
@@ -465,7 +465,7 @@ static inline int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
 void snd_soc_disconnect_sync(struct device *dev);
 
 struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card,
-               const char *dai_link);
+                               struct snd_soc_dai_link *dai_link);
 
 bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd);
 void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd, int stream);
index 39ea9bda139470ba8c7cdea9c0efa3dc66d0f2c1..9ce55feaac22d005f1785c266fde9ac92cae5026 100644 (file)
@@ -256,7 +256,7 @@ static int fsl_asoc_card_set_bias_level(struct snd_soc_card *card,
        unsigned int pll_out;
        int ret;
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
        codec_dai = rtd->codec_dai;
        if (dapm->dev != codec_dai->dev)
                return 0;
index 129eb5251a5fa135a83774a200775805a4c40294..76e054d514a8fe54bce4f8841b60bd930ed7794d 100644 (file)
@@ -72,7 +72,7 @@ static int rear_amp_event(struct snd_soc_dapm_widget *widget,
        struct snd_soc_pcm_runtime *rtd;
        struct snd_soc_component *component;
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
        component = rtd->codec_dai->component;
        return rear_amp_power(component, SND_SOC_DAPM_EVENT_ON(event));
 }
index b60b2268b60883bcf71b7543010721aeab5fc653..58d8a81aa0eadbcef6663c4c56a4ea3a43a03da4 100644 (file)
@@ -59,7 +59,7 @@ static int bells_set_bias_level(struct snd_soc_card *card,
        struct bells_drvdata *bells = card->drvdata;
        int ret;
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_DSP_CODEC].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_DSP_CODEC]);
        codec_dai = rtd->codec_dai;
        component = codec_dai->component;
 
@@ -105,7 +105,7 @@ static int bells_set_bias_level_post(struct snd_soc_card *card,
        struct bells_drvdata *bells = card->drvdata;
        int ret;
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_DSP_CODEC].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_DSP_CODEC]);
        codec_dai = rtd->codec_dai;
        component = codec_dai->component;
 
@@ -151,10 +151,10 @@ static int bells_late_probe(struct snd_soc_card *card)
        struct snd_soc_dai *wm9081_dai;
        int ret;
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_AP_DSP].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_AP_DSP]);
        wm0010 = rtd->codec_dai->component;
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_DSP_CODEC].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_DSP_CODEC]);
        component = rtd->codec_dai->component;
        aif1_dai = rtd->codec_dai;
 
@@ -194,7 +194,7 @@ static int bells_late_probe(struct snd_soc_card *card)
                return ret;
        }
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_CODEC_CP].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_CODEC_CP]);
        aif2_dai = rtd->cpu_dai;
 
        ret = snd_soc_dai_set_sysclk(aif2_dai, ARIZONA_CLK_ASYNCCLK, 0, 0);
@@ -206,7 +206,7 @@ static int bells_late_probe(struct snd_soc_card *card)
        if (card->num_rtd == DAI_CODEC_SUB)
                return 0;
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_CODEC_SUB].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_CODEC_SUB]);
        aif3_dai = rtd->cpu_dai;
        wm9081_dai = rtd->codec_dai;
 
index 6132cee8550b34bed79c0960ca539301d1434811..59904f44118b9d48495c6506690c7d03324b06c4 100644 (file)
@@ -22,7 +22,7 @@ static int littlemill_set_bias_level(struct snd_soc_card *card,
        struct snd_soc_dai *aif1_dai;
        int ret;
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
        aif1_dai = rtd->codec_dai;
 
        if (dapm->dev != aif1_dai->dev)
@@ -69,7 +69,7 @@ static int littlemill_set_bias_level_post(struct snd_soc_card *card,
        struct snd_soc_dai *aif1_dai;
        int ret;
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
        aif1_dai = rtd->codec_dai;
 
        if (dapm->dev != aif1_dai->dev)
@@ -180,7 +180,7 @@ static int bbclk_ev(struct snd_soc_dapm_widget *w,
        struct snd_soc_dai *aif2_dai;
        int ret;
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[1]);
        aif2_dai = rtd->cpu_dai;
 
        switch (event) {
@@ -263,11 +263,11 @@ static int littlemill_late_probe(struct snd_soc_card *card)
        struct snd_soc_dai *aif2_dai;
        int ret;
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
        component = rtd->codec_dai->component;
        aif1_dai = rtd->codec_dai;
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[1]);
        aif2_dai = rtd->cpu_dai;
 
        ret = snd_soc_dai_set_sysclk(aif1_dai, WM8994_SYSCLK_MCLK2,
index 8ea7799df028a9b36f0baed39a2157342eb119de..f075aae9561a702538e5f0e161161f8ed8c6cf89 100644 (file)
@@ -106,7 +106,7 @@ static int snow_late_probe(struct snd_soc_card *card)
        struct snd_soc_pcm_runtime *rtd;
        struct snd_soc_dai *codec_dai;
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
 
        /* In the multi-codec case codec_dais 0 is MAX98095 and 1 is HDMI. */
        if (rtd->num_codecs > 1)
index 9e58cbed942a918737dd0296dd47e13cfa144544..5ccdfe0eb6fe723ae79fac1fd45d6e06c670ebe6 100644 (file)
@@ -24,7 +24,7 @@ static int speyside_set_bias_level(struct snd_soc_card *card,
        struct snd_soc_dai *codec_dai;
        int ret;
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[1]);
        codec_dai = rtd->codec_dai;
 
        if (dapm->dev != codec_dai->dev)
@@ -60,7 +60,7 @@ static int speyside_set_bias_level_post(struct snd_soc_card *card,
        struct snd_soc_dai *codec_dai;
        int ret;
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[1]);
        codec_dai = rtd->codec_dai;
 
        if (dapm->dev != codec_dai->dev)
index bb9910d4cbe24ea89e72e9909af6b3c2fe06680a..10ff14b856f2366f38f3137f4803cbf19a606c7c 100644 (file)
@@ -282,7 +282,7 @@ static int tm2_set_bias_level(struct snd_soc_card *card,
 {
        struct snd_soc_pcm_runtime *rtd;
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
 
        if (dapm->dev != rtd->codec_dai->dev)
                return 0;
@@ -314,7 +314,7 @@ static int tm2_late_probe(struct snd_soc_card *card)
        struct snd_soc_dai *aif2_dai;
        int ret;
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[TM2_DAI_AIF1].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[TM2_DAI_AIF1]);
        aif1_dai = rtd->codec_dai;
        priv->component = rtd->codec_dai->component;
 
@@ -324,7 +324,7 @@ static int tm2_late_probe(struct snd_soc_card *card)
                return ret;
        }
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[TM2_DAI_AIF2].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[TM2_DAI_AIF2]);
        aif2_dai = rtd->codec_dai;
 
        ret = snd_soc_dai_set_sysclk(aif2_dai, ARIZONA_CLK_ASYNCCLK, 0, 0);
index ef51f289fbc73216b63f71fffc1e44ce3b2b119a..fdce28cc26c4155d5c2bb629b10a59ed17ea30be 100644 (file)
@@ -22,7 +22,7 @@ static int tobermory_set_bias_level(struct snd_soc_card *card,
        struct snd_soc_dai *codec_dai;
        int ret;
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
        codec_dai = rtd->codec_dai;
 
        if (dapm->dev != codec_dai->dev)
@@ -65,7 +65,7 @@ static int tobermory_set_bias_level_post(struct snd_soc_card *card,
        struct snd_soc_dai *codec_dai;
        int ret;
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
        codec_dai = rtd->codec_dai;
 
        if (dapm->dev != codec_dai->dev)
@@ -180,7 +180,7 @@ static int tobermory_late_probe(struct snd_soc_card *card)
        struct snd_soc_dai *codec_dai;
        int ret;
 
-       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
        component = rtd->codec_dai->component;
        codec_dai = rtd->codec_dai;
 
index f215a37fd3d6be85f89702123ef31c88c14a1150..9ee7d5d118c01f6ca57d76bfb219f9ddb8b5d743 100644 (file)
@@ -393,15 +393,15 @@ static const struct snd_soc_ops null_snd_soc_ops;
 
 struct snd_soc_pcm_runtime
 *snd_soc_get_pcm_runtime(struct snd_soc_card *card,
-                        const char *dai_link)
+                        struct snd_soc_dai_link *dai_link)
 {
        struct snd_soc_pcm_runtime *rtd;
 
        for_each_card_rtds(card, rtd) {
-               if (!strcmp(rtd->dai_link->name, dai_link))
+               if (rtd->dai_link == dai_link)
                        return rtd;
        }
-       dev_dbg(card->dev, "ASoC: failed to find rtd %s\n", dai_link);
+       dev_dbg(card->dev, "ASoC: failed to find rtd %s\n", dai_link->name);
        return NULL;
 }
 EXPORT_SYMBOL_GPL(snd_soc_get_pcm_runtime);
@@ -1064,7 +1064,7 @@ void snd_soc_remove_dai_link(struct snd_soc_card *card,
        if (card->remove_dai_link)
                card->remove_dai_link(card, dai_link);
 
-       rtd = snd_soc_get_pcm_runtime(card, dai_link->name);
+       rtd = snd_soc_get_pcm_runtime(card, dai_link);
        if (rtd)
                soc_free_pcm_runtime(rtd);
 }
index 6211dfda21957e027440febbb89cf997872b1d99..f08d3489c3cf3148ab00dc2f45d7066d15f38af3 100644 (file)
@@ -186,7 +186,7 @@ static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd)
 static int tegra_wm8903_remove(struct snd_soc_card *card)
 {
        struct snd_soc_pcm_runtime *rtd =
-               snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+               snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
        struct snd_soc_dai *codec_dai = rtd->codec_dai;
        struct snd_soc_component *component = codec_dai->component;