diff options
author | Marc Kleine-Budde <mkl@pengutronix.de> | 2020-12-16 00:17:46 +0100 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2021-01-06 15:15:41 +0100 |
commit | 0460ecaeba90f418f29f9ea57d994429c8f88a4e (patch) | |
tree | ff7f4fc091cb93f8fcaf9a3aa8cf12c17b705f77 /drivers/net/can/m_can/tcan4x5x-regmap.c | |
parent | 1c5d0fc48b3aef66128b10bcf40ff782f32b3909 (diff) | |
download | linux-0460ecaeba90f418f29f9ea57d994429c8f88a4e.tar.bz2 |
can: tcan4x5x: add support for half-duplex controllers
This patch adds back support for half-duplex controllers, which was removed in
the last patch.
Reviewed-by: Dan Murphy <dmurphy@ti.com>
Tested-by: Sean Nyekjaer <sean@geanix.com>
Link: https://lore.kernel.org/r/20201215231746.1132907-17-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can/m_can/tcan4x5x-regmap.c')
-rw-r--r-- | drivers/net/can/m_can/tcan4x5x-regmap.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/drivers/net/can/m_can/tcan4x5x-regmap.c b/drivers/net/can/m_can/tcan4x5x-regmap.c index 660e9d87dffb..ca80dbaf7a3f 100644 --- a/drivers/net/can/m_can/tcan4x5x-regmap.c +++ b/drivers/net/can/m_can/tcan4x5x-regmap.c @@ -51,7 +51,7 @@ static int tcan4x5x_regmap_read(void *context, struct tcan4x5x_priv *priv = spi_get_drvdata(spi); struct tcan4x5x_map_buf *buf_rx = &priv->map_buf_rx; struct tcan4x5x_map_buf *buf_tx = &priv->map_buf_tx; - struct spi_transfer xfer[] = { + struct spi_transfer xfer[2] = { { .tx_buf = buf_tx, } @@ -66,17 +66,26 @@ static int tcan4x5x_regmap_read(void *context, sizeof(buf_tx->cmd.addr)); tcan4x5x_spi_cmd_set_len(&buf_tx->cmd, val_len); - xfer[0].rx_buf = buf_rx; - xfer[0].len = sizeof(buf_tx->cmd) + val_len; + if (spi->controller->flags & SPI_CONTROLLER_HALF_DUPLEX) { + xfer[0].len = sizeof(buf_tx->cmd); + + xfer[1].rx_buf = val_buf; + xfer[1].len = val_len; + spi_message_add_tail(&xfer[1], &msg); + } else { + xfer[0].rx_buf = buf_rx; + xfer[0].len = sizeof(buf_tx->cmd) + val_len; - if (TCAN4X5X_SANITIZE_SPI) - memset(buf_tx->data, 0x0, val_len); + if (TCAN4X5X_SANITIZE_SPI) + memset(buf_tx->data, 0x0, val_len); + } err = spi_sync(spi, &msg); if (err) return err; - memcpy(val_buf, buf_rx->data, val_len); + if (!(spi->controller->flags & SPI_CONTROLLER_HALF_DUPLEX)) + memcpy(val_buf, buf_rx->data, val_len); return 0; } |