Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp339031imm; Mon, 9 Jul 2018 02:45:20 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfWhO1U2d4GBLeAfNWeBDr3ruBd29xNEMN/C0BduNkZlYrN3lDSwpaEU952rrwAPacbRJp8 X-Received: by 2002:a62:3545:: with SMTP id c66-v6mr3770652pfa.63.1531129520234; Mon, 09 Jul 2018 02:45:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531129520; cv=none; d=google.com; s=arc-20160816; b=RmvoSvRzNSJDspsEdGmuQ1NCmtxkX0HQzom280GV9JvNF785B9m/KWXdlbSP0ZCKoJ CH9Kyc10EY9ZzHW6UPkHd9Rga7jdIWJLUHsLRKyl2/H3CJWIoU1LB9VckyeoRBdBwA9z yu068TZWXZ3pin9N8lNfiZIPeFoVfrKPL8JIuyEctpZsAS9C9VZfQNCe2t1qW9sWhz87 /kjrAyQykC0RIE5SX8EwKwvwcHTGkIJdmKPl+ZjCHjA+7SZdNREdb9V4DV2AaEazvl+O 4YxTiQjvsPNO2uWQ00E0RYmaFnCmnCr6UT0rRyhNFTqPBMLauoqU2pqlRQ8DhE4DqBFt yNUQ== 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=ACdevhe59HqxDEaM7CGxNaIQFaq7aeM3wEmuzAxHDTs=; b=p/5IrtWX5JOVfs9/vsuMEXpC8olRbkH2zmeQKAG8peX81fwHXArusrz1nwMF0Vp82j yL4cXfXBbdjocA6rNkB8zoGhOAVWNnbV1tdyT2J+t553NjJLurcpVCnCzS/BmcEbRDb8 ITDmBc3iqXPz4UP1SHRwDe7qYowmeh8lRze0DYhhHOV4xqBlA9V9E+pGpwl8VQdFrH1t D+as9MhBD3JjHodV78WFrMdsCtMqb4i+HKXsr1qwPyUFQpk5Nl1IsE/XZW0UqUN0w3/x 10iPNsxLl4jUkgDQmQ3gOZJH/CsXUp1n+R3XrxBnvSUNSF4pbajS9rIwkpTx4WNVac1P vA6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="T1nQl/1g"; 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 b5-v6si14387011pfo.54.2018.07.09.02.45.05; Mon, 09 Jul 2018 02:45:20 -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="T1nQl/1g"; 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 S1754474AbeGIJn4 (ORCPT + 99 others); Mon, 9 Jul 2018 05:43:56 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:34207 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932436AbeGIJnT (ORCPT ); Mon, 9 Jul 2018 05:43:19 -0400 Received: by mail-lj1-f193.google.com with SMTP id c12-v6so13601894ljj.1; Mon, 09 Jul 2018 02:43:18 -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=ACdevhe59HqxDEaM7CGxNaIQFaq7aeM3wEmuzAxHDTs=; b=T1nQl/1gaBDHAqWSDEmbsvhq1ItVAsZPJjCYhqW0JCTcSpkRO81BTs8kN3XnfLFr02 uLfb9Tg5J0ZRtCsAD8vVHpE6McwB3crmtydYSuJo0iV5iWZmEPnKR2nE2dJm37Obo3oB LpNNQ7BvEGpXGWbb/sEvLfquBmZyfbHi7xFsvCxk8WPA9HB/OyiykXJGOyb5pOl9d88Y oJnteeWsHpL7dDmGM9Wwkf2AIsU4C852qqVGVG9htk0h5eRMWHsQmhiTMJqngm4jEf2Y uiaD3WXfvQKfVcUk1TZTEdlzEmHPSbB6ed1ounQrGCS+KbmiIV5araYE66/mOg2M1Dyr R4nw== 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=ACdevhe59HqxDEaM7CGxNaIQFaq7aeM3wEmuzAxHDTs=; b=kS9jgoxhjlJeUyAKoP5tIB6PuqsHnvJvBMPHK/9z4ir6fmzx8RDP9M+iUyysshuFc6 VxJaS89dyX6+SLHDfBJngmaROsxZJFfAWs20J/PDOrWS4a8iFWDHpPGlmgd2s11mSL7T 1CPo3jHK/AiEnde4uo9IXANcGj5slZ4pvRmNHvXGJ/m+COtBdzeyxZpHz32IDzqBC3qu BL3mTmeM1bNRFOJIUbbXbYTBxfDrpgXjvhvYWD8ZntFirEcF9QpHAn4dxZVWtTL3BvTQ M4fBNfkVLdCODOHN+/vm52mOwPZtGdrrr6TqG0D7S8FC/LK0lSqPNtgM4cP1HiwqcUon cWuw== X-Gm-Message-State: APt69E2nGMzRxiZ8IO7ykLNZpINrASTjbnPK/HIkY0uvuPZ/OXUlwi/E cpkpFuEcHI4wpfS8MB6reOa4tViGw80= X-Received: by 2002:a2e:7c12:: with SMTP id x18-v6mr11774508ljc.71.1531129397465; Mon, 09 Jul 2018 02:43:17 -0700 (PDT) Received: from localhost (87-57-30-174-static.dk.customer.tdc.net. [87.57.30.174]) by smtp.gmail.com with ESMTPSA id e20-v6sm3856684lff.41.2018.07.09.02.43.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jul 2018 02:43:16 -0700 (PDT) From: Esben Haabendal To: linux-i2c@vger.kernel.org Cc: Wolfram Sang , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Rob Herring , Mark Rutland , Yuan Yao , Esben Haabendal , Philipp Zabel , Phil Reid , Lucas Stach , Clemens Gruber , Peter Rosin , Fabio Estevam , linux-kernel@vger.kernel.org Subject: [PATCH v2 3/4] i2c: imx: Simplify stopped state tracking Date: Mon, 9 Jul 2018 11:43:03 +0200 Message-Id: <20180709094304.8814-4-esben.haabendal@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180709094304.8814-1-esben.haabendal@gmail.com> References: <20180709094304.8814-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 d86f152176a4..1db8e6790afc 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -421,10 +421,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__); @@ -538,7 +542,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; @@ -569,7 +572,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 */ @@ -724,7 +726,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: @@ -852,7 +853,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.18.0