Skip to content

Commit

Permalink
ASoC: soc-core: find rtd via dai_link pointer at snd_soc_get_pcm_runt…
Browse files Browse the repository at this point in the history
…ime()

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 <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Reviewed-by: Pierre-Louis Bossart <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
morimoto authored and broonie committed Dec 10, 2019
1 parent 94def8e commit 4468189
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion include/sound/soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/fsl/fsl-asoc-card.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/pxa/mioa701_wm9713.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
12 changes: 6 additions & 6 deletions sound/soc/samsung/bells.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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;

Expand Down
10 changes: 5 additions & 5 deletions sound/soc/samsung/littlemill.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/samsung/snow.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions sound/soc/samsung/speyside.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions sound/soc/samsung/tm2_wm5110.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions sound/soc/samsung/tobermory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/tegra/tegra_wm8903.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 4468189

Please sign in to comment.