diff options
author | Takashi Iwai <tiwai@suse.de> | 2013-10-30 03:35:01 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-10-30 12:33:30 -0400 |
commit | 166a34d27fcad1eeb0322cff23939a1910f8a77c (patch) | |
tree | 84da6b53d0d952949de3dfcc12bfb56b0820c25c | |
parent | 00ecdd93a80fda1336bf5413b1d705c742a5b598 (diff) |
ASoC: ab8500: Fix invalid cast to long pointer
Don't cast to long pointers blindly just for using find_first_bit()
and co. This is certainly not portable at all.
Reimplement the code with ffs() and fls() instead. This is a slight
optimization, too.
Spotted by coverity CID 1056484 and 1056485.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | sound/soc/codecs/ab8500-codec.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c index 10be4cbfe969..3ef481551740 100644 --- a/sound/soc/codecs/ab8500-codec.c +++ b/sound/soc/codecs/ab8500-codec.c | |||
@@ -2295,17 +2295,17 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, | |||
2295 | case 0: | 2295 | case 0: |
2296 | break; | 2296 | break; |
2297 | case 1: | 2297 | case 1: |
2298 | slot = find_first_bit((unsigned long *)&tx_mask, 32); | 2298 | slot = ffs(tx_mask); |
2299 | snd_soc_update_bits(codec, AB8500_DASLOTCONF1, mask, slot); | 2299 | snd_soc_update_bits(codec, AB8500_DASLOTCONF1, mask, slot); |
2300 | snd_soc_update_bits(codec, AB8500_DASLOTCONF3, mask, slot); | 2300 | snd_soc_update_bits(codec, AB8500_DASLOTCONF3, mask, slot); |
2301 | snd_soc_update_bits(codec, AB8500_DASLOTCONF2, mask, slot); | 2301 | snd_soc_update_bits(codec, AB8500_DASLOTCONF2, mask, slot); |
2302 | snd_soc_update_bits(codec, AB8500_DASLOTCONF4, mask, slot); | 2302 | snd_soc_update_bits(codec, AB8500_DASLOTCONF4, mask, slot); |
2303 | break; | 2303 | break; |
2304 | case 2: | 2304 | case 2: |
2305 | slot = find_first_bit((unsigned long *)&tx_mask, 32); | 2305 | slot = ffs(tx_mask); |
2306 | snd_soc_update_bits(codec, AB8500_DASLOTCONF1, mask, slot); | 2306 | snd_soc_update_bits(codec, AB8500_DASLOTCONF1, mask, slot); |
2307 | snd_soc_update_bits(codec, AB8500_DASLOTCONF3, mask, slot); | 2307 | snd_soc_update_bits(codec, AB8500_DASLOTCONF3, mask, slot); |
2308 | slot = find_next_bit((unsigned long *)&tx_mask, 32, slot + 1); | 2308 | slot = fls(tx_mask); |
2309 | snd_soc_update_bits(codec, AB8500_DASLOTCONF2, mask, slot); | 2309 | snd_soc_update_bits(codec, AB8500_DASLOTCONF2, mask, slot); |
2310 | snd_soc_update_bits(codec, AB8500_DASLOTCONF4, mask, slot); | 2310 | snd_soc_update_bits(codec, AB8500_DASLOTCONF4, mask, slot); |
2311 | break; | 2311 | break; |
@@ -2336,18 +2336,18 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, | |||
2336 | case 0: | 2336 | case 0: |
2337 | break; | 2337 | break; |
2338 | case 1: | 2338 | case 1: |
2339 | slot = find_first_bit((unsigned long *)&rx_mask, 32); | 2339 | slot = ffs(rx_mask); |
2340 | snd_soc_update_bits(codec, AB8500_ADSLOTSEL(slot), | 2340 | snd_soc_update_bits(codec, AB8500_ADSLOTSEL(slot), |
2341 | AB8500_MASK_SLOT(slot), | 2341 | AB8500_MASK_SLOT(slot), |
2342 | AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(AB8500_AD_OUT3, slot)); | 2342 | AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(AB8500_AD_OUT3, slot)); |
2343 | break; | 2343 | break; |
2344 | case 2: | 2344 | case 2: |
2345 | slot = find_first_bit((unsigned long *)&rx_mask, 32); | 2345 | slot = ffs(rx_mask); |
2346 | snd_soc_update_bits(codec, | 2346 | snd_soc_update_bits(codec, |
2347 | AB8500_ADSLOTSEL(slot), | 2347 | AB8500_ADSLOTSEL(slot), |
2348 | AB8500_MASK_SLOT(slot), | 2348 | AB8500_MASK_SLOT(slot), |
2349 | AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(AB8500_AD_OUT3, slot)); | 2349 | AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(AB8500_AD_OUT3, slot)); |
2350 | slot = find_next_bit((unsigned long *)&rx_mask, 32, slot + 1); | 2350 | slot = fls(rx_mask); |
2351 | snd_soc_update_bits(codec, | 2351 | snd_soc_update_bits(codec, |
2352 | AB8500_ADSLOTSEL(slot), | 2352 | AB8500_ADSLOTSEL(slot), |
2353 | AB8500_MASK_SLOT(slot), | 2353 | AB8500_MASK_SLOT(slot), |