summaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/rt5677-spi.c
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2019-05-21 23:00:33 +0200
committerMark Brown <broonie@kernel.org>2019-05-21 23:00:33 +0200
commita41016e40378d19f7c9ced61856b8bed866e2dda (patch)
treed82aeb3f14ff95791ff165813fee90d3916df0aa /sound/soc/codecs/rt5677-spi.c
parentASoC: soc-pcm: fixup try_module_get()/module_put() timing (diff)
parentASoC: Intel: sof-rt5682: fix AMP quirk support (diff)
downloadlinux-a41016e40378d19f7c9ced61856b8bed866e2dda.tar.xz
linux-a41016e40378d19f7c9ced61856b8bed866e2dda.zip
Merge branch 'for-5.2' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-5.3
Diffstat (limited to 'sound/soc/codecs/rt5677-spi.c')
-rw-r--r--sound/soc/codecs/rt5677-spi.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sound/soc/codecs/rt5677-spi.c b/sound/soc/codecs/rt5677-spi.c
index 871ccb37318d..770fa09609cf 100644
--- a/sound/soc/codecs/rt5677-spi.c
+++ b/sound/soc/codecs/rt5677-spi.c
@@ -103,7 +103,7 @@ static void rt5677_spi_reverse(u8 *dst, u32 dstlen, const u8 *src, u32 srclen)
u32 word_size = min_t(u32, dstlen, 8);
for (w = 0; w < dstlen; w += word_size) {
- for (i = 0; i < word_size; i++) {
+ for (i = 0; i < word_size && i + w < dstlen; i++) {
si = w + word_size - i - 1;
dst[w + i] = si < srclen ? src[si] : 0;
}
@@ -154,8 +154,9 @@ int rt5677_spi_read(u32 addr, void *rxbuf, size_t len)
status |= spi_sync(g_spi, &m);
mutex_unlock(&spi_mutex);
+
/* Copy data back to caller buffer */
- rt5677_spi_reverse(cb + offset, t[1].len, body, t[1].len);
+ rt5677_spi_reverse(cb + offset, len - offset, body, t[1].len);
}
return status;
}