From patchwork Thu Mar 21 12:22:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 2313181 Return-Path: X-Original-To: patchwork-spi-devel-general@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by patchwork1.kernel.org (Postfix) with ESMTP id 95E1740213 for ; Thu, 21 Mar 2013 12:23:06 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1UIeWP-0006Wn-DW; Thu, 21 Mar 2013 12:23:05 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1UIeWN-0006Wd-E4 for spi-devel-general@lists.sourceforge.net; Thu, 21 Mar 2013 12:23:03 +0000 X-ACL-Warn: Received: from www.linutronix.de ([62.245.132.108] helo=Galois.linutronix.de) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1UIeWK-000467-4t for spi-devel-general@lists.sourceforge.net; Thu, 21 Mar 2013 12:23:03 +0000 Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by Galois.linutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1UIeWC-0000aX-KA; Thu, 21 Mar 2013 13:22:52 +0100 From: Sebastian Andrzej Siewior To: Grant Likely Subject: [PATCH] spi/omap-mcspi: check condition also after timeout Date: Thu, 21 Mar 2013 13:22:48 +0100 Message-Id: <1363868569-10673-1-git-send-email-bigeasy@linutronix.de> X-Mailer: git-send-email 1.7.10.4 X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1, SHORTCIRCUIT=-0.0001 X-Spam-Score: -2.5 (--) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -2.5 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1UIeWK-000467-4t Cc: spi-devel-general@lists.sourceforge.net, Sebastian Andrzej Siewior , Mark Brown X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: spi-devel-general-bounces@lists.sourceforge.net It is possible that the handler gets interrupted after checking the status. After it resumes the time out is due but the condition it was waiting for might be true as well. Therefore it is necessary to check the condition in case of an time out to be sure that the condition is not true after the time passed by. Signed-off-by: Sebastian Andrzej Siewior --- drivers/spi/spi-omap2-mcspi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index b610f52..56c4166 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -285,8 +285,12 @@ static int mcspi_wait_for_reg_bit(void __iomem *reg, unsigned long bit) timeout = jiffies + msecs_to_jiffies(1000); while (!(__raw_readl(reg) & bit)) { - if (time_after(jiffies, timeout)) - return -1; + if (time_after(jiffies, timeout)) { + if (!(__raw_readl(reg) & bit)) + return -ETIMEDOUT; + else + return 0; + } cpu_relax(); } return 0;