netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Heimpold <mhei@heimpold.de>
To: Jonathan Cameron <jic23@kernel.org>,
	"Andrew F . Davis" <afd@ti.com>, Mark Brown <broonie@kernel.org>,
	netdev@vger.kernel.org,
	Claudio Lanconelli <lanconelli.claudio@eptar.com>
Cc: Michael Heimpold <mhei@heimpold.de>
Subject: [PATCH net-next 1/2] net: ethernet: enc28j60: support half-duplex SPI controllers
Date: Sat, 23 Apr 2016 23:43:19 +0200	[thread overview]
Message-ID: <1461447800-11381-2-git-send-email-mhei@heimpold.de> (raw)
In-Reply-To: <1461447800-11381-1-git-send-email-mhei@heimpold.de>

The current spi_read_buf function fails on SPI host masters which
are only half-duplex capable. Splitting the Tx and Rx part solves
this issue.

Tested on Raspberry Pi (full duplex) and I2SE Duckbill (half duplex).

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
---
 drivers/net/ethernet/microchip/enc28j60.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/microchip/enc28j60.c b/drivers/net/ethernet/microchip/enc28j60.c
index 86ea17e..b723622 100644
--- a/drivers/net/ethernet/microchip/enc28j60.c
+++ b/drivers/net/ethernet/microchip/enc28j60.c
@@ -89,22 +89,26 @@ spi_read_buf(struct enc28j60_net *priv, int len, u8 *data)
 {
 	u8 *rx_buf = priv->spi_transfer_buf + 4;
 	u8 *tx_buf = priv->spi_transfer_buf;
-	struct spi_transfer t = {
+	struct spi_transfer tx = {
 		.tx_buf = tx_buf,
+		.len = SPI_OPLEN,
+	};
+	struct spi_transfer rx = {
 		.rx_buf = rx_buf,
-		.len = SPI_OPLEN + len,
+		.len = len,
 	};
 	struct spi_message msg;
 	int ret;
 
 	tx_buf[0] = ENC28J60_READ_BUF_MEM;
-	tx_buf[1] = tx_buf[2] = tx_buf[3] = 0;	/* don't care */
 
 	spi_message_init(&msg);
-	spi_message_add_tail(&t, &msg);
+	spi_message_add_tail(&tx, &msg);
+	spi_message_add_tail(&rx, &msg);
+
 	ret = spi_sync(priv->spi, &msg);
 	if (ret == 0) {
-		memcpy(data, &rx_buf[SPI_OPLEN], len);
+		memcpy(data, rx_buf, len);
 		ret = msg.status;
 	}
 	if (ret && netif_msg_drv(priv))
-- 
2.5.0

  reply	other threads:[~2016-04-23 21:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-23 21:43 [PATCH net-next 0/2] net: ethernet: enc28j60: small improvements Michael Heimpold
2016-04-23 21:43 ` Michael Heimpold [this message]
2016-04-23 21:43 ` [PATCH net-next 2/2] net: ethernet: enc28j60: add device tree support Michael Heimpold
2016-04-23 22:20   ` Arnd Bergmann
2016-04-24 21:28     ` [PATCH v2 net-next] " Michael Heimpold
2016-04-25 13:23       ` Rob Herring
2016-04-25 18:41         ` Michael Heimpold
     [not found]       ` <1461533283-24852-1-git-send-email-mhei-Z/Lg1yOAjpkb1SvskN2V4Q@public.gmane.org>
2016-04-25 15:39         ` Andrew F. Davis
2016-04-25 17:46           ` Michael Heimpold
2016-04-25 18:04             ` Andrew F. Davis

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=1461447800-11381-2-git-send-email-mhei@heimpold.de \
    --to=mhei@heimpold.de \
    --cc=afd@ti.com \
    --cc=broonie@kernel.org \
    --cc=jic23@kernel.org \
    --cc=lanconelli.claudio@eptar.com \
    --cc=netdev@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).