diff options
author | Shengjiu Wang <shengjiu.wang@nxp.com> | 2019-07-04 15:29:57 +0800 |
---|---|---|
committer | Dong Aisheng <aisheng.dong@nxp.com> | 2019-11-25 15:48:43 +0800 |
commit | 2ca6909313e86735557e53f086499eed8038b517 (patch) | |
tree | 08d10163b0b9731c8cc0ed5018bb6663a40d3186 /sound/soc/fsl/fsl_easrc.c | |
parent | d1d594749325328e72dd61bff1dbd43108d17d27 (diff) |
MLK-22168: fsl_easrc:Add error handle for format check
Add error handler for format check, if the format is not supported
should return error, otherwise it cause "input DMA task timeout"
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Viorel Suman <viorel.suman@nxp.com>
Diffstat (limited to 'sound/soc/fsl/fsl_easrc.c')
-rw-r--r-- | sound/soc/fsl/fsl_easrc.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/sound/soc/fsl/fsl_easrc.c b/sound/soc/fsl/fsl_easrc.c index 859827517797..49b7fc7e083b 100644 --- a/sound/soc/fsl/fsl_easrc.c +++ b/sound/soc/fsl/fsl_easrc.c @@ -1154,12 +1154,14 @@ int fsl_easrc_config_context(struct fsl_easrc *easrc, unsigned int ctx_id) return ret; } -void fsl_easrc_process_format(struct fsl_easrc *easrc, +static int fsl_easrc_process_format(struct fsl_easrc *easrc, struct fsl_easrc_data_fmt *fmt, snd_pcm_format_t raw_fmt) { + int ret; + if (!fmt) - return; + return -EINVAL; /* Context Input Floating Point Format * 0 - Integer Format @@ -1183,6 +1185,8 @@ void fsl_easrc_process_format(struct fsl_easrc *easrc, case 32: fmt->width = EASRC_WIDTH_32_BIT; break; + default: + return -EINVAL; } switch (raw_fmt) { @@ -1205,12 +1209,22 @@ void fsl_easrc_process_format(struct fsl_easrc *easrc, * 0 - Little-Endian * 1 - Big-Endian */ - fmt->endianness = snd_pcm_format_big_endian(raw_fmt); + ret = snd_pcm_format_big_endian(raw_fmt); + if (ret < 0) + return ret; + + fmt->endianness = ret; /* Input Data sign * 0b - Signed Format * 1b - Unsigned Format */ - fmt->unsign = snd_pcm_format_unsigned(raw_fmt) > 0 ? 1 : 0; + ret = snd_pcm_format_unsigned(raw_fmt) > 0 ? 1 : 0; + if (ret < 0) + return ret; + + fmt->unsign = ret; + + return 0; } int fsl_easrc_set_ctx_format(struct fsl_easrc_context *ctx, @@ -1223,8 +1237,11 @@ int fsl_easrc_set_ctx_format(struct fsl_easrc_context *ctx, int ret; /* get the bitfield values for input data format */ - if (in_raw_format && out_raw_format) - fsl_easrc_process_format(easrc, in_fmt, *in_raw_format); + if (in_raw_format && out_raw_format) { + ret = fsl_easrc_process_format(easrc, in_fmt, *in_raw_format); + if (ret) + return ret; + } ret = regmap_update_bits(easrc->regmap, REG_EASRC_CC(ctx->index), @@ -1261,8 +1278,11 @@ int fsl_easrc_set_ctx_format(struct fsl_easrc_context *ctx, return ret; /* get the bitfield values for input data format */ - if (in_raw_format && out_raw_format) - fsl_easrc_process_format(easrc, out_fmt, *out_raw_format); + if (in_raw_format && out_raw_format) { + ret = fsl_easrc_process_format(easrc, out_fmt, *out_raw_format); + if (ret) + return ret; + } ret = regmap_update_bits(easrc->regmap, REG_EASRC_COC(ctx->index), |