spi: bitbang: Fix lsb-first Rx
authorRobin Murphy <robin.murphy@arm.com>
Wed, 3 Aug 2022 14:58:57 +0000 (15:58 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 15 Aug 2022 00:26:20 +0000 (01:26 +0100)
commit46f7ac3d7892e808c9ba01c39da6bb85cda26ecd
treedae9d3f12927dec8c225abd1e273e8a0a463c761
parent568035b01cfb107af8d2e4bd2fb9aea22cf5b868
spi: bitbang: Fix lsb-first Rx

Shifting the recieved bit by "bits" inserts it at the top of the
*currently remaining* Tx data, so we end up accumulating the whole
transfer into bit 0 of the output word. Oops.

For the algorithm to work as intended, we need to remember where the
top of the *original* word was, and shift Rx to there.

Fixes: 1847e3046c52 ("spi: gpio: Implement LSB First bitbang support")
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Link: https://lore.kernel.org/r/28324d8622da80461cce35a82859b003d6f6c4b0.1659538737.git.robin.murphy@arm.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-bitbang-txrx.h