From patchwork Sun Apr 28 20:28:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 325 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 51D0A3F08F for ; Sun, 28 Apr 2019 22:29:29 +0200 (CEST) Received: by mail-pf1-f199.google.com with SMTP id a141sf4426745pfa.13 for ; Sun, 28 Apr 2019 13:29:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1556483368; cv=pass; d=google.com; s=arc-20160816; b=GgXGzihvyRmS/83y0MKUnTgh+TqOwpDVw7/jusqJ4HLdHU5Ioz6Lr7xlnmLdmDMVAH VYE7Hf4u4Bdjgb8Sx6Qat+OYtVPoRVFnPPxjp80isjNbIOmrILyJ2tfOJTNMbkjcp3OR 0uM0iWJ4+tUR9JqpFbF/EvvHTbyCddS3FSwM9cwh8dIgd0OOw0k02ogzurV44F/fPCS3 N5fF1g/cviyxn7lpZ58Ve+RD8Vza9usdbL3zlflPMswhCNFTJmXpcOz/m63gxR1BcipM fr9/G5F9voGlSgl8zZTgP+UY7nTWKp4ZQd9YBhDVubEVsPPsRybPibQ4/+0vMWSimKCy OWTA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=iH3ONbWz3L+J5LVdZ9e/m3CMBEfTU8Uctqn5xwIiKWY=; b=Spnqs+CPw7Mp+V8wCZDgx10kfOKEsJAre++uBgUCWwyFQN6wbTs1JP98gPnMXPJyWj fEhFJq272hPlFYy4HoakQWwYG5Tx4tTV9GsorW1tOl5H02Y7wij1k38b9gi2R+l/gpG5 mUmgek8bGoZz9e12Ahy+0SLArD/Nrm1d4TzNHMCQHv6tl6rqVUkJCsurgrrufS7afp6d mMStfWDf9IOdOUCXPZxpeIOy8sdJxOkGSoStUxFp7pEn0Hy1CpUoLbFyOUEX/caoJBIg vSW1KMqlZ9ZSa9WrYxvx62ym/JDZFqNgMhAENN+eWWSaad15ei2mWr3smMzfL8pLzFKm pa2g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=d25zGYn+; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=iH3ONbWz3L+J5LVdZ9e/m3CMBEfTU8Uctqn5xwIiKWY=; b=oi09IiM3pMWjOxQohOzSZkVG+v8VdgIAXsAN7ySmcqzHj3KOOTMDJP1YT2G2lJsdSb 62RgFALVLv/vdaxsMTgBSW/ULlgL/Ygh8eCCq4Rt86KCpuzjiT+60auzUfZOEUOVI3pX hT2zcKIubbTaAfFKWggcK0Tuc2CBxKFlovxHg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=iH3ONbWz3L+J5LVdZ9e/m3CMBEfTU8Uctqn5xwIiKWY=; b=gLo6q5D2lD05cLxcVHJMVqoixRNu2pjAQAX1oII8tDpxs+x4kFop1OR9mAtPHXuPlr VmXcByQdPwogCR38EPvVgIPs3uRfI5xMfkWHsbnz9+kF44w+vzHxCtMoNiZoG/PMV4WS Iu7Vh2iNLkwXXoU5YYNg8VFm2gdqNZm0w6ydrLi+JR4ggD3+MG8dJ/BpJNyjGH2Uswxz nlI7VULzL6v4eJcCetEWkBCeIFWTjHlJj6bJvg1CdzB2PNABdnW8zexN3+tDXwgBO97n ztJ6V34sqB/bAtlJJ7IafxXkPjlvwRvQhsW2VtxcY8EywkYbErPnAsoYhNjTzo+smmlO tfDg== X-Gm-Message-State: APjAAAWgZdVFtUUT/Sbl2WENKkoJZmHLLLZYvJSTqIDqGy+Cx8vrGZWH QH7Xetskf7rqoV/fwqsSjZAjDnM9 X-Google-Smtp-Source: APXvYqwdQJzhM0VCGAZIyopBV8YCZUE09zHZxpM7wrkJbYhDM9EiRkK50BWf9WuGe4bjWhnQe+NHuw== X-Received: by 2002:aa7:9285:: with SMTP id j5mr30718105pfa.129.1556483368120; Sun, 28 Apr 2019 13:29:28 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a62:6085:: with SMTP id u127ls363069pfb.9.gmail; Sun, 28 Apr 2019 13:29:27 -0700 (PDT) X-Received: by 2002:a63:a42:: with SMTP id z2mr25759320pgk.262.1556483367830; Sun, 28 Apr 2019 13:29:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556483367; cv=none; d=google.com; s=arc-20160816; b=KjVjPVuAihUSmmTumV8VezK1cnWt6pv8fACY1M+7Zt/jO9dOPHjdU5BF8s0G49GaEU Pys6kKvArYtJcKBwyTJ0CPB0whW1g9cHHKcCoDw3Mhx+danJIPHvIvP2hMjGyz2FdZBB kUBlZv169WFO+oILe5sKO+ysfYuHKJ8zziaQiZhrmpKXgj6YdJ7E/r4Tc1qq2ZKtezI8 YIlUR+rXxLafFEsZJG2A8oEWPhz/hdSTCV2UG6ve+Bt3p2k51JDKiLPZzFmMM7o0Uwz+ wYTvHZqBwQvgis9uQ0dckTl8WrQuzCLfzeimiuMvldodwmxXj2zIzJw5TaC379I3ujjf vELg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=tlg7S/5yavDNw1bG++IXicLM4kjsM/wdZz52Nn7kN+U=; b=b6Pk2fiasDv4YrGQ2pBQJfkZ1bU1CpGS194PivXb6oheyU9lAsvLeRPuyrcp4o1LmQ SxazZVxSp9DtzdgFtnWjufq6YPg9Yr3mpLNdKZM5f8cZXHTgYltEEiuGJ2ulVD5ZT3rh mAwevLGkHLzA1yW4hAlv3GbbmC09Kn4tnG78NBRSui9izfU6D6pnzHNRX++vW+wMLHuu H9oCvjGYtOx25EyWHGADEfONPfLvnJc+CZH4L7nq3OAUG08SVf5lAC02ghfLJCY/dq9K YkUBTzEuIjt3rAi2l5TWtg6xhk3iDJEgRJ0jWa1T9IvEUiOZDkuuZ5ZitSAFa1uVoLYF n4JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=d25zGYn+; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id t23sor8507665plr.33.2019.04.28.13.29.27 for (Google Transport Security); Sun, 28 Apr 2019 13:29:27 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:902:20c9:: with SMTP id v9mr58111292plg.239.1556483367546; Sun, 28 Apr 2019 13:29:27 -0700 (PDT) Received: from localhost.localdomain ([115.97.185.144]) by smtp.gmail.com with ESMTPSA id x66sm68841439pfb.78.2019.04.28.13.29.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Apr 2019 13:29:26 -0700 (PDT) From: Jagan Teki To: Heiko Schocher , Tom Rini Cc: u-boot@lists.denx.de, linux-amarula@amarulasolutions.com, Mario Six Subject: [PATCH v2 09/19] spi: mpc8xxx: Get rid of is_read Date: Mon, 29 Apr 2019 01:58:44 +0530 Message-Id: <20190428202854.8590-10-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190428202854.8590-1-jagan@amarulasolutions.com> References: <20190428202854.8590-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=d25zGYn+; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Mario Six 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 --- 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)