From: "Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>
To: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
Mark Brown <broonie@kernel.org>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>
Subject: Re: [PATCH 4/5] ASoC: soc-pcm.c: use temporary variable at soc_get_playback_capture()
Date: Tue, 30 May 2023 16:45:10 +0200 [thread overview]
Message-ID: <13b6c019-1034-4f59-4d8f-fb9f478b7764@linux.intel.com> (raw)
In-Reply-To: <87ttvuzlqe.wl-kuninori.morimoto.gx@renesas.com>
On 5/30/2023 2:50 AM, Kuninori Morimoto wrote:
> soc_get_playback_capture() (A) returns number of substreams for
> playback/capture (B).
>
> (A) static int soc_get_playback_capture(...,
> (B) int *playback, int *capture)
> {
> ...
> for_each_xxx(...) {
> if (xxx)
> return -EINVAL;
> => *playback = 1;
> ...
> => *capture = 1;
> ...
> }
> ...
> }
>
> But, it is directly updating playback/capture which is the result of this
> function even though it might be error. It should be updated in case of
> succeed only. This patch updates it.
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
> sound/soc/soc-pcm.c | 27 ++++++++++++++++-----------
> 1 file changed, 16 insertions(+), 11 deletions(-)
>
> diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
> index 47da3be0ff46..b3d569e7ba61 100644
> --- a/sound/soc/soc-pcm.c
> +++ b/sound/soc/soc-pcm.c
> @@ -2733,6 +2733,8 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
> {
> struct snd_soc_dai_link *dai_link = rtd->dai_link;
> struct snd_soc_dai *cpu_dai;
> + int has_playback = 0;
> + int has_capture = 0;
> int i;
>
> if (dai_link->dynamic && dai_link->num_cpus > 1) {
> @@ -2748,11 +2750,11 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
>
> for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
> if (snd_soc_dai_stream_valid(cpu_dai, stream)) {
> - *playback = 1;
> + has_playback = 1;
> break;
> }
> }
> - if (!*playback) {
> + if (!has_playback) {
> dev_err(rtd->card->dev,
> "No CPU DAIs support playback for stream %s\n",
> dai_link->stream_name);
> @@ -2764,12 +2766,12 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
>
> for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
> if (snd_soc_dai_stream_valid(cpu_dai, stream)) {
> - *capture = 1;
> + has_capture = 1;
> break;
> }
> }
>
> - if (!*capture) {
> + if (!has_capture) {
> dev_err(rtd->card->dev,
> "No CPU DAIs support capture for stream %s\n",
> dai_link->stream_name);
> @@ -2798,30 +2800,33 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,
>
> if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) &&
> snd_soc_dai_stream_valid(cpu_dai, cpu_playback))
> - *playback = 1;
> + has_playback = 1;
> if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE) &&
> snd_soc_dai_stream_valid(cpu_dai, cpu_capture))
> - *capture = 1;
> + has_capture = 1;
> }
> }
>
> if (dai_link->playback_only) {
> - *playback = 1;
> - *capture = 0;
> + has_playback = 1;
> + has_capture = 0;
> }
>
> if (dai_link->capture_only) {
> - *playback = 0;
> - *capture = 1;
> + has_playback = 0;
> + has_capture = 1;
> }
>
> - if (!*playback && !*capture) {
> + if (!has_playback && !has_capture) {
> dev_err(rtd->dev, "substream %s has no playback, no capture\n",
> dai_link->stream_name);
>
> return -EINVAL;
> }
>
> + *playback = has_playback;
> + *capture = has_capture;
> +
> return 0;
> }
>
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
next prev parent reply other threads:[~2023-05-30 14:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-30 0:49 [PATCH 0/5] ASoC: minor cleanup for soc_get_playback_capture() Kuninori Morimoto
2023-05-30 0:49 ` [PATCH 1/5] ASoC: soc-pcm.c: indicate error if stream has no playback no capture Kuninori Morimoto
2023-05-30 0:49 ` [PATCH 2/5] ASoC: soc-pcm.c: use dai_link on soc_get_playback_capture() Kuninori Morimoto
2023-05-30 0:49 ` [PATCH 3/5] ASoC: soc-pcm.c: cleanup soc_get_playback_capture() error Kuninori Morimoto
2023-05-30 0:50 ` [PATCH 4/5] ASoC: soc-pcm.c: use temporary variable at soc_get_playback_capture() Kuninori Morimoto
2023-05-30 14:45 ` Amadeusz Sławiński [this message]
2023-05-30 0:50 ` [PATCH 5/5] ASoC: soc-pcm.c: tidyup playback/capture_only " Kuninori Morimoto
2023-05-30 19:50 ` [PATCH 0/5] ASoC: minor cleanup for soc_get_playback_capture() Pierre-Louis Bossart
2023-05-31 15:38 ` 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=13b6c019-1034-4f59-4d8f-fb9f478b7764@linux.intel.com \
--to=amadeuszx.slawinski@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=kuninori.morimoto.gx@renesas.com \
/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