Commit fe839119 authored by Mark Brown's avatar Mark Brown

ASoC: mediatek: fix coverity problems

Merge series from Trevor Wu <trevor.wu@mediatek.com>:

Coverity reports some UNINIT and CERT STR31-C problems, so we add
initialization and dai id check to resolve problems.
parents da1f2282 3a60fa4c
...@@ -429,7 +429,7 @@ static int mt6358_put_volsw(struct snd_kcontrol *kcontrol, ...@@ -429,7 +429,7 @@ static int mt6358_put_volsw(struct snd_kcontrol *kcontrol,
struct mt6358_priv *priv = snd_soc_component_get_drvdata(component); struct mt6358_priv *priv = snd_soc_component_get_drvdata(component);
struct soc_mixer_control *mc = struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value; (struct soc_mixer_control *)kcontrol->private_value;
unsigned int reg; unsigned int reg = 0;
int ret; int ret;
ret = snd_soc_put_volsw(kcontrol, ucontrol); ret = snd_soc_put_volsw(kcontrol, ucontrol);
......
...@@ -358,7 +358,7 @@ static int mt6359_put_volsw(struct snd_kcontrol *kcontrol, ...@@ -358,7 +358,7 @@ static int mt6359_put_volsw(struct snd_kcontrol *kcontrol,
struct mt6359_priv *priv = snd_soc_component_get_drvdata(component); struct mt6359_priv *priv = snd_soc_component_get_drvdata(component);
struct soc_mixer_control *mc = struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value; (struct soc_mixer_control *)kcontrol->private_value;
unsigned int reg; unsigned int reg = 0;
int index = ucontrol->value.integer.value[0]; int index = ucontrol->value.integer.value[0];
int ret; int ret;
......
...@@ -704,13 +704,18 @@ static int mtk_dai_adda_hw_params(struct snd_pcm_substream *substream, ...@@ -704,13 +704,18 @@ static int mtk_dai_adda_hw_params(struct snd_pcm_substream *substream,
{ {
struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
struct mt8195_afe_private *afe_priv = afe->platform_priv; struct mt8195_afe_private *afe_priv = afe->platform_priv;
struct mtk_dai_adda_priv *adda_priv = afe_priv->dai_priv[dai->id]; struct mtk_dai_adda_priv *adda_priv;
unsigned int rate = params_rate(params); unsigned int rate = params_rate(params);
int id = dai->id; int ret;
int ret = 0;
if (dai->id != MT8195_AFE_IO_DL_SRC &&
dai->id != MT8195_AFE_IO_UL_SRC1 &&
dai->id != MT8195_AFE_IO_UL_SRC2)
return -EINVAL;
adda_priv = afe_priv->dai_priv[dai->id];
dev_dbg(afe->dev, "%s(), id %d, stream %d, rate %d\n", dev_dbg(afe->dev, "%s(), id %d, stream %d, rate %d\n",
__func__, id, substream->stream, rate); __func__, dai->id, substream->stream, rate);
if (rate > ADDA_HIRES_THRES) if (rate > ADDA_HIRES_THRES)
adda_priv->hires_required = 1; adda_priv->hires_required = 1;
...@@ -718,9 +723,9 @@ static int mtk_dai_adda_hw_params(struct snd_pcm_substream *substream, ...@@ -718,9 +723,9 @@ static int mtk_dai_adda_hw_params(struct snd_pcm_substream *substream,
adda_priv->hires_required = 0; adda_priv->hires_required = 0;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
ret = mtk_dai_da_configure(afe, rate, id); ret = mtk_dai_da_configure(afe, rate, dai->id);
else else
ret = mtk_dai_ad_configure(afe, rate, id); ret = mtk_dai_ad_configure(afe, rate, dai->id);
return ret; return ret;
} }
......
This diff is collapsed.
...@@ -122,17 +122,26 @@ static int mtk_dai_pcm_configure(struct snd_pcm_substream *substream, ...@@ -122,17 +122,26 @@ static int mtk_dai_pcm_configure(struct snd_pcm_substream *substream,
struct snd_pcm_runtime * const runtime = substream->runtime; struct snd_pcm_runtime * const runtime = substream->runtime;
struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
struct mt8195_afe_private *afe_priv = afe->platform_priv; struct mt8195_afe_private *afe_priv = afe->platform_priv;
struct mtk_dai_pcmif_priv *pcmif_priv = afe_priv->dai_priv[dai->id]; struct mtk_dai_pcmif_priv *pcmif_priv;
unsigned int slave_mode = pcmif_priv->slave_mode; unsigned int slave_mode;
unsigned int lrck_inv = pcmif_priv->lrck_inv; unsigned int lrck_inv;
unsigned int bck_inv = pcmif_priv->bck_inv; unsigned int bck_inv;
unsigned int fmt = pcmif_priv->format; unsigned int fmt;
unsigned int bit_width = dai->sample_bits; unsigned int bit_width = dai->sample_bits;
unsigned int val = 0; unsigned int val = 0;
unsigned int mask = 0; unsigned int mask = 0;
int fs = 0; int fs = 0;
int mode = 0; int mode = 0;
if (dai->id != MT8195_AFE_IO_PCM)
return -EINVAL;
pcmif_priv = afe_priv->dai_priv[dai->id];
slave_mode = pcmif_priv->slave_mode;
lrck_inv = pcmif_priv->lrck_inv;
bck_inv = pcmif_priv->bck_inv;
fmt = pcmif_priv->format;
/* sync freq mode */ /* sync freq mode */
fs = mt8195_afe_fs_timing(runtime->rate); fs = mt8195_afe_fs_timing(runtime->rate);
if (fs < 0) if (fs < 0)
...@@ -230,10 +239,15 @@ static int mtk_dai_pcm_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -230,10 +239,15 @@ static int mtk_dai_pcm_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ {
struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
struct mt8195_afe_private *afe_priv = afe->platform_priv; struct mt8195_afe_private *afe_priv = afe->platform_priv;
struct mtk_dai_pcmif_priv *pcmif_priv = afe_priv->dai_priv[dai->id]; struct mtk_dai_pcmif_priv *pcmif_priv;
dev_dbg(dai->dev, "%s fmt 0x%x\n", __func__, fmt); dev_dbg(dai->dev, "%s fmt 0x%x\n", __func__, fmt);
if (dai->id != MT8195_AFE_IO_PCM)
return -EINVAL;
pcmif_priv = afe_priv->dai_priv[dai->id];
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S: case SND_SOC_DAIFMT_I2S:
pcmif_priv->format = MTK_DAI_PCM_FMT_I2S; pcmif_priv->format = MTK_DAI_PCM_FMT_I2S;
......
...@@ -158,7 +158,7 @@ static int mt8195_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd) ...@@ -158,7 +158,7 @@ static int mt8195_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd)
int mtkaif_phase_cycle[MT8195_MTKAIF_MISO_NUM]; int mtkaif_phase_cycle[MT8195_MTKAIF_MISO_NUM];
int mtkaif_calibration_num_phase; int mtkaif_calibration_num_phase;
bool mtkaif_calibration_ok; bool mtkaif_calibration_ok;
unsigned int monitor; unsigned int monitor = 0;
int counter; int counter;
int phase; int phase;
int i; int i;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment