From patchwork Fri Sep 17 03:02:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Povey X-Patchwork-Id: 187072 Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o8H34VHr021300 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 17 Sep 2010 03:05:07 GMT Received: from dlep33.itg.ti.com ([157.170.170.112]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id o8H32Tu4007274 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 16 Sep 2010 22:02:29 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id o8H32S7o003891; Thu, 16 Sep 2010 22:02:28 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 6F1E580627; Thu, 16 Sep 2010 22:02:28 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp52.itg.ti.com (dflp52.itg.ti.com [128.247.22.96]) by linux.omap.com (Postfix) with ESMTP id 17A9180626 for ; Thu, 16 Sep 2010 22:02:26 -0500 (CDT) Received: from red.ext.ti.com (localhost [127.0.0.1]) by dflp52.itg.ti.com (8.13.7/8.13.7) with ESMTP id o8H32PUs025821 for ; Thu, 16 Sep 2010 22:02:25 -0500 (CDT) Received: from psmtp.com (na3sys009amx166.postini.com [74.125.149.92]) by red.ext.ti.com (8.13.7/8.13.7) with SMTP id o8H32Og0027115 for ; Thu, 16 Sep 2010 22:02:24 -0500 Received: from source ([122.28.30.136]) by na3sys009amx166.postini.com ([74.125.148.10]) with SMTP; Thu, 16 Sep 2010 20:02:24 PDT Received: from localhost.localdomain (p4095-ipbf4103marunouchi.tokyo.ocn.ne.jp [123.224.193.95]) by smtp.sand.ocn.ne.jp (Postfix) with ESMTP id 9CAAE240B; Fri, 17 Sep 2010 12:02:22 +0900 (JST) From: Jon Povey To: linux-i2c@vger.kernel.org, davinci-linux-open-source@linux.davincidsp.com Subject: [PATCH v3] i2c: davinci: Fix race when setting up for TX Date: Fri, 17 Sep 2010 12:02:11 +0900 Message-Id: <1284692531-10100-1-git-send-email-jon.povey@racelogic.co.uk> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1284691607-9697-1-git-send-email-jon.povey@racelogic.co.uk> References: <1284691607-9697-1-git-send-email-jon.povey@racelogic.co.uk> X-pstn-levels: (S:98.24817/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] 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@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 17 Sep 2010 03:05:07 +0000 (UTC) diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c index 2222c87..b8feac5 100644 --- a/drivers/i2c/busses/i2c-davinci.c +++ b/drivers/i2c/busses/i2c-davinci.c @@ -357,9 +357,6 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop) dev->terminate = 0; - /* write the data into mode register */ - davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag); - /* * First byte should be set here, not after interrupt, * because transmit-data-ready interrupt can come before @@ -371,6 +368,9 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop) dev->buf_len--; } + /* write the data into mode register; start transmitting */ + davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag); + r = wait_for_completion_interruptible_timeout(&dev->cmd_complete, dev->adapter.timeout); if (r == 0) {