Skip to content

Commit

Permalink
ASoC: rockchip: i2s-tdm: Fix refcount test
Browse files Browse the repository at this point in the history
During development of V5 of the i2s-tdm patch series, I replaced
the atomic refcount with a regular integer, as it was only ever
accessed within a spinlock.

Foolishly, I got the semantics of atomic_dec_and_test wrong, which
resulted in a test for 0 actually becoming a test for >0.

The result was that setting the audio frequency broke; switching
from 44100 Hz audio playback to 96000 Hz audio playback would
garble the sound most unpleasantly.

Fix this by checking for --refcount == 0, which is what it should
have been all along.

Fixes: 081068f ("ASoC: rockchip: add support for i2s-tdm controller")
Signed-off-by: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
Link: https://lore.kernel.org/r/20211015210730.308946-1-frattaroli.nicolas@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Nicolas Frattaroli authored and Mark Brown committed Oct 18, 2021
1 parent bc38788 commit 0ea15e9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sound/soc/rockchip/rockchip_i2s_tdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ static void rockchip_snd_txrxctrl(struct snd_pcm_substream *substream,
else
rockchip_disable_rde(i2s_tdm->regmap);

if (--i2s_tdm->refcount) {
if (--i2s_tdm->refcount == 0) {
rockchip_snd_xfer_clear(i2s_tdm,
I2S_CLR_TXC | I2S_CLR_RXC);
}
Expand Down

0 comments on commit 0ea15e9

Please sign in to comment.