All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jagan Teki <jagan@amarulasolutions.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 12/32] spi: mpc8xxx: Get rid of is_read
Date: Sun, 25 Nov 2018 22:58:33 +0530	[thread overview]
Message-ID: <20181125172853.20491-13-jagan@amarulasolutions.com> (raw)
In-Reply-To: <20181125172853.20491-1-jagan@amarulasolutions.com>

From: Mario Six <mario.six@gdsys.cc>

Get rid of the is_read variable, and just keep the state of the "not
empty" and "not full" events in two boolean variables within the loop
body.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---
 drivers/spi/mpc8xxx_spi.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/mpc8xxx_spi.c b/drivers/spi/mpc8xxx_spi.c
index ca34570901..962ef710f8 100644
--- a/drivers/spi/mpc8xxx_spi.c
+++ b/drivers/spi/mpc8xxx_spi.c
@@ -90,7 +90,7 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 	spi8xxx_t *spi = &((immap_t *)(CONFIG_SYS_IMMR))->spi;
 	uint tmpdout, tmpdin, event;
 	int num_blks = DIV_ROUND_UP(bitlen, 32);
-	int tm, is_read = 0;
+	int tm;
 	uchar char_size = 32;
 
 	debug("%s: slave %u:%u dout %08X din %08X bitlen %u\n", __func__,
@@ -144,12 +144,14 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 		 * or time out (1 second = 1000 ms)
 		 * The NE event must be read and cleared first
 		 */
-		for (tm = 0, is_read = 0; tm < SPI_TIMEOUT; ++tm) {
+		for (tm = 0; tm < SPI_TIMEOUT; ++tm) {
 			event = in_be32(&spi->event);
-			if (event & SPI_EV_NE) {
+			bool have_ne = event & SPI_EV_NE;
+			bool have_nf = event & SPI_EV_NF;
+
+			if (have_ne) {
 				tmpdin = in_be32(&spi->rx);
 				setbits_be32(&spi->event, SPI_EV_NE);
-				is_read = 1;
 
 				*(u32 *)din = (tmpdin << (32 - char_size));
 				if (char_size == 32) {
@@ -163,7 +165,7 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 			 * in the future put an arbitrary delay after writing
 			 * the device.  Arbitrary delays suck, though...
 			 */
-			if (is_read && (event & SPI_EV_NF))
+			if (have_ne && have_nf)
 				break;
 		}
 		if (tm >= SPI_TIMEOUT)
-- 
2.18.0.321.gffc6fa0e3

  parent reply	other threads:[~2018-11-25 17:28 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-25 17:28 [U-Boot] [PATCH v2 00/32] spi: DM_SPI migration timeout, remainder(2) Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 01/32] spi: davinci: Full dm conversion Jagan Teki
2018-11-26 13:32   ` Adam Ford
2018-11-26 18:19     ` Jagan Teki
2018-11-26 19:12       ` Adam Ford
2018-11-25 17:28 ` [U-Boot] [PATCH v2 02/32] spi: kirkwood: " Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 03/32] spi: ti_qspi: " Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 04/32] spi: mpc8xxx: Use short type names Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 05/32] spi: mpc8xxx: Fix comments Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 06/32] spi: mpc8xxx: Rename camel-case variables Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 07/32] spi: mpc8xxx: Fix space after cast Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 08/32] spi: mpc8xxx: Fix function names in strings Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 09/32] spi: mpc8xxx: Replace defines with enums Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 10/32] spi: mpc8xxx: Use IO accessors Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 11/32] spi: mpc8xxx: Simplify if Jagan Teki
2018-11-25 17:28 ` Jagan Teki [this message]
2018-11-25 17:28 ` [U-Boot] [PATCH v2 13/32] spi: mpc8xxx: Simplify logic a bit Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 14/32] spi: mpc8xxx: Reduce scope of loop variables Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 15/32] spi: mpc8xxx: Make code more readable Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 16/32] spi: mpc8xxx: Rename variable Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 17/32] spi: mpc8xxx: Document LEN setting better Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 18/32] spi: mpc8xxx: Re-order transfer setup Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 19/32] spi: mpc8xxx: Fix if check Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 20/32] spi: mpc8xxx: Use get_timer Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 21/32] spi: mpc8xxx: Convert to DM Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 22/32] spi: Zap cf_spi driver-related code Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 23/32] spi: Zap lpc32xx_ssp " Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 24/32] spi: Zap mxs_spi " Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 25/32] spi: Zap sh_spi " Jagan Teki
2018-11-25 18:06   ` Marek Vasut
2018-11-27  6:05     ` Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 26/32] spi: Zap soft_spi_legacy " Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 27/32] spi: mxc: Drop non-dm code Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 28/32] spi: omap3: " Jagan Teki
2018-11-26 19:36   ` Adam Ford
2018-11-25 17:28 ` [U-Boot] [PATCH v2 29/32] spi: atmel: " Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 30/32] spi: Zap fsl_espi driver-related code Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 31/32] spi: fsl_dspi: Drop non-dm code Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 32/32] dm: MIGRATION: spi: Update SPI driver status Jagan Teki
2018-12-11  1:03   ` Simon Glass
2018-11-26  7:18 ` [U-Boot] [PATCH v2 00/32] spi: DM_SPI migration timeout, remainder(2) Peng Fan
2018-11-27  5:51   ` Jagan Teki
2018-11-27 12:10     ` Marek Vasut
2018-11-28  4:24       ` Heiko Schocher
2018-11-28  4:36         ` Tom Rini
2018-11-27 14:39     ` Stefano Babic
2018-11-27 16:13       ` Tom Rini
2018-11-28  9:33         ` Stefano Babic
2018-11-28 14:59           ` Tom Rini

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=20181125172853.20491-13-jagan@amarulasolutions.com \
    --to=jagan@amarulasolutions.com \
    --cc=u-boot@lists.denx.de \
    /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.