diff options
author | Axel Lin <axel.lin@gmail.com> | 2011-09-03 01:41:47 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-09-04 11:53:39 -0400 |
commit | 7b4615ba8108649ed30804450eb054925e347ad3 (patch) | |
tree | 219fb27c95e59605767d856a009b42596f184ae2 /sound | |
parent | efd614ac067a30b5541640e89d08f7afa7601f24 (diff) |
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: Axel Lin <axel.lin@gmail.com>
Acked-by: Vinod Koul <vinod.koul@linux.intel.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/codecs/sn95031.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/sound/soc/codecs/sn95031.c b/sound/soc/codecs/sn95031.c index 84ffdebb8a8b..b4f1cb494ffc 100644 --- a/sound/soc/codecs/sn95031.c +++ b/sound/soc/codecs/sn95031.c | |||
@@ -79,7 +79,7 @@ static void configure_adc(struct snd_soc_codec *sn95031_codec, int val) | |||
79 | */ | 79 | */ |
80 | static int find_free_channel(struct snd_soc_codec *sn95031_codec) | 80 | static int find_free_channel(struct snd_soc_codec *sn95031_codec) |
81 | { | 81 | { |
82 | int ret = 0, i, value; | 82 | int i, value; |
83 | 83 | ||
84 | /* check whether ADC is enabled */ | 84 | /* check whether ADC is enabled */ |
85 | value = snd_soc_read(sn95031_codec, SN95031_ADC1CNTL1); | 85 | value = snd_soc_read(sn95031_codec, SN95031_ADC1CNTL1); |
@@ -91,12 +91,10 @@ static int find_free_channel(struct snd_soc_codec *sn95031_codec) | |||
91 | for (i = 0; i < SN95031_ADC_CHANLS_MAX; i++) { | 91 | for (i = 0; i < SN95031_ADC_CHANLS_MAX; i++) { |
92 | value = snd_soc_read(sn95031_codec, | 92 | value = snd_soc_read(sn95031_codec, |
93 | SN95031_ADC_CHNL_START_ADDR + i); | 93 | SN95031_ADC_CHNL_START_ADDR + i); |
94 | if (value & SN95031_STOPBIT_MASK) { | 94 | if (value & SN95031_STOPBIT_MASK) |
95 | ret = i; | ||
96 | break; | 95 | break; |
97 | } | ||
98 | } | 96 | } |
99 | return (ret > SN95031_ADC_LOOP_MAX) ? (-EINVAL) : ret; | 97 | return (i == SN95031_ADC_CHANLS_MAX) ? (-EINVAL) : i; |
100 | } | 98 | } |
101 | 99 | ||
102 | /* Initialize the ADC for reading micbias values. Can sleep. */ | 100 | /* Initialize the ADC for reading micbias values. Can sleep. */ |