From patchwork Tue Jun 22 07:31:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Povey X-Patchwork-Id: 107348 Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o5M7VitP011292 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 22 Jun 2010 07:32:34 GMT Received: from dlep34.itg.ti.com ([157.170.170.115]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id o5M7VbZq028837 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 22 Jun 2010 02:31:42 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep34.itg.ti.com (8.13.7/8.13.7) with ESMTP id o5M7VZbk026768 for ; Tue, 22 Jun 2010 02:31:36 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 230FF80647 for ; Tue, 22 Jun 2010 02:31:35 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp51.itg.ti.com (dflp51.itg.ti.com [128.247.22.94]) by linux.omap.com (Postfix) with ESMTP id C828D80626 for ; Tue, 22 Jun 2010 02:31:28 -0500 (CDT) Received: from white.ext.ti.com (localhost [127.0.0.1]) by dflp51.itg.ti.com (8.13.7/8.13.7) with ESMTP id o5M7VSM7025965 for ; Tue, 22 Jun 2010 02:31:28 -0500 (CDT) Received: from psmtp.com (na3sys009amx167.postini.com [74.125.149.93]) by white.ext.ti.com (8.13.7/8.13.7) with SMTP id o5M7VQY0030236 for ; Tue, 22 Jun 2010 02:31:26 -0500 Received: from source ([122.28.30.136]) by na3sys009amx167.postini.com ([74.125.148.10]) with SMTP; Tue, 22 Jun 2010 00:31:26 PDT Received: from localhost.localdomain (p4040-ipbf2501marunouchi.tokyo.ocn.ne.jp [122.18.150.40]) by smtp.sand.ocn.ne.jp (Postfix) with ESMTP id 48F7130A1; Tue, 22 Jun 2010 16:31:23 +0900 (JST) From: Jon Povey To: davinci-linux-open-source@linux.davincidsp.com Subject: [PATCH] i2c: davinci: Fix race when setting up for TX Date: Tue, 22 Jun 2010 16:31:03 +0900 Message-Id: <1277191864-5024-1-git-send-email-jon.povey@racelogic.co.uk> X-Mailer: git-send-email 1.6.3.3 X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S:94.58644/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-settings: 2 (0.5000:0.5000) s cv gt3 gt2 gt1 r p m c X-pstn-addresses: from [db-null] Cc: linux-kernel@vger.kernel.org, Philby John , linux-i2c@vger.kernel.org, "Ben Dooks (embedded platforms)" , "Jean Delvare (PC drivers, core)" X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 22 Jun 2010 07:32:34 +0000 (UTC) diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c index 2222c87..72df4af 100644 --- a/drivers/i2c/busses/i2c-davinci.c +++ b/drivers/i2c/busses/i2c-davinci.c @@ -347,14 +347,6 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop) flag &= ~DAVINCI_I2C_MDR_STP; } - /* Enable receive or transmit interrupts */ - w = davinci_i2c_read_reg(dev, DAVINCI_I2C_IMR_REG); - if (msg->flags & I2C_M_RD) - w |= DAVINCI_I2C_IMR_RRDY; - else - w |= DAVINCI_I2C_IMR_XRDY; - davinci_i2c_write_reg(dev, DAVINCI_I2C_IMR_REG, w); - dev->terminate = 0; /* write the data into mode register */ @@ -371,6 +363,14 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop) dev->buf_len--; } + /* Enable receive or transmit interrupts */ + w = davinci_i2c_read_reg(dev, DAVINCI_I2C_IMR_REG); + if (msg->flags & I2C_M_RD) + w |= DAVINCI_I2C_IMR_RRDY; + else + w |= DAVINCI_I2C_IMR_XRDY; + davinci_i2c_write_reg(dev, DAVINCI_I2C_IMR_REG, w); + r = wait_for_completion_interruptible_timeout(&dev->cmd_complete, dev->adapter.timeout); if (r == 0) {