mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] can: mcp251x: convert to half-duplex SPI
@ 2020-02-25 18:35 Tim Harvey
  2020-02-25 21:43 ` Marc Kleine-Budde
  0 siblings, 1 reply; 13+ messages in thread
From: Tim Harvey @ 2020-02-25 18:35 UTC (permalink / raw)
  To: linux-kernel, linux-can, Wolfgang Grandegger, Marc Kleine-Budde
  Cc: Timo Schlüßler, Andy Shevchenko, Tim Harvey

Some SPI host controllers such as the Cavium Thunder do not support
full-duplex SPI. Using half-duplex transfers allows the driver to work
with those host controllers.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
---
 drivers/net/can/spi/mcp251x.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/can/spi/mcp251x.c b/drivers/net/can/spi/mcp251x.c
index 5009ff2..840c31c 100644
--- a/drivers/net/can/spi/mcp251x.c
+++ b/drivers/net/can/spi/mcp251x.c
@@ -290,23 +290,23 @@ static u8 mcp251x_read_reg(struct spi_device *spi, u8 reg)
 	priv->spi_tx_buf[0] = INSTRUCTION_READ;
 	priv->spi_tx_buf[1] = reg;
 
-	mcp251x_spi_trans(spi, 3);
-	val = priv->spi_rx_buf[2];
+	spi_write_then_read(spi, priv->spi_tx_buf, 2, &val, 1);
 
 	return val;
 }
 
 static void mcp251x_read_2regs(struct spi_device *spi, u8 reg, u8 *v1, u8 *v2)
 {
+	u8 val[4] = {0};
 	struct mcp251x_priv *priv = spi_get_drvdata(spi);
 
 	priv->spi_tx_buf[0] = INSTRUCTION_READ;
 	priv->spi_tx_buf[1] = reg;
 
-	mcp251x_spi_trans(spi, 4);
+	spi_write_then_read(spi, priv->spi_tx_buf, 2, val, 2);
 
-	*v1 = priv->spi_rx_buf[2];
-	*v2 = priv->spi_rx_buf[3];
+	*v1 = val[0];
+	*v2 = val[1];
 }
 
 static void mcp251x_write_reg(struct spi_device *spi, u8 reg, u8 val)
-- 
2.7.4


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

end of thread, other threads:[~2020-05-25 13:27 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-25 18:35 [PATCH] can: mcp251x: convert to half-duplex SPI Tim Harvey
2020-02-25 21:43 ` Marc Kleine-Budde
2020-02-25 22:25   ` Tim Harvey
2020-02-26  7:37     ` Marc Kleine-Budde
2020-02-26 10:19       ` Marc Kleine-Budde
2020-05-21 20:19         ` Tim Harvey
2020-05-21 21:08           ` Mark Brown
2020-05-25 11:17           ` Marc Kleine-Budde
2020-05-25 11:31             ` Mark Brown
2020-05-25 12:41               ` Marc Kleine-Budde
2020-05-25 12:57                 ` Mark Brown
2020-05-25 13:12                   ` Marc Kleine-Budde
2020-05-25 13:27                     ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®