Commit db3aa39c authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: soc-pcm: indicate error message at dpcm_be_dai_trigger()

Indicating error message when failed case is very useful for debuging.
In many case, its style is like below.

	int function(...)
	{
		...
		return ret;
	}

	int caller(...)
	{
		...
		ret = function(...);
		if (ret < 0)
			dev_err(...)
		...
	}

This is not so bad, but in this style *each caller* needs to indicate
duplicate same error message, and some caller is forgetting to do it.
And caller can't indicate detail function() error information.

If function() indicates error message, we can get same and
detail information without forgot.

	int function(...)
	{
		...
		if (ret < 0)
			dev_err(...)

		return ret;
	}

	int caller(...)
	{
		...
		ret = function(...);
		...
	}

Now, dpcm_be_dai_trigger() user uses it like below.

	err = dpcm_be_dai_trigger(...);
	if (err < 0)
		dev_err(..., "ASoC: trigger FE failed %d\n", err);

But we can get more detail information if dpcm_be_dai_trigger() itself
had dev_err(). And above error message is confusable,
failed is *BE*, not *FE*.

This patch indicates error message at dpcm_be_dai_trigger().
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87lfaputbe.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent d479f00b
...@@ -1985,14 +1985,15 @@ static int dpcm_fe_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -1985,14 +1985,15 @@ static int dpcm_fe_dai_hw_params(struct snd_pcm_substream *substream,
int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
int cmd) int cmd)
{ {
struct snd_soc_pcm_runtime *be;
struct snd_soc_dpcm *dpcm; struct snd_soc_dpcm *dpcm;
int ret = 0; int ret = 0;
for_each_dpcm_be(fe, stream, dpcm) { for_each_dpcm_be(fe, stream, dpcm) {
struct snd_pcm_substream *be_substream;
struct snd_soc_pcm_runtime *be = dpcm->be; be = dpcm->be;
struct snd_pcm_substream *be_substream = be_substream = snd_soc_dpcm_get_substream(be, stream);
snd_soc_dpcm_get_substream(be, stream);
/* is this op for this BE ? */ /* is this op for this BE ? */
if (!snd_soc_dpcm_be_can_update(fe, be, stream)) if (!snd_soc_dpcm_be_can_update(fe, be, stream))
...@@ -2010,7 +2011,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, ...@@ -2010,7 +2011,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
ret = soc_pcm_trigger(be_substream, cmd); ret = soc_pcm_trigger(be_substream, cmd);
if (ret) if (ret)
return ret; goto end;
be->dpcm[stream].state = SND_SOC_DPCM_STATE_START; be->dpcm[stream].state = SND_SOC_DPCM_STATE_START;
break; break;
...@@ -2020,7 +2021,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, ...@@ -2020,7 +2021,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
ret = soc_pcm_trigger(be_substream, cmd); ret = soc_pcm_trigger(be_substream, cmd);
if (ret) if (ret)
return ret; goto end;
be->dpcm[stream].state = SND_SOC_DPCM_STATE_START; be->dpcm[stream].state = SND_SOC_DPCM_STATE_START;
break; break;
...@@ -2030,7 +2031,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, ...@@ -2030,7 +2031,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
ret = soc_pcm_trigger(be_substream, cmd); ret = soc_pcm_trigger(be_substream, cmd);
if (ret) if (ret)
return ret; goto end;
be->dpcm[stream].state = SND_SOC_DPCM_STATE_START; be->dpcm[stream].state = SND_SOC_DPCM_STATE_START;
break; break;
...@@ -2044,7 +2045,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, ...@@ -2044,7 +2045,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
ret = soc_pcm_trigger(be_substream, cmd); ret = soc_pcm_trigger(be_substream, cmd);
if (ret) if (ret)
return ret; goto end;
be->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; be->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP;
break; break;
...@@ -2057,7 +2058,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, ...@@ -2057,7 +2058,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
ret = soc_pcm_trigger(be_substream, cmd); ret = soc_pcm_trigger(be_substream, cmd);
if (ret) if (ret)
return ret; goto end;
be->dpcm[stream].state = SND_SOC_DPCM_STATE_SUSPEND; be->dpcm[stream].state = SND_SOC_DPCM_STATE_SUSPEND;
break; break;
...@@ -2070,13 +2071,16 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, ...@@ -2070,13 +2071,16 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
ret = soc_pcm_trigger(be_substream, cmd); ret = soc_pcm_trigger(be_substream, cmd);
if (ret) if (ret)
return ret; goto end;
be->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; be->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED;
break; break;
} }
} }
end:
if (ret < 0)
dev_err(fe->dev, "ASoC: %s() failed at %s (%d)\n",
__func__, be->dai_link->name, ret);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(dpcm_be_dai_trigger); EXPORT_SYMBOL_GPL(dpcm_be_dai_trigger);
...@@ -2310,8 +2314,6 @@ static int dpcm_run_update_shutdown(struct snd_soc_pcm_runtime *fe, int stream) ...@@ -2310,8 +2314,6 @@ static int dpcm_run_update_shutdown(struct snd_soc_pcm_runtime *fe, int stream)
fe->dai_link->name); fe->dai_link->name);
err = dpcm_be_dai_trigger(fe, stream, SNDRV_PCM_TRIGGER_STOP); err = dpcm_be_dai_trigger(fe, stream, SNDRV_PCM_TRIGGER_STOP);
if (err < 0)
dev_err(fe->dev,"ASoC: trigger FE failed %d\n", err);
} }
err = dpcm_be_dai_hw_free(fe, stream); err = dpcm_be_dai_hw_free(fe, stream);
...@@ -2393,11 +2395,9 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream) ...@@ -2393,11 +2395,9 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream)
ret = dpcm_be_dai_trigger(fe, stream, ret = dpcm_be_dai_trigger(fe, stream,
SNDRV_PCM_TRIGGER_START); SNDRV_PCM_TRIGGER_START);
if (ret < 0) { if (ret < 0)
dev_err(fe->dev,"ASoC: trigger FE failed %d\n", ret);
goto hw_free; goto hw_free;
} }
}
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment