From patchwork Thu Mar 25 09:52:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shishkin X-Patchwork-Id: 88172 X-Patchwork-Delegate: tony@atomide.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2P9rJDV023396 for ; Thu, 25 Mar 2010 09:53:26 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752383Ab0CYJxZ (ORCPT ); Thu, 25 Mar 2010 05:53:25 -0400 Received: from smtp.nokia.com ([192.100.122.230]:23837 "EHLO mgw-mx03.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751256Ab0CYJxY (ORCPT ); Thu, 25 Mar 2010 05:53:24 -0400 Received: from vaebh105.NOE.Nokia.com (vaebh105.europe.nokia.com [10.160.244.31]) by mgw-mx03.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o2P9qiA3019876; Thu, 25 Mar 2010 11:53:11 +0200 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by vaebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 25 Mar 2010 11:53:01 +0200 Received: from mgw-da01.ext.nokia.com ([147.243.128.24]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Thu, 25 Mar 2010 11:53:00 +0200 Received: from trapdoor (esdhcp041177.research.nokia.com [172.21.41.177]) by mgw-da01.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o2P9qrQa004300 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Thu, 25 Mar 2010 11:52:55 +0200 Received: from ash by trapdoor with local (Exim 4.69) (envelope-from ) id 1NujkB-00027e-Od; Thu, 25 Mar 2010 11:52:51 +0200 From: Alexander Shishkin To: ben-linux@fluff.org Cc: nm@ti.com, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, Tony Lindgren , Alexander Shishkin Subject: [PATCH v2 2/2] omap i2c: add a timeout to the busy waiting Date: Thu, 25 Mar 2010 11:52:37 +0200 Message-Id: <1269510757-8119-3-git-send-email-virtuoso@slind.org> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <20100316143025.GR2900@atomide.com> References: <20100316143025.GR2900@atomide.com> X-OriginalArrivalTime: 25 Mar 2010 09:53:00.0757 (UTC) FILETIME=[F47FE850:01CACC00] X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 25 Mar 2010 09:53:27 +0000 (UTC) diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 2d146ac..7d56a25 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -678,6 +678,8 @@ omap_i2c_rev1_isr(int this_irq, void *dev_id) */ static int errata_omap3_1p153(struct omap_i2c_dev *dev, u16 *stat, int *err) { + unsigned long timeout = jiffies + msecs_to_jiffies(1); + while (!(*stat & OMAP_I2C_STAT_XUDF)) { if (*stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) { omap_i2c_ack_stat(dev, *stat & (OMAP_I2C_STAT_XRDY | @@ -685,6 +687,12 @@ static int errata_omap3_1p153(struct omap_i2c_dev *dev, u16 *stat, int *err) *err |= OMAP_I2C_STAT_XUDF; return -ETIMEDOUT; } + + if (time_after(jiffies, timeout)) { + dev_err(dev->dev, "timeout waiting on XUDF bit\n"); + return 0; + } + cpu_relax(); *stat = omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG); }