From patchwork Mon Dec 14 13:21:04 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shishkin X-Patchwork-Id: 67281 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nBEDLfUv025195 for ; Mon, 14 Dec 2009 13:21:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756722AbZLNNVk (ORCPT ); Mon, 14 Dec 2009 08:21:40 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756463AbZLNNVk (ORCPT ); Mon, 14 Dec 2009 08:21:40 -0500 Received: from smtp.nokia.com ([192.100.122.233]:44355 "EHLO mgw-mx06.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756113AbZLNNVj (ORCPT ); Mon, 14 Dec 2009 08:21:39 -0500 Received: from vaebh105.NOE.Nokia.com (vaebh105.europe.nokia.com [10.160.244.31]) by mgw-mx06.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id nBEDLSwq010510; Mon, 14 Dec 2009 15:21:34 +0200 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by vaebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 14 Dec 2009 15:21:23 +0200 Received: from mgw-da02.ext.nokia.com ([147.243.128.26]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Mon, 14 Dec 2009 15:21:21 +0200 Received: from esdhcp04087 (esdhcp041145.research.nokia.com [172.21.41.145]) by mgw-da02.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id nBEDLILA030133 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Mon, 14 Dec 2009 15:21:19 +0200 Received: from ash by esdhcp04087 with local (Exim 4.69) (envelope-from ) id 1NKArT-0002Fs-Jq; Mon, 14 Dec 2009 15:21:15 +0200 From: Alexander Shishkin To: Tony Lindgren Cc: linux-omap@vger.kernel.org, Alexander Shishkin Subject: [PATCH] omap i2c: add timeout to a busy loop in isr Date: Mon, 14 Dec 2009 15:21:04 +0200 Message-Id: <1260796864-8560-1-git-send-email-virtuoso@slind.org> X-Mailer: git-send-email 1.6.3.3 X-OriginalArrivalTime: 14 Dec 2009 13:21:22.0319 (UTC) FILETIME=[544A21F0:01CA7CC0] 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 75bf3ad..7617f18 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -803,15 +803,20 @@ complete: */ if (dev->rev <= OMAP_I2C_REV_ON_3430) { - 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 | OMAP_I2C_STAT_XDR)); - err |= OMAP_I2C_STAT_XUDF; - goto complete; - } - cpu_relax(); - stat = omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG); + unsigned long timeout = 10000; + + while (!(stat & OMAP_I2C_STAT_XUDF) && --timeout) { + if (stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) { + omap_i2c_ack_stat(dev, stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR)); + err |= OMAP_I2C_STAT_XUDF; + goto complete; } + cpu_relax(); + stat = omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG); + } + + if (!timeout) + dev_err(dev->dev, "timeout waiting on XUDF bit\n"); } omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w);