linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RFC] ASoC: pcm: Trigger all commands on error
@ 2013-10-04 10:53 Markus Pargmann
  2013-10-07 17:27 ` Mark Brown
  0 siblings, 1 reply; 13+ messages in thread
From: Markus Pargmann @ 2013-10-04 10:53 UTC (permalink / raw)
  To: linux-arm-kernel

If a start command is triggered and an error occures in the first called
function, e.g. DMA, all other functions are not executed and the error
value is returned immediately.

In case of a start command, the calling function will call undo_start,
calling this trigger function with the stop command. It will call stop
for each function. But only the first function was started previously.
The other functions may fail in the assumption that a stop command
always comes after a start command.

As the API does not specify the behaviour of trigger functionpointers, I
think this should be fixed in the function calling the trigger
functionpointers.

This patch changes the behaviour. The trigger function calls all
functionpointers independent of their returncodes. The first error-code
is returned.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
 sound/soc/soc-pcm.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 330c9a6..23fc25b 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -616,26 +616,28 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	int ret;
+	int ret = 0;
+	int err = 0;
 
 	if (codec_dai->driver->ops->trigger) {
 		ret = codec_dai->driver->ops->trigger(substream, cmd, codec_dai);
-		if (ret < 0)
-			return ret;
+		if (!err && ret)
+			err = ret;
 	}
 
 	if (platform->driver->ops && platform->driver->ops->trigger) {
 		ret = platform->driver->ops->trigger(substream, cmd);
-		if (ret < 0)
-			return ret;
+		if (!err && ret)
+			err = ret;
 	}
 
 	if (cpu_dai->driver->ops->trigger) {
 		ret = cpu_dai->driver->ops->trigger(substream, cmd, cpu_dai);
-		if (ret < 0)
-			return ret;
+		if (!err && ret)
+			err = ret;
 	}
-	return 0;
+
+	return err;
 }
 
 static int soc_pcm_bespoke_trigger(struct snd_pcm_substream *substream,
-- 
1.8.4.rc3

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-10-10 12:35 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-04 10:53 [RFC] ASoC: pcm: Trigger all commands on error Markus Pargmann
2013-10-07 17:27 ` Mark Brown
2013-10-08  8:29   ` Markus Pargmann
2013-10-08  9:34     ` Mark Brown
2013-10-08  9:48       ` Markus Pargmann
2013-10-08 10:44         ` Mark Brown
2013-10-09 13:05           ` Markus Pargmann
2013-10-09 13:20             ` Mark Brown
2013-10-09 14:12               ` Markus Pargmann
2013-10-09 14:59                 ` Mark Brown
2013-10-10  8:40                   ` Markus Pargmann
2013-10-10 12:35                     ` Mark Brown
     [not found]                 ` <1381329076-12022-1-git-send-email-mpa@pengutronix.de>
2013-10-09 18:22                   ` [alsa-devel] [RFC v2] ASoC: pcm: Store component running state Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).