Commit 7b4615ba authored by Axel Lin's avatar Axel Lin Committed by Mark Brown

ASoC: sn95031: Fix the logic to find free channel

In the case of no free channel available,
current implementation returns 0 instead of negative errno.

This patch fixes the logic to return -EINVAL if no free channel available.
Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Acked-by: default avatarVinod Koul <vinod.koul@linux.intel.com>
Acked-by: default avatarLiam Girdwood <lrg@ti.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent efd614ac
...@@ -79,7 +79,7 @@ static void configure_adc(struct snd_soc_codec *sn95031_codec, int val) ...@@ -79,7 +79,7 @@ static void configure_adc(struct snd_soc_codec *sn95031_codec, int val)
*/ */
static int find_free_channel(struct snd_soc_codec *sn95031_codec) static int find_free_channel(struct snd_soc_codec *sn95031_codec)
{ {
int ret = 0, i, value; int i, value;
/* check whether ADC is enabled */ /* check whether ADC is enabled */
value = snd_soc_read(sn95031_codec, SN95031_ADC1CNTL1); value = snd_soc_read(sn95031_codec, SN95031_ADC1CNTL1);
...@@ -91,12 +91,10 @@ static int find_free_channel(struct snd_soc_codec *sn95031_codec) ...@@ -91,12 +91,10 @@ static int find_free_channel(struct snd_soc_codec *sn95031_codec)
for (i = 0; i < SN95031_ADC_CHANLS_MAX; i++) { for (i = 0; i < SN95031_ADC_CHANLS_MAX; i++) {
value = snd_soc_read(sn95031_codec, value = snd_soc_read(sn95031_codec,
SN95031_ADC_CHNL_START_ADDR + i); SN95031_ADC_CHNL_START_ADDR + i);
if (value & SN95031_STOPBIT_MASK) { if (value & SN95031_STOPBIT_MASK)
ret = i;
break; break;
}
} }
return (ret > SN95031_ADC_LOOP_MAX) ? (-EINVAL) : ret; return (i == SN95031_ADC_CHANLS_MAX) ? (-EINVAL) : i;
} }
/* Initialize the ADC for reading micbias values. Can sleep. */ /* Initialize the ADC for reading micbias values. Can sleep. */
......
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