linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: imx: Simplify logic in spi_imx_push()
@ 2021-07-16 17:39 Uwe Kleine-König
  2021-07-18 13:40 ` Fabio Estevam
  2021-07-19 14:37 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2021-07-16 17:39 UTC (permalink / raw)
  To: Mark Brown, Shawn Guo, Sascha Hauer
  Cc: Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team,
	linux-spi, linux-arm-kernel

For each usage of fifo_words it is clear if ->dynamic_burst is true or
not. This can be used to simplify the function a bit.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/spi/spi-imx.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 39dc02e366f4..c171765d05b1 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -1032,52 +1032,47 @@ static void spi_imx_set_burst_len(struct spi_imx_data *spi_imx, int n_bits)
 
 	ctrl = readl(spi_imx->base + MX51_ECSPI_CTRL);
 	ctrl &= ~MX51_ECSPI_CTRL_BL_MASK;
 	ctrl |= ((n_bits - 1) << MX51_ECSPI_CTRL_BL_OFFSET);
 	writel(ctrl, spi_imx->base + MX51_ECSPI_CTRL);
 }
 
 static void spi_imx_push(struct spi_imx_data *spi_imx)
 {
-	unsigned int burst_len, fifo_words;
+	unsigned int burst_len;
 
-	if (spi_imx->dynamic_burst)
-		fifo_words = 4;
-	else
-		fifo_words = spi_imx_bytes_per_word(spi_imx->bits_per_word);
 	/*
 	 * Reload the FIFO when the remaining bytes to be transferred in the
 	 * current burst is 0. This only applies when bits_per_word is a
 	 * multiple of 8.
 	 */
 	if (!spi_imx->remainder) {
 		if (spi_imx->dynamic_burst) {
 
 			/* We need to deal unaligned data first */
 			burst_len = spi_imx->count % MX51_ECSPI_CTRL_MAX_BURST;
 
 			if (!burst_len)
 				burst_len = MX51_ECSPI_CTRL_MAX_BURST;
 
 			spi_imx_set_burst_len(spi_imx, burst_len * 8);
 
 			spi_imx->remainder = burst_len;
 		} else {
-			spi_imx->remainder = fifo_words;
+			spi_imx->remainder = spi_imx_bytes_per_word(spi_imx->bits_per_word);
 		}
 	}
 
 	while (spi_imx->txfifo < spi_imx->devtype_data->fifo_size) {
 		if (!spi_imx->count)
 			break;
 		if (spi_imx->dynamic_burst &&
-		    spi_imx->txfifo >= DIV_ROUND_UP(spi_imx->remainder,
-						     fifo_words))
+		    spi_imx->txfifo >= DIV_ROUND_UP(spi_imx->remainder, 4))
 			break;
 		spi_imx->tx(spi_imx);
 		spi_imx->txfifo++;
 	}
 
 	if (!spi_imx->slave_mode)
 		spi_imx->devtype_data->trigger(spi_imx);
 }
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] spi: imx: Simplify logic in spi_imx_push()
  2021-07-16 17:39 [PATCH] spi: imx: Simplify logic in spi_imx_push() Uwe Kleine-König
@ 2021-07-18 13:40 ` Fabio Estevam
  2021-07-19 14:37 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Fabio Estevam @ 2021-07-18 13:40 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Mark Brown, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	NXP Linux Team, linux-spi,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

Hi Uwe,

On Fri, Jul 16, 2021 at 2:39 PM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
>
> For each usage of fifo_words it is clear if ->dynamic_burst is true or
> not. This can be used to simplify the function a bit.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Reviewed-by: Fabio Estevam <festevam@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] spi: imx: Simplify logic in spi_imx_push()
  2021-07-16 17:39 [PATCH] spi: imx: Simplify logic in spi_imx_push() Uwe Kleine-König
  2021-07-18 13:40 ` Fabio Estevam
@ 2021-07-19 14:37 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2021-07-19 14:37 UTC (permalink / raw)
  To: Uwe Kleine-König, Sascha Hauer, Shawn Guo
  Cc: Mark Brown, NXP Linux Team, linux-arm-kernel, linux-spi,
	Fabio Estevam, Pengutronix Kernel Team

On Fri, 16 Jul 2021 19:39:27 +0200, Uwe Kleine-König wrote:
> For each usage of fifo_words it is clear if ->dynamic_burst is true or
> not. This can be used to simplify the function a bit.

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: imx: Simplify logic in spi_imx_push()
      commit: bd9616996bb8cd6fbceedf00f1aa72fd9a845519

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-19 14:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-16 17:39 [PATCH] spi: imx: Simplify logic in spi_imx_push() Uwe Kleine-König
2021-07-18 13:40 ` Fabio Estevam
2021-07-19 14:37 ` Mark Brown

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).