1 From 6edfb172ff1dd3cfc84c19790c245a4005474bb7 Mon Sep 17 00:00:00 2001
2 From: Tim Harvey <tharvey@gateworks.com>
3 Date: Tue, 25 Feb 2020 12:01:36 -0800
4 Subject: [PATCH 03/12] can: mcp251x: convert to half-duplex SPI
6 Some SPI host controllers such as the Cavium Thunder do not support
7 full-duplex SPI. Using half-duplex transfers allows the driver to work
8 with those host controllers.
10 Signed-off-by: Tim Harvey <tharvey@gateworks.com>
12 drivers/net/can/spi/mcp251x.c | 10 +++++-----
13 1 file changed, 5 insertions(+), 5 deletions(-)
15 diff --git a/drivers/net/can/spi/mcp251x.c b/drivers/net/can/spi/mcp251x.c
16 index 0b0dd3f0..c655b29 100644
17 --- a/drivers/net/can/spi/mcp251x.c
18 +++ b/drivers/net/can/spi/mcp251x.c
19 @@ -345,8 +345,7 @@ static u8 mcp251x_read_reg(struct spi_device *spi, uint8_t reg)
20 priv->spi_tx_buf[0] = INSTRUCTION_READ;
21 priv->spi_tx_buf[1] = reg;
23 - mcp251x_spi_trans(spi, 3);
24 - val = priv->spi_rx_buf[2];
25 + spi_write_then_read(spi, priv->spi_tx_buf, 2, &val, 1);
29 @@ -354,15 +353,16 @@ static u8 mcp251x_read_reg(struct spi_device *spi, uint8_t reg)
30 static void mcp251x_read_2regs(struct spi_device *spi, uint8_t reg,
31 uint8_t *v1, uint8_t *v2)
34 struct mcp251x_priv *priv = spi_get_drvdata(spi);
36 priv->spi_tx_buf[0] = INSTRUCTION_READ;
37 priv->spi_tx_buf[1] = reg;
39 - mcp251x_spi_trans(spi, 4);
40 + spi_write_then_read(spi, priv->spi_tx_buf, 2, val, 2);
42 - *v1 = priv->spi_rx_buf[2];
43 - *v2 = priv->spi_rx_buf[3];
48 static void mcp251x_write_reg(struct spi_device *spi, u8 reg, uint8_t val)