From patchwork Tue Sep 4 02:40:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1401111 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 3BC18DF2AB for ; Tue, 4 Sep 2012 02:44:15 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T8j4g-0001Ik-S9; Tue, 04 Sep 2012 02:41:10 +0000 Received: from mail-out.m-online.net ([2001:a60:0:28:0:1:25:1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1T8j49-0001Eb-Ru for linux-arm-kernel@lists.infradead.org; Tue, 04 Sep 2012 02:40:40 +0000 Received: from frontend1.mail.m-online.net (frontend1.mail.intern.m-online.net [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 3X9sjJ69d1z3hhcs; Tue, 4 Sep 2012 04:40:36 +0200 (CEST) X-Auth-Info: WrIM6W1OaxMWbqnerjhBdCEl9up2FWZBMuX0vUFqZGo= Received: from mashiro.lan (unknown [195.140.253.167]) by smtp-auth.mnet-online.de (Postfix) with ESMTPA id 3X9sjJ44rNzbbgH; Tue, 4 Sep 2012 04:40:36 +0200 (CEST) From: Marek Vasut To: spi-devel-general@lists.sourceforge.net Subject: [PATCH 4/4] mxs/spi: Rework the mxs_ssp_timeout to be more readable Date: Tue, 4 Sep 2012 04:40:18 +0200 Message-Id: <1346726418-2856-5-git-send-email-marex@denx.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1346726418-2856-1-git-send-email-marex@denx.de> References: <1346726418-2856-1-git-send-email-marex@denx.de> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Marek Vasut , Fabio Estevam , Shawn Guo , Mark Brown , Grant Likely , Chris Ball , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Rework the mxs_ssp_timeout() function to make it a bit more readable and hopefully less error prone. Also, have only one successful exit from the function and one failing exit instead of two. Finally, discard the udelay() from this function altogether, as this tightloop is quick enough it's pointless. Signed-off-by: Marek Vasut Cc: Chris Ball Cc: Fabio Estevam Cc: Grant Likely Cc: Mark Brown Cc: Shawn Guo --- drivers/spi/spi-mxs.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c index 6650ded..2c3665a 100644 --- a/drivers/spi/spi-mxs.c +++ b/drivers/spi/spi-mxs.c @@ -177,25 +177,23 @@ static inline void mxs_spi_disable(struct mxs_spi *spi) static int mxs_ssp_wait(struct mxs_spi *spi, int offset, int mask, bool set) { - unsigned long timeout = jiffies + msecs_to_jiffies(SSP_TIMEOUT); + const unsigned long timeout = jiffies + msecs_to_jiffies(SSP_TIMEOUT); struct mxs_ssp *ssp = &spi->ssp; uint32_t reg; - while (1) { + do { reg = readl_relaxed(ssp->base + offset); - if (set && ((reg & mask) == mask)) - break; + if (!set) + reg = ~reg; - if (!set && ((~reg & mask) == mask)) - break; + reg &= mask; - udelay(1); + if (reg == mask) + return 0; + } while (time_before(jiffies, timeout)); - if (time_after(jiffies, timeout)) - return -ETIMEDOUT; - } - return 0; + return -ETIMEDOUT; } static void mxs_ssp_dma_irq_callback(void *param)