Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp628760imm; Wed, 23 May 2018 02:57:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrvgo1TiJIgBnjXJQ40kfiX0qPFUx35wphjcfhdwXL4FcoTTUyp2+kZUIlfynWvmt3o4VaO X-Received: by 2002:a63:6107:: with SMTP id v7-v6mr1054037pgb.264.1527069467711; Wed, 23 May 2018 02:57:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527069467; cv=none; d=google.com; s=arc-20160816; b=Aeqc76N5Bqav82CtODlyRJW9YyxltABnLMIBUnYEUhbAPxnipecNcHaqREASAiUebO ukBlSEt4c4GLYTL2G1CnC2u39C0wrZUTULMvvSW166PWEzicOnRZcjYpDTb+Ulb6FPJ3 8ZchijyVtvbgPUnZaM/kU0funU/yZ/52nm4xpksA6WZ5UAVhLTutpbcNYIymWRoOFfZs hVrrXL23Y/HWDLAXIwWmSoI+eNtGTn0cW8rvW6T347FRb2eTC7Opl0vmsh8VSoEUcKgC v3VSX+SMGWaOb/Zd32igQSYeTFnTztpBMWWTb/83o13EghbNBHx4nWQ5a6eHyjBnLdqu 7j6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=9FmV4vdjqqeW1PPYZnwpm8QzQHNpH4eDYP4EzpaP/FE=; b=YpvXO3524ntueLecBsa2yvxUTr4y6oTU9AIH9aJojM0hajyp6pVoM0ZPaIdt0BXOsn rkML6j+q8BLvhDVOBAFgrZiqztqeRVQnTpnC7CHymxO00RvOBe5zjsOphdMi25XMV9wS 9DCG6LW/FH5cMoEhFCf52P9ItpR2wBnjnFtMD+YLarmvSrP3DpJNnw51VmRcob/aec5j ezcLSP3DwHn1ZWai1QJLtwufoS2EQG/LMrQaFxiIRndSS3L6BBfm6xL4eHdElZ4GBVsp wvTtjAZW59UBoysp+sDFZLgm6gMYbXjBACX0gGlp8r04ZKvODblhaMiKE3RtFHBMRaex R8hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=uKUuSrd+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6-v6si19193036pfc.186.2018.05.23.02.57.32; Wed, 23 May 2018 02:57:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=uKUuSrd+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932343AbeEWJ4n (ORCPT + 99 others); Wed, 23 May 2018 05:56:43 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:38981 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932180AbeEWJ4f (ORCPT ); Wed, 23 May 2018 05:56:35 -0400 Received: by mail-wm0-f68.google.com with SMTP id f8-v6so7443237wmc.4; Wed, 23 May 2018 02:56:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=9FmV4vdjqqeW1PPYZnwpm8QzQHNpH4eDYP4EzpaP/FE=; b=uKUuSrd+Ffish92oXCQZkDKqE9d4z8m+TXwbYowDQtVJMqChtlZhoskxdl0c+sngNU yx9yRtdkgkSnK75Mi1OyAG1IxYDmiHGWXGj5M0ykOwQSe+pFcv10Moa5Od13dKt+UF+F HB+iw/HSUapK0v6Lng6fy6uDU9b2jC4soQcJKV+cIcVdP90a2ZsGI8Z67QXny34lPKYK BQ+Thsn68T27AKraVjU5ZER25VFhxmQ8S2A3cpfS0LWtt72EO0ieWJZTiCbQhYPrg+Rw 1ks6PC87opOJYt36sWhH530r0V/PclnQX8+hyaiPFYvPx+G1WCtgQScS2C7mFM9Xt2p3 CCZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=9FmV4vdjqqeW1PPYZnwpm8QzQHNpH4eDYP4EzpaP/FE=; b=tLrkHGY4kHZJw9Y4aVd0cODk3cqANYakaOdGxAEBfWmLVuk1VelAQpUttZ++BAUwib kEbJ0bAhOU+ALG01hkp7QrwKYciAhvhHHTqHaaxGoKmWSt4wSsfD3NAJEpxI+UJqEuqI qQgG93nT5bMUrHEQyMSZsAX1MIMQT4eY/IH1XrhNFDQElFRvEsVGbpHxTCiTdiJrx5zm 3sw5o7rHEXNkDKNjLu9AgJWvVvQcdHGURbJjks5EjaXwo2025vFF+1DNk+NJqjJ6MEO+ M5ePNwRiKwQaAw7RO+MP5H8FZ1FeWrRM1/vfni4/OoIdpHYrIleMIE7mN865SymGywd0 puDA== X-Gm-Message-State: ALKqPwcKKt5orWmwT28aMWODUJV3LeIxbNCFnduT8W+UE/Mr00hwiNpE AMazTqz6yXuAql43HnAZ5fkQhmhwmbY= X-Received: by 2002:a2e:9158:: with SMTP id q24-v6mr1312068ljg.73.1527069394248; Wed, 23 May 2018 02:56:34 -0700 (PDT) Received: from localhost ([87.54.42.112]) by smtp.gmail.com with ESMTPSA id n5-v6sm3373662ljh.84.2018.05.23.02.56.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 May 2018 02:56:33 -0700 (PDT) From: Esben Haabendal To: linux-i2c@vger.kernel.org Cc: Esben Haabendal , Wolfram Sang , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Lucas Stach , Philipp Zabel , Michail Georgios Etairidis , Wei Jinhua , Phil Reid , linux-kernel@vger.kernel.org Subject: [PATCH 3/4] i2c: imx: Simplify stopped state tracking Date: Wed, 23 May 2018 11:56:22 +0200 Message-Id: <20180523095623.3347-4-esben.haabendal@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180523095623.3347-1-esben.haabendal@gmail.com> References: <20180523095623.3347-1-esben.haabendal@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Esben Haabendal Always update the stopped state when busy status have been checked. This is identical to what was done before, with the exception of error handling. Without this change, some errors cause the stopped state to be left in incorrect state in i2c_imx_stop(), i2c_imx_dma_read(), i2c_imx_read() and i2c_imx_xfer(). Signed-off-by: Esben Haabendal --- drivers/i2c/busses/i2c-imx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 742b548437af..f9c99b123188 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -430,10 +430,14 @@ static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy) return -EAGAIN; } - if (for_busy && (temp & I2SR_IBB)) + if (for_busy && (temp & I2SR_IBB)) { + i2c_imx->stopped = 0; break; - if (!for_busy && !(temp & I2SR_IBB)) + } + if (!for_busy && !(temp & I2SR_IBB)) { + i2c_imx->stopped = 1; break; + } if (time_after(jiffies, orig_jiffies + msecs_to_jiffies(500))) { dev_dbg(&i2c_imx->adapter.dev, "<%s> I2C bus is busy\n", __func__); @@ -547,7 +551,6 @@ static int i2c_imx_start(struct imx_i2c_struct *i2c_imx) result = i2c_imx_bus_busy(i2c_imx, 1); if (result) return result; - i2c_imx->stopped = 0; temp |= I2CR_IIEN | I2CR_MTX | I2CR_TXAK; temp &= ~I2CR_DMAEN; @@ -578,7 +581,6 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx) if (!i2c_imx->stopped) { i2c_imx_bus_busy(i2c_imx, 0); - i2c_imx->stopped = 1; } /* Disable I2C controller */ @@ -733,7 +735,6 @@ static int i2c_imx_dma_read(struct imx_i2c_struct *i2c_imx, temp &= ~(I2CR_MSTA | I2CR_MTX); imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR); i2c_imx_bus_busy(i2c_imx, 0); - i2c_imx->stopped = 1; } else { /* * For i2c master receiver repeat restart operation like: @@ -861,7 +862,6 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, struct i2c_msg *msgs, bo temp &= ~(I2CR_MSTA | I2CR_MTX); imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR); i2c_imx_bus_busy(i2c_imx, 0); - i2c_imx->stopped = 1; } else { /* * For i2c master receiver repeat restart operation like: -- 2.17.0