From: mpa@pengutronix.de (Markus Pargmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC] ASoC: pcm: Trigger all commands on error
Date: Fri, 4 Oct 2013 12:53:17 +0200 [thread overview]
Message-ID: <1380883997-18236-1-git-send-email-mpa@pengutronix.de> (raw)
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
next reply other threads:[~2013-10-04 10:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-04 10:53 Markus Pargmann [this message]
2013-10-07 17:27 ` [RFC] ASoC: pcm: Trigger all commands on error 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1380883997-18236-1-git-send-email-mpa@pengutronix.de \
--to=mpa@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).