mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 06:31:49 +00:00
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: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87lfaputbe.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
d479f00b79
commit
db3aa39c91
@ -1985,14 +1985,15 @@ out:
|
||||
int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
|
||||
int cmd)
|
||||
{
|
||||
struct snd_soc_pcm_runtime *be;
|
||||
struct snd_soc_dpcm *dpcm;
|
||||
int ret = 0;
|
||||
|
||||
for_each_dpcm_be(fe, stream, dpcm) {
|
||||
struct snd_pcm_substream *be_substream;
|
||||
|
||||
struct snd_soc_pcm_runtime *be = dpcm->be;
|
||||
struct snd_pcm_substream *be_substream =
|
||||
snd_soc_dpcm_get_substream(be, stream);
|
||||
be = dpcm->be;
|
||||
be_substream = snd_soc_dpcm_get_substream(be, stream);
|
||||
|
||||
/* is this op for this BE ? */
|
||||
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,
|
||||
|
||||
ret = soc_pcm_trigger(be_substream, cmd);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
be->dpcm[stream].state = SND_SOC_DPCM_STATE_START;
|
||||
break;
|
||||
@ -2020,7 +2021,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
|
||||
|
||||
ret = soc_pcm_trigger(be_substream, cmd);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
be->dpcm[stream].state = SND_SOC_DPCM_STATE_START;
|
||||
break;
|
||||
@ -2030,7 +2031,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
|
||||
|
||||
ret = soc_pcm_trigger(be_substream, cmd);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
be->dpcm[stream].state = SND_SOC_DPCM_STATE_START;
|
||||
break;
|
||||
@ -2044,7 +2045,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
|
||||
|
||||
ret = soc_pcm_trigger(be_substream, cmd);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
be->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP;
|
||||
break;
|
||||
@ -2057,7 +2058,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
|
||||
|
||||
ret = soc_pcm_trigger(be_substream, cmd);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
be->dpcm[stream].state = SND_SOC_DPCM_STATE_SUSPEND;
|
||||
break;
|
||||
@ -2070,13 +2071,16 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
|
||||
|
||||
ret = soc_pcm_trigger(be_substream, cmd);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
be->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
if (ret < 0)
|
||||
dev_err(fe->dev, "ASoC: %s() failed at %s (%d)\n",
|
||||
__func__, be->dai_link->name, ret);
|
||||
return ret;
|
||||
}
|
||||
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)
|
||||
fe->dai_link->name);
|
||||
|
||||
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);
|
||||
@ -2393,10 +2395,8 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream)
|
||||
|
||||
ret = dpcm_be_dai_trigger(fe, stream,
|
||||
SNDRV_PCM_TRIGGER_START);
|
||||
if (ret < 0) {
|
||||
dev_err(fe->dev,"ASoC: trigger FE failed %d\n", ret);
|
||||
if (ret < 0)
|
||||
goto hw_free;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user