Skip to content

Commit

Permalink
ASoC: ssm2518: Fix off-by-one error by ffs()
Browse files Browse the repository at this point in the history
ffs() returns the bit position from 1, while the ssm2158 driver code
assumes it being 0-based.  Also, the bit mask computation of the two
channel slots are incorrect; it must have worked just casually.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
  • Loading branch information
Takashi Iwai authored and Mark Brown committed Jan 2, 2014
1 parent 6ce4eac commit f60e547
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sound/soc/codecs/ssm2518.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,13 +549,13 @@ static int ssm2518_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
right_slot = 0;
} else {
/* We assume the left channel < right channel */
left_slot = ffs(tx_mask);
tx_mask &= ~(1 << tx_mask);
left_slot = __ffs(tx_mask);
tx_mask &= ~(1 << left_slot);
if (tx_mask == 0) {
right_slot = left_slot;
} else {
right_slot = ffs(tx_mask);
tx_mask &= ~(1 << tx_mask);
right_slot = __ffs(tx_mask);
tx_mask &= ~(1 << right_slot);
}
}

Expand Down

0 comments on commit f60e547

Please sign in to comment.