All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tim Harvey <tharvey@gateworks.com>
To: linux-kernel@vger.kernel.org, linux-can@vger.kernel.org,
	Wolfgang Grandegger <wg@grandegger.com>,
	Marc Kleine-Budde <mkl@pengutronix.de>
Cc: "Timo Schlüßler" <schluessler@krause.de>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"Tim Harvey" <tharvey@gateworks.com>
Subject: [PATCH] can: mcp251x: convert to half-duplex SPI
Date: Tue, 25 Feb 2020 10:35:34 -0800	[thread overview]
Message-ID: <1582655734-20890-1-git-send-email-tharvey@gateworks.com> (raw)

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

             reply	other threads:[~2020-02-25 18:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-25 18:35 Tim Harvey [this message]
2020-02-25 21:43 ` [PATCH] can: mcp251x: convert to half-duplex SPI 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
     [not found]         ` <7b85e098-b9a9-dd14-203f-100cdf2e703e-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2020-05-21 20:19           ` Tim Harvey
2020-05-21 20:19             ` Tim Harvey
     [not found]             ` <CAJ+vNU06DHVS25OQR1Kqyzy2ZxLVq-HdwenGv-jN5Rb3r8F86Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-05-21 21:08               ` Mark Brown
2020-05-21 21:08                 ` Mark Brown
2020-05-25 11:17               ` Marc Kleine-Budde
2020-05-25 11:17                 ` Marc Kleine-Budde
2020-05-25 11:31                 ` Mark Brown
     [not found]                   ` <20200525113106.GB4544-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2020-05-25 12:41                     ` Marc Kleine-Budde
2020-05-25 12:41                       ` Marc Kleine-Budde
     [not found]                       ` <a337c8ea-66e2-13c2-f625-fbe93e367d44-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2020-05-25 12:57                         ` Mark Brown
2020-05-25 12:57                           ` Mark Brown
2020-05-25 13:12                           ` Marc Kleine-Budde
2020-05-25 13:27                             ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1582655734-20890-1-git-send-email-tharvey@gateworks.com \
    --to=tharvey@gateworks.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=schluessler@krause.de \
    --cc=wg@grandegger.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.