[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0ac77abd-0df5-e437-ea46-f6c77f59b81c@pengutronix.de>
Date: Tue, 25 Feb 2020 22:43:07 +0100
From: Marc Kleine-Budde <mkl@...gutronix.de>
To: Tim Harvey <tharvey@...eworks.com>, linux-kernel@...r.kernel.org,
linux-can@...r.kernel.org, Wolfgang Grandegger <wg@...ndegger.com>
Cc: Timo Schlüßler <schluessler@...use.de>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: Re: [PATCH] can: mcp251x: convert to half-duplex SPI
On 2/25/20 7:35 PM, Tim Harvey wrote:
> 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.
There are several transfers left in the driver, where both rx_buf and
tx_buf are set. How does your host controller driver know which one to
handle?
Marc
> Signed-off-by: Tim Harvey <tharvey@...eworks.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)
>
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Powered by blists - more mailing lists