From patchwork Fri Nov 16 20:05:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Weaver X-Patchwork-Id: 999121 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=weaverpad.net Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=weaverpad.net header.i=@weaverpad.net header.b="eEA2ps2f"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42xTjW6qw4z9s3x for ; Sat, 17 Nov 2018 07:05:03 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725854AbeKQGSu (ORCPT ); Sat, 17 Nov 2018 01:18:50 -0500 Received: from weaverpad.net ([107.170.225.214]:49488 "EHLO mail.weaverpad.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725763AbeKQGSt (ORCPT ); Sat, 17 Nov 2018 01:18:49 -0500 Received: from server.chicago.weaver.network (unknown [24.15.188.62]) by mail.weaverpad.net (Postfix) with ESMTPSA id 3A8A841E3A for ; Fri, 16 Nov 2018 20:05:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=weaverpad.net; s=mail; t=1542398702; bh=t1o1o5q8KBrAZvtWE92WAlo88MF6/QjDJhrAxK8jSRo=; h=Date:From:To:Subject:From; b=eEA2ps2fIlhyJzsCGRhiLMmwJJxK0eonV4D4hPPuXtU8xIGnBYYbwo58tGFDLIX6c ogtlFFSQJdoWx6xgJGJIYYvnphvyTIP5+7nhPZDwswKz+gbdgpipOfEMxFL2x9Abc3 shwgI3JVN/J9/ExzD8b2OPhIEfuR10P5Sy/esdE7oMc7fH2wKnHudirl3nL8jZXHSw V8McU1NzOr925x8lVY5fjpewMghLphBeMej5drisNxi8Tnejg0aCV+NCeLahaAZxR2 m2aP8B3x/5STnzMjTRAjZ9FZvDEE7C3zc0mmwRWerYV/s6JW1DXLoGc4BFISP0Et97 n2YmCHXX45JgA== Date: Fri, 16 Nov 2018 14:05:00 -0600 From: Steven Weaver To: linux-i2c@vger.kernel.org Subject: [PATCH v3] i2c: imx: check bus for busy before signaling start condition. Message-ID: <20181116200456.GA26105@server.chicago.weaver.network> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Setting MSTA in I2CR signals a start condition on the bus. In a multi-master scenario, this can clobber a transaction already in progress. Signed-off-by: Steven Weaver --- drivers/i2c/busses/i2c-imx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index c406700789e1..8691b7fd6980 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -536,6 +536,9 @@ static int i2c_imx_start(struct imx_i2c_struct *i2c_imx) usleep_range(50, 150); /* Start I2C transaction */ + result = i2c_imx_bus_busy(i2c_imx, 0); + if (result) + return result; temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR); temp |= I2CR_MSTA; imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);