From patchwork Sun Apr 28 20:28:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 326 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 2191E3F08F for ; Sun, 28 Apr 2019 22:29:32 +0200 (CEST) Received: by mail-pf1-f200.google.com with SMTP id i23sf6144500pfa.0 for ; Sun, 28 Apr 2019 13:29:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1556483371; cv=pass; d=google.com; s=arc-20160816; b=QgzKb2yfsW8sY0hXSnJIxSHYOZzNO6imo7NZsKfQB/L1bH3dvN4ag902QEnFmHzq2V aqWwdwdUVSWAGsmPlyb43E91CY1TIozoENNO1FSng+oARMdSRWhxJ1FgVYDsSXilBcnv /BMCfh9xEiOpJpXOOgglWE628rKjBJJN+icWlEbZWj7UNN2FoWo128Ggh9sFNc90ktm3 oTjC2QiB4cYGyDD2Po4ocW8Ef8weyjipLN9+/Be05fg8NpWWT0Cl4iEyo9G7/43S8acr 7WMLg6loZh6Lylp8RD0QfmmWNUQB9iIxM54jTU8XOJZaNg3kZEWKLwZm3FSMs3+qJBl5 sS8Q== 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=GfRvy++mcuM6fS9KVUgWjkhIL+ryW2q2XqRBfCVIqxc=; b=jqyoM/VYb5m8veYV5HfQZF5ZzFtQYrTzVc+geEWL/lUUlpYu3W5HZnIrs7WH7EWrIs gL+uZncWpXc7ZvHdHxVMBtctfpK3WXxtgOBu1qxtFjKKJBiLdZD3FDGX80pmGP1NAyty EA30q/i/8elVR+0+HH9cuSxsE2kem5dd+xNSMeaMpPHtvN3QM583/a0lWyn/gNrob20/ oQAKsExkfE8S4L2wK9IB5qWuJs17jxsHmwgpTg7j/YPTZwYTxpC+T6Q5Rfkm5mQ5QKh5 b406e8k1EinxQttD9IGIdkCouxRpUhFr69T3J3QdlkDgKNmjcrpOxbJ+j0LwRr3FTP+T 5znw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="VyJA/7wF"; 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=GfRvy++mcuM6fS9KVUgWjkhIL+ryW2q2XqRBfCVIqxc=; b=YEZkR9GiJ93ZUIewe0Sxvgu1eMN2IK59+hugYSWDmvSedDxttdpHKJ16VuQEUCTLO6 pLbuSViFmYrO2pFg7c188jwkl2IAfdDWYwvGvR4Amrzdd7NasxyKLfP+3sXXdXmFQqzd Rh28RXlpA9deQhWd3HLzvBma/rg3jiKLzo4R8= 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=GfRvy++mcuM6fS9KVUgWjkhIL+ryW2q2XqRBfCVIqxc=; b=Wpgfm4UJAo9N/7RugslZKzCCpxHcMMTgN1Gss+H7zzhfTAqad6aKhaKX6SFsf0Aq+t bybhYpZIN+on2Znztjvg31P7Ds7GOoHrSfGAIeoXAtIUO/JN7f+uUqYN3zFQ5jjGHUOm T3Y7Z+ViuRBIJxC4mt99El9vu2o4M0cg3UBsdq6Mtd/33nneoIrYZUg1q8lMzkTqF+g9 e9BXTlBdAC3/hLE4kCIRlHfwUkSnRbCfepEmPZKDUEJORk8/jKpDP8uAoKOahXaj2Bte s01w/AyddKzRWQw7R38rfpJYmkaEQG4eZ62RUHEQCa5fxSvWliVHzA1T8boGjvp9Tjh9 zD+A== X-Gm-Message-State: APjAAAVnYkJE5THVGhhjkumTFLFU4pA/GdvbHarbpYRPhpM279LEsagm DG5U5sJAJ9uhhLBlj79KAJEumebK X-Google-Smtp-Source: APXvYqyFoVaDjWFNzr4PqqhVp28KffoBy0AR1WlqTX9zULqArpfZBkGidky19QT2zQPZs9v5VxZjmg== X-Received: by 2002:a63:6cc7:: with SMTP id h190mr54298387pgc.350.1556483370926; Sun, 28 Apr 2019 13:29:30 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:54d:: with SMTP id 71ls766114plf.10.gmail; Sun, 28 Apr 2019 13:29:30 -0700 (PDT) X-Received: by 2002:a17:902:9a48:: with SMTP id x8mr11144186plv.133.1556483370572; Sun, 28 Apr 2019 13:29:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556483370; cv=none; d=google.com; s=arc-20160816; b=Rcc1ijWxkm9xas4rxJCcozjRn0rgwomtdbeyWkE3QHRrTOWfZFL285gBdVrasLHR1a ZvXdl83qUdHNWzBbyYXujbm6nD0Tsv5OyJv/dJKo0fSABmwQ3TeBkJ3TPgsPqWSVUqSb Ga8W3+egzW1xfB5CBL3sx2Q5x3AROdKu7fYsvdaoSFmS0srLNlOHkelJXmINHKGx/ek3 c3OUXuYt4OQ87yvDq6EahZOt02MKaVhEb7Yfwc445lm5tXekI69Vvy08rxG1WSo5p7fz ZTwZVzB7Mg0iF/V6gfdikvCEK4Tm9Pog6TPestRfUKh5qPN7R+i6v7QhuaGjM3uaFahE Cj6g== 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=DTO6ewJO6LxtcHMlk6isa3AoPn6RhI6b3q543pvVwGE=; b=HlunoFB+UVUSwwRmgqDasezf+DhYUYi/7kVPTEiv/oN2e8uww3Q29Ei8VkR0lY8tOW 0M6RtVPxXXSQKOn2bNWSPorcXbVWlPxdsXCetJM+zAjd8ndRwiXWhbiC7OJgBodHOBYg KPqLN2CERRSIFKtTbnte4n59MWGbfRWHLMYDnXAHML3AbVHzRRQ7ZM7DgclUoRH2csKB nFv3+2lw77ar3/7Ehau1zxpEt/FXqn1yx1dhU5NsIAAanLP8TGb4U5bqo0bgNfzFAwry uZQdiUjlO2v5s1+gmmFWvjelH7s5qVVCYVLZ3m5Oymjh7qBo2hcYSllUtwvb8RQVNEQC /0PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="VyJA/7wF"; 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 d12sor24369689pgk.19.2019.04.28.13.29.30 for (Google Transport Security); Sun, 28 Apr 2019 13:29:30 -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:a63:5b4d:: with SMTP id l13mr54842512pgm.160.1556483370258; Sun, 28 Apr 2019 13:29:30 -0700 (PDT) Received: from localhost.localdomain ([115.97.185.144]) by smtp.gmail.com with ESMTPSA id x66sm68841439pfb.78.2019.04.28.13.29.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Apr 2019 13:29:29 -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 10/19] spi: mpc8xxx: Simplify logic a bit Date: Mon, 29 Apr 2019 01:58:45 +0530 Message-Id: <20190428202854.8590-11-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="VyJA/7wF"; 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 We do nothing in the loop if the "not empty" event was not detected. To simplify the logic, check if this is the case, and skip the execution of the loop early to reduce the nesting level and flag checking. Signed-off-by: Mario Six --- drivers/spi/mpc8xxx_spi.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/spi/mpc8xxx_spi.c b/drivers/spi/mpc8xxx_spi.c index 962ef710f8..a2e698ea17 100644 --- a/drivers/spi/mpc8xxx_spi.c +++ b/drivers/spi/mpc8xxx_spi.c @@ -149,25 +149,28 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din, 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); - - *(u32 *)din = (tmpdin << (32 - char_size)); - if (char_size == 32) { - /* Advance output buffer by 32 bits */ - din += 4; - } + if (!have_ne) + continue; + + tmpdin = in_be32(&spi->rx); + setbits_be32(&spi->event, SPI_EV_NE); + + *(u32 *)din = (tmpdin << (32 - char_size)); + if (char_size == 32) { + /* Advance output buffer by 32 bits */ + din += 4; } + /* * Only bail when we've had both NE and NF events. * This will cause timeouts on RO devices, so maybe * in the future put an arbitrary delay after writing * the device. Arbitrary delays suck, though... */ - if (have_ne && have_nf) + if (have_nf) break; } + if (tm >= SPI_TIMEOUT) debug("*** %s: Time out during SPI transfer\n", __func__);