Permalink
Browse files

can: mcp251x: convert driver to half-duplex SPI

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>
  • Loading branch information...
Gateworks committed Aug 30, 2018
1 parent ed9e7d8 commit cb270339619ccf2b50dfd3604a03626f85830453
Showing with 5 additions and 5 deletions.
  1. +5 −5 drivers/net/can/spi/mcp251x.c
@@ -345,24 +345,24 @@ static u8 mcp251x_read_reg(struct spi_device *spi, uint8_t 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, uint8_t reg,
uint8_t *v1, uint8_t *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, uint8_t val)

0 comments on commit cb27033

Please sign in to comment.