All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adam Butcher <adam@jessamine.co.uk>
To: broonie@kernel.org, benjamin@bigler.one, carlos.song@nxp.com,
	s.hauer@pengutronix.de, shawnguo@kernel.org,
	stefanmoring@gmail.com
Cc: adam@jessamine.co.uk, kernel@pengutronix.de, linux-imx@nxp.com,
	linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org
Subject: [PATCH v3] spi: spi-imx: fix off-by-one in mx51 CPU mode burst length
Date: Mon, 18 Mar 2024 17:50:52 +0000	[thread overview]
Message-ID: <20240318175119.3334-1-adam@jessamine.co.uk> (raw)

From: Adam Butcher <adam@jessamine.co.uk>

c712c05e46c8 ("spi: imx: fix the burst length at DMA mode and CPU mode")
corrects three cases of setting the ECSPI burst length but erroneously
leaves the in-range CPU case one bit to big (in that field a value of
0 means 1 bit).  The effect was that transmissions that should have been
8-bit bytes appeared as 9-bit causing failed communication with SPI
devices.

Link: https://lore.kernel.org/all/20240201105451.507005-1-carlos.song@nxp.com/
Link: https://lore.kernel.org/all/20240204091912.36488-1-carlos.song@nxp.com/
Fixes: c712c05e46c8 ("spi: imx: fix the burst length at DMA mode and CPU mode")
Signed-off-by: Adam Butcher <adam@jessamine.co.uk>
---

v2. Cleaned up body text.  No diff change.
v3. Corrected log message ref to upstream commit being fixed.  No diff change.

The original patch submission up to v4 (first link above) did not contain
the bug that this patch fixes.  It was introduced in the v5 update (second
link).

---
 drivers/spi/spi-imx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 7c1fcd5ed52f7..100552e6c56bc 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -743,8 +743,8 @@ static int mx51_ecspi_prepare_transfer(struct spi_imx_data *spi_imx,
 				ctrl |= (MX51_ECSPI_CTRL_MAX_BURST * BITS_PER_BYTE - 1)
 						<< MX51_ECSPI_CTRL_BL_OFFSET;
 			else
-				ctrl |= spi_imx->count / DIV_ROUND_UP(spi_imx->bits_per_word,
-						BITS_PER_BYTE) * spi_imx->bits_per_word
+				ctrl |= (spi_imx->count / DIV_ROUND_UP(spi_imx->bits_per_word,
+						BITS_PER_BYTE) * spi_imx->bits_per_word - 1)
 						<< MX51_ECSPI_CTRL_BL_OFFSET;
 		}
 	}
-- 
2.43.0

             reply	other threads:[~2024-03-18 17:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-18 17:50 Adam Butcher [this message]
2024-03-19 11:47 ` [PATCH v3] spi: spi-imx: fix off-by-one in mx51 CPU mode burst length 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=20240318175119.3334-1-adam@jessamine.co.uk \
    --to=adam@jessamine.co.uk \
    --cc=benjamin@bigler.one \
    --cc=broonie@kernel.org \
    --cc=carlos.song@nxp.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=stefanmoring@gmail.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.