aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/ad1980.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-05-20 08:23:10 -0400
committerMark Brown <broonie@linaro.org>2014-05-20 17:53:36 -0400
commitcf7b71f46b1c2f0376c373e10e5eee1b1fa3cd12 (patch)
tree9977d42924c430011cceae14fc4f2c5a522e8394 /sound/soc/codecs/ad1980.c
parentc9eaa447e77efe77b7fa4c953bd62de8297fd6c5 (diff)
ASoC: ad1980: Replace goto loop with do-while loop
Using a proper do-while loop here instead of a open-coded goto loop is both cleaner and shorter. Also fixes the following warnings from smatch: sound/soc/codecs/ad1980.c:213 ad1980_reset() info: loop could be replaced with if statement. sound/soc/codecs/ad1980.c:212 ad1980_reset() info: ignoring unreachable code. sound/soc/codecs/ad1980.c:215 ad1980_reset() info: ignoring unreachable code. While we are at it also change retry_cnt to unsigned int, using u16 for a on-stack loop counter doesn't make that much sense. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/codecs/ad1980.c')
-rw-r--r--sound/soc/codecs/ad1980.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/sound/soc/codecs/ad1980.c b/sound/soc/codecs/ad1980.c
index 34d965a4a040..304d3003339a 100644
--- a/sound/soc/codecs/ad1980.c
+++ b/sound/soc/codecs/ad1980.c
@@ -189,28 +189,27 @@ static struct snd_soc_dai_driver ad1980_dai = {
189 189
190static int ad1980_reset(struct snd_soc_codec *codec, int try_warm) 190static int ad1980_reset(struct snd_soc_codec *codec, int try_warm)
191{ 191{
192 u16 retry_cnt = 0; 192 unsigned int retry_cnt = 0;
193 193
194retry: 194 do {
195 if (try_warm && soc_ac97_ops->warm_reset) { 195 if (try_warm && soc_ac97_ops->warm_reset) {
196 soc_ac97_ops->warm_reset(codec->ac97); 196 soc_ac97_ops->warm_reset(codec->ac97);
197 if (ac97_read(codec, AC97_RESET) == 0x0090) 197 if (ac97_read(codec, AC97_RESET) == 0x0090)
198 return 1; 198 return 1;
199 } 199 }
200
201 soc_ac97_ops->reset(codec->ac97);
202 /* Set bit 16slot in register 74h, then every slot will has only 16
203 * bits. This command is sent out in 20bit mode, in which case the
204 * first nibble of data is eaten by the addr. (Tag is always 16 bit)*/
205 ac97_write(codec, AC97_AD_SERIAL_CFG, 0x9900);
206
207 if (ac97_read(codec, AC97_RESET) != 0x0090)
208 goto err;
209 return 0;
210 200
211err: 201 soc_ac97_ops->reset(codec->ac97);
212 while (retry_cnt++ < 10) 202 /*
213 goto retry; 203 * Set bit 16slot in register 74h, then every slot will has only
204 * 16 bits. This command is sent out in 20bit mode, in which
205 * case the first nibble of data is eaten by the addr. (Tag is
206 * always 16 bit)
207 */
208 ac97_write(codec, AC97_AD_SERIAL_CFG, 0x9900);
209
210 if (ac97_read(codec, AC97_RESET) == 0x0090)
211 return 0;
212 } while (retry_cnt++ < 10);
214 213
215 printk(KERN_ERR "AD1980 AC97 reset failed\n"); 214 printk(KERN_ERR "AD1980 AC97 reset failed\n");
216 return -EIO; 215 return -EIO;