From patchwork Mon Dec 21 11:29:59 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shishkin X-Patchwork-Id: 69105 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id nBLBVqeJ015783 for ; Mon, 21 Dec 2009 11:31:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756306AbZLULbv (ORCPT ); Mon, 21 Dec 2009 06:31:51 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756221AbZLULbu (ORCPT ); Mon, 21 Dec 2009 06:31:50 -0500 Received: from smtp.nokia.com ([192.100.105.134]:23001 "EHLO mgw-mx09.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755324AbZLULbt (ORCPT ); Mon, 21 Dec 2009 06:31:49 -0500 Received: from vaebh106.NOE.Nokia.com (vaebh106.europe.nokia.com [10.160.244.32]) by mgw-mx09.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id nBLBUUk6028336; Mon, 21 Dec 2009 05:31:33 -0600 Received: from esebh102.NOE.Nokia.com ([172.21.138.183]) by vaebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 21 Dec 2009 13:30:56 +0200 Received: from mgw-sa01.ext.nokia.com ([147.243.1.47]) by esebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Mon, 21 Dec 2009 13:30:56 +0200 Received: from esdhcp04087 (esdhcp041145.research.nokia.com [172.21.41.145]) by mgw-sa01.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id nBLBUssr020027 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Mon, 21 Dec 2009 13:30:54 +0200 Received: from ash by esdhcp04087 with local (Exim 4.69) (envelope-from ) id 1NMgTT-0005WN-HR; Mon, 21 Dec 2009 13:30:51 +0200 From: Alexander Shishkin To: ben-linux@fluff.org Cc: nm@ti.com, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, Alexander Shishkin Subject: [PATCH v2 2/2] omap i2c: add a timeout to the busy waiting Date: Mon, 21 Dec 2009 13:29:59 +0200 Message-Id: <1261394999-20857-3-git-send-email-virtuoso@slind.org> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1261394999-20857-2-git-send-email-virtuoso@slind.org> References: <1261394999-20857-1-git-send-email-virtuoso@slind.org> <1261394999-20857-2-git-send-email-virtuoso@slind.org> X-OriginalArrivalTime: 21 Dec 2009 11:30:56.0649 (UTC) FILETIME=[0FF95F90:01CA8231] X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org 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); }