linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Revert "spi: bitbang: only toggle bitchanges"
@ 2015-07-24  5:37 Lars Persson
       [not found] ` <1437716236-12715-1-git-send-email-larper-VrBV9hrLPhE@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Persson @ 2015-07-24  5:37 UTC (permalink / raw)
  To: linux-spi-u79uwXL29TY76Z2rM5mHXA, broonie-DgEjT+Ai2ygdnm+yROfE0A,
	m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ
  Cc: Lars Persson

This reverts commit 232a5adc5199 ("spi: bitbang: only toggle
bitchanges") because it breaks bitbanged SPI on our MIPS system. I
found two problems with the patch:
- oldbit must initially be computed from bit position 7, 15 or 31 of
  word depending on the value of bits.
- The optimization also does not eliminate consecutive ones because
  the compare of 1<<31 and 1 will be false (a bool only takes values 0
  or 1).

Signed-off-by: Lars Persson <larper-VrBV9hrLPhE@public.gmane.org>
---
 drivers/spi/spi-bitbang-txrx.h | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/spi/spi-bitbang-txrx.h b/drivers/spi/spi-bitbang-txrx.h
index 06b34e5..c616e41 100644
--- a/drivers/spi/spi-bitbang-txrx.h
+++ b/drivers/spi/spi-bitbang-txrx.h
@@ -49,17 +49,12 @@ bitbang_txrx_be_cpha0(struct spi_device *spi,
 {
 	/* if (cpol == 0) this is SPI_MODE_0; else this is SPI_MODE_2 */
 
-	bool oldbit = !(word & 1);
 	/* clock starts at inactive polarity */
 	for (word <<= (32 - bits); likely(bits); bits--) {
 
 		/* setup MSB (to slave) on trailing edge */
-		if ((flags & SPI_MASTER_NO_TX) == 0) {
-			if ((word & (1 << 31)) != oldbit) {
-				setmosi(spi, word & (1 << 31));
-				oldbit = word & (1 << 31);
-			}
-		}
+		if ((flags & SPI_MASTER_NO_TX) == 0)
+			setmosi(spi, word & (1 << 31));
 		spidelay(nsecs);	/* T(setup) */
 
 		setsck(spi, !cpol);
@@ -81,18 +76,13 @@ bitbang_txrx_be_cpha1(struct spi_device *spi,
 {
 	/* if (cpol == 0) this is SPI_MODE_1; else this is SPI_MODE_3 */
 
-	bool oldbit = !(word & (1 << 31));
 	/* clock starts at inactive polarity */
 	for (word <<= (32 - bits); likely(bits); bits--) {
 
 		/* setup MSB (to slave) on leading edge */
 		setsck(spi, !cpol);
-		if ((flags & SPI_MASTER_NO_TX) == 0) {
-			if ((word & (1 << 31)) != oldbit) {
-				setmosi(spi, word & (1 << 31));
-				oldbit = word & (1 << 31);
-			}
-		}
+		if ((flags & SPI_MASTER_NO_TX) == 0)
+			setmosi(spi, word & (1 << 31));
 		spidelay(nsecs); /* T(setup) */
 
 		setsck(spi, cpol);
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-07-24 14:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-24  5:37 [PATCH] Revert "spi: bitbang: only toggle bitchanges" Lars Persson
     [not found] ` <1437716236-12715-1-git-send-email-larper-VrBV9hrLPhE@public.gmane.org>
2015-07-24 10:44   ` Mark Brown
     [not found]     ` <20150724104419.GH11162-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-07-24 11:48       ` Lars Persson
     [not found]         ` <1437738480.31818.5.camel-VrBV9hrLPhE@public.gmane.org>
2015-07-24 11:55           ` Lars-Peter Clausen
     [not found]             ` <55B227B2.9080205-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2015-07-24 14:50               ` Mark Brown
2015-07-24 11:55       ` Jonas Gorski
2015-07-24 12:30   ` Michael Grzeschik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).