From patchwork Mon Apr 22 11:06:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Eibach X-Patchwork-Id: 238444 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 350E12C00FB for ; Mon, 22 Apr 2013 21:13:22 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 596E44A216; Mon, 22 Apr 2013 13:13:15 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LMv05zw0bQ-7; Mon, 22 Apr 2013 13:13:15 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1A0A14A219; Mon, 22 Apr 2013 13:12:51 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 799E04A205 for ; Mon, 22 Apr 2013 13:12:47 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id l53ZoDQ1zG7x for ; Mon, 22 Apr 2013 13:12:45 +0200 (CEST) X-Greylist: delayed 341 seconds by postgrey-1.27 at theia; Mon, 22 Apr 2013 13:12:43 CEST X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from sputnik.urmx.de (sputnik.urmx.de [88.198.51.18]) by theia.denx.de (Postfix) with ESMTP id 3FB054A202 for ; Mon, 22 Apr 2013 13:12:43 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by sputnik.urmx.de (Postfix) with ESMTP id E95EA603434F for ; Mon, 22 Apr 2013 13:07:11 +0200 (CEST) X-Virus-Scanned: amavisd-new at urmx.de Received: from sputnik.urmx.de ([127.0.0.1]) by localhost (sputnik.urmx.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id DQd5VAuP3fBA for ; Mon, 22 Apr 2013 13:07:11 +0200 (CEST) Received: from utm1.gdsys.de (unknown [195.243.218.178]) by mforward1.urmx.de (Postfix) with ESMTPS id 57E4E6034331 for ; Mon, 22 Apr 2013 13:07:11 +0200 (CEST) Received: from [172.16.100.239] (port=55256 helo=smgw1.gd.local) by utm1.gdsys.de with esmtp (Exim 4.76) (envelope-from ) id 1UUEaS-0000Sx-2y for u-boot@lists.denx.de; Mon, 22 Apr 2013 13:07:08 +0200 Received: from smgw1.gd.local (localhost [127.0.0.1]) by smgw1.gd.local (Postfix) with ESMTP id CF44D1A30FA for ; Mon, 22 Apr 2013 13:07:08 +0200 (CEST) From: Dirk Eibach To: u-boot@lists.denx.de Date: Mon, 22 Apr 2013 13:06:42 +0200 Message-Id: <1366628805-29964-4-git-send-email-eibach@gdsys.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1366628805-29964-1-git-send-email-eibach@gdsys.de> References: <1366628805-29964-1-git-send-email-eibach@gdsys.de> X-SafeGuard_MailGateway: Version: 5.80.2.12968 SGMG_SOPHOS Date: 20130422110708Z Cc: Heiko Schocher , Tabi Timur Subject: [U-Boot] [PATCH 3/6] i2c: fsl_i2c: i2c_read(): dont try to write address w/ alen=0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Reinhard Pfau if alen is 0: no longer start a write cycle before reading data. Signed-off-by: Dirk Eibach Signed-off-by: Reinhard Pfau --- drivers/i2c/fsl_i2c.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c index 1c7265d..276386d 100644 --- a/drivers/i2c/fsl_i2c.c +++ b/drivers/i2c/fsl_i2c.c @@ -383,13 +383,16 @@ i2c_read(u8 dev, uint addr, int alen, u8 *data, int length) int i = -1; /* signal error */ u8 *a = (u8*)&addr; - if (i2c_wait4bus() >= 0 + if (i2c_wait4bus() < 0) + return -1; + + if (alen > 0 && i2c_write_addr(dev, I2C_WRITE_BIT, 0) != 0 && __i2c_write(&a[4 - alen], alen) == alen) i = 0; /* No error so far */ if (length - && i2c_write_addr(dev, I2C_READ_BIT, 1) != 0) + && i2c_write_addr(dev, I2C_READ_BIT, alen ? 1 : 0) != 0) i = __i2c_read(data, length); writeb(I2C_CR_MEN, &i2c_dev[i2c_bus_num]->cr);