[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200721170007.4554-2-srinivas.kandagatla@linaro.org>
Date: Tue, 21 Jul 2020 18:00:02 +0100
From: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
To: broonie@...nel.org
Cc: vkoul@...nel.org, perex@...ex.cz, tiwai@...e.com,
lgirdwood@...il.com, alsa-devel@...a-project.org,
linux-kernel@...r.kernel.org, ckeepax@...nsource.cirrus.com,
Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
Subject: [RFC PATCH v2 1/6] ALSA: compress: move codec parameter check to a function
Move codec parameter checking to dedicated function so that other
callers do not duplicate it. This is in preparedness for adding
snd_compr_set_codec_params() support.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
---
sound/core/compress_offload.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 0e53f6f31916..af5824113246 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -566,6 +566,18 @@ static int snd_compr_allocate_buffer(struct snd_compr_stream *stream,
return 0;
}
+static int snd_compress_check_codec_params(struct snd_codec *codec)
+{
+ /* now codec parameters */
+ if (codec->id == 0 || codec->id > SND_AUDIOCODEC_MAX)
+ return -EINVAL;
+
+ if (codec->ch_in == 0 || codec->ch_out == 0)
+ return -EINVAL;
+
+ return 0;
+}
+
static int snd_compress_check_input(struct snd_compr_params *params)
{
/* first let's check the buffer parameter's */
@@ -574,14 +586,8 @@ static int snd_compress_check_input(struct snd_compr_params *params)
params->buffer.fragments == 0)
return -EINVAL;
- /* now codec parameters */
- if (params->codec.id == 0 || params->codec.id > SND_AUDIOCODEC_MAX)
- return -EINVAL;
+ return snd_compress_check_codec_params(¶ms->codec);
- if (params->codec.ch_in == 0 || params->codec.ch_out == 0)
- return -EINVAL;
-
- return 0;
}
static int
--
2.21.0
Powered by blists - more mailing lists