From patchwork Sun Apr 28 20:28:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 333 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id E6F923F08F for ; Sun, 28 Apr 2019 22:29:48 +0200 (CEST) Received: by mail-pg1-f200.google.com with SMTP id o8sf6097862pgq.5 for ; Sun, 28 Apr 2019 13:29:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1556483387; cv=pass; d=google.com; s=arc-20160816; b=fhfUNbb6PLStGqpor0UMn4fRfuo78ZZhR1NxGUsd+TBV1AYCeEvuNVbg2DCJb1d5C1 yEU/SFNkgV8m+TUoFOsdmDEXoTZ+PCun6gLR+bBhRsT2QTXnKAOmf4ea3Bxs3rZorVPa F0C2iup7Ht68UTbwJi5m+/WMmqamzhJBL+uoUcCO1QoRNGlAwnf8myfywLRxFE4BA67r kDb8Wmf821yGr4vV5inpBoXz2U5bzeVLF7esmaeQ9FHRmzblp8R9sD5dlhxuKxlOdmLB +xmE0+XC0mD+cGwWDuYnh9E8xyQn/cvdAyrnD/Ui8HYxMC5C+3yRMzwgGbvRa8B250x8 xA7w== 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=uoWq0YdPUoaAovXS66Bg5KEflTmjnJYWLCUb76LCFgo=; b=yN1K+TgPk+ZaU7Lje+EQOru4Ohlxvq9Pd8TxLWR/ognBwkUTEftf07qn2RAWwhgGBt h7TYRKHn7/sed/kbHmuRYaSxtUk827W93B9bK1gGf5DUTu8lki/6aistc0XsRFXTZAsR LNVevTADaQspyynwa9Q3JWOxbNdZ8Uu4ztieLyNeRwZaMVMEq0kBrT7m9ItooR+gor2h ViD8PYZX4SlB8fiFz05MeyNXul/Qs1DO5TMRbRI3dWyIFebq7rTYLNmLREssPVrAaIeg Kl8FrcxTL13AkcQyTaIhEaKEo0BsRte8v/er33Xp1MTuDR7vJQySSbKiWIJeMPhgEWaP 55Bg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=XDafTVZc; 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=uoWq0YdPUoaAovXS66Bg5KEflTmjnJYWLCUb76LCFgo=; b=b4TqAD63wM2hcoCm/L6g+0qgrA95WQGdxVrblN3+jHbXjGMG6mvBwQ8M8TBEErq8du 4YNnPumxCBuV6QgWl58o5mDlwSUDWsui4PwcjivJ/swXTkh/3TGtNsLHo1LwFZcWcTbx Z1vaOjTGSv7h+ks4Nq/n5hshRltlHEoqU62fI= 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=uoWq0YdPUoaAovXS66Bg5KEflTmjnJYWLCUb76LCFgo=; b=fo4y5+krLX20vHyG21ghxH+7mKTkQtZ+Z4tr1Swh7/bdadPu5QniCslIArnw5FAfCK 7od3t2sUOafHetizv2FQhHU0jx7UXaf5uG+OCwqLYYH0EqYzYAiI/WH98NZ6JSiQa8Dy KxTFN1RlPx/S9Bg16kdJ1PEXDXgpsR1UpmXvTbIbqCS/5aQqdL07FLVutzNQ4bZgT5Xl qsRjZUi+B2qT4KqjMMrL/4DIFWFtp3NIHVjXCWmAPeXqw4sRHjkuIC1hDydmKYpLhrxj LToLcwRr8CGeh6etgrtIG/Pvsy1xzIcgZajT/8yFc4KNX6oJKTE7Ay+6SQRqDORBgQDO MkWg== X-Gm-Message-State: APjAAAUYTZccYM/qi30OYogg3F1JrjHKv4ZeDRCaV0HFP5DxobMnnMWD cWfINdUHTEY+7Cj6XwroXQPY3veQ X-Google-Smtp-Source: APXvYqwHth8Jx9d0BcceF1mQJl3zVfj+7hs/28bRqk+xT9kfYZ0c69lTOkF97mXVRCUaoLxByIMw2Q== X-Received: by 2002:a63:2325:: with SMTP id j37mr1132584pgj.137.1556483387754; Sun, 28 Apr 2019 13:29:47 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a63:c542:: with SMTP id g2ls127212pgd.9.gmail; Sun, 28 Apr 2019 13:29:47 -0700 (PDT) X-Received: by 2002:a62:5a42:: with SMTP id o63mr61704546pfb.170.1556483387367; Sun, 28 Apr 2019 13:29:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556483387; cv=none; d=google.com; s=arc-20160816; b=p9hRJxKvP7A+XPRAKJ6zt1dI9KIevExkl3/IqX0YilVbywuVd7gOJd+IuJJn+N6wpH Cxupl9wv9qfG30Q+BxX1uGMB0913NCcEF7mNr4YwXq9E6gGELcrNEb2ltbR+wLFpdCYQ iZ849XxbiYXpMtq3GHJ/9GowYMSsMVWGcCzt8syk/KanAzKBCa6hn1+ccPbHxNAtoLY0 hnxoSdOC6kLi2yd/i/vQ/70kZKRkZrRo3kYoU3Rb0X+95TOYG6TKVwsVXRHkMJWgXfJs gC2/mzr81DmmC2k0jtAbdCveSJWUxsRKEHHZa1PrSgqVKgSn8z6sbc3kxvRbt+utpO0I ermA== 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=IgaR4FUCQnO0Df8jzFpeiy0ayqG5b2rwTivOAhw7crw=; b=XcFxwVs+52wog5pusYYGPE7sg44YvQdb2TNAq3Wg+vsUCaG1wOt8e3CdzenNQDnt+N ovjYq2jN3bkVd7w2Pwepho8ZcdWr/mU6pZvA4TQMde5Q5IpfI0yjCtzkOySSisOAfuGM ONt0juZiVId/FqBQpAjwhhO+a5cbVslfga3fqdc+e6k2KVOlAOWuxBj5vn3JuqxrenVr dMr/96jNBzB6C4nbFy6bFgMKE/JI2dBpbvQ/4ZH9J/FSj3pibzA4z3alPy6TwxkaDKnf XxsL7LzVQ55Yert9V+dx41qqK7/Tjm0jnUcH8geH7kdOof2CxV9ikDCxE7US/Y9bqqQy 1+BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=XDafTVZc; 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 r18sor6833296pgk.12.2019.04.28.13.29.47 for (Google Transport Security); Sun, 28 Apr 2019 13:29:47 -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:d016:: with SMTP id z22mr1569291pgf.116.1556483387084; Sun, 28 Apr 2019 13:29:47 -0700 (PDT) Received: from localhost.localdomain ([115.97.185.144]) by smtp.gmail.com with ESMTPSA id x66sm68841439pfb.78.2019.04.28.13.29.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Apr 2019 13:29:46 -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 17/19] spi: mpc8xxx: Use get_timer Date: Mon, 29 Apr 2019 01:58:52 +0530 Message-Id: <20190428202854.8590-18-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=XDafTVZc; 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 The comment before the transmission loop in conjunction with the definition of SPI_TIMEOUT as 1000 implies that the loop is supposed to have a timeout value of 1000 ms. But since there is no mdelay(1) or similar in the loop body, the loop just runs 1000 times, without regard for the time elapsed. To correct this, use the standard get_timer functionality to properly time out the loop after 1000 ms. Signed-off-by: Mario Six --- drivers/spi/mpc8xxx_spi.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/spi/mpc8xxx_spi.c b/drivers/spi/mpc8xxx_spi.c index e09e91c8e9..63e1a150f8 100644 --- a/drivers/spi/mpc8xxx_spi.c +++ b/drivers/spi/mpc8xxx_spi.c @@ -112,9 +112,9 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din, /* Handle data in 32-bit chunks */ while (num_blks--) { - int tm; u32 tmpdout = 0; uchar xfer_bitlen = (bitlen >= 32 ? 32 : bitlen); + ulong start; clrbits_be32(&spi->mode, SPI_MODE_EN); @@ -148,7 +148,8 @@ 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; tm < SPI_TIMEOUT; ++tm) { + start = get_timer(0); + do { u32 event = in_be32(&spi->event); bool have_ne = event & SPI_EV_NE; bool have_nf = event & SPI_EV_NF; @@ -173,9 +174,11 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din, */ if (have_nf) break; - } - if (tm >= SPI_TIMEOUT) + mdelay(1); + } while (get_timer(start) < SPI_TIMEOUT); + + if (get_timer(start) >= SPI_TIMEOUT) debug("*** %s: Time out during SPI transfer\n", __func__);