Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: Fix regression in spi-bitbang-txrx.h

This patch fixes a regression introduced by commit 232a5adc5199 ("spi:
bitbang: only toggle bitchanges"). The attempt to optimize writes of
consecutive bit patterns broke most of the combinations of word size
and SPI modes due to selecting the wrong bit as the MSB value.

Fixes: 232a5adc5199 (spi: bitbang: only toggle bitchanges)
Signed-off-by: Lars Persson <larper@axis.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org

authored by

Lars Persson and committed by
Mark Brown
26a67ec4 d770e558

+2 -2
+2 -2
drivers/spi/spi-bitbang-txrx.h
··· 49 49 { 50 50 /* if (cpol == 0) this is SPI_MODE_0; else this is SPI_MODE_2 */ 51 51 52 - bool oldbit = !(word & 1); 52 + u32 oldbit = (!(word & (1<<(bits-1)))) << 31; 53 53 /* clock starts at inactive polarity */ 54 54 for (word <<= (32 - bits); likely(bits); bits--) { 55 55 ··· 81 81 { 82 82 /* if (cpol == 0) this is SPI_MODE_1; else this is SPI_MODE_3 */ 83 83 84 - bool oldbit = !(word & (1 << 31)); 84 + u32 oldbit = (!(word & (1<<(bits-1)))) << 31; 85 85 /* clock starts at inactive polarity */ 86 86 for (word <<= (32 - bits); likely(bits); bits--) { 87 87