From patchwork Fri Aug 31 14:30:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 964483 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=none (p=none dis=none) header.from=socionext.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.b="xsL5jW22"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4221yR3Znbz9rvt for ; Sat, 1 Sep 2018 00:31:43 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728637AbeHaSjW (ORCPT ); Fri, 31 Aug 2018 14:39:22 -0400 Received: from conuserg-08.nifty.com ([210.131.2.75]:52188 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727572AbeHaSjV (ORCPT ); Fri, 31 Aug 2018 14:39:21 -0400 X-Greylist: delayed 24953 seconds by postgrey-1.27 at vger.kernel.org; Fri, 31 Aug 2018 14:39:20 EDT Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-08.nifty.com with ESMTP id w7VEUp9h030172; Fri, 31 Aug 2018 23:30:52 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com w7VEUp9h030172 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1535725852; bh=jBo3wS4BA/zEKJYcB1wVpZfBl26y6JDoM9tDdtPZ9Uk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xsL5jW22IxiUCteSf958nAur4ohTscf/fPVZQ7tws28ndKz/2aIgonD0lqzBV31Rm ok3u2z9KUVvd3l3iwIdesBXZseMkxkeJuk80rIZfzkOmt93idua8pr8/SZHWpyrF4U ZWx3fI2wnZ7D9ScHdcssudxoijyFIjsCdUfiIFLdsHKShyhkags+CdxowCFjRD4FX5 UH+KKFOgAOLW0yGxoAU9fF5gk/dbh1C+mBoMdHbU55C/AxlJ43Bxb54QsVdFIJcK0p RPQRXJeRu8I5UGLnGNMC5kzMNKMs8GxhYgbvod16EbKdo9J2/81PACdnqy7suU+KbE zcoDo4StxgVjw== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada To: linux-i2c@vger.kernel.org Cc: Wolfram Sang , Masahiro Yamada , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] i2c: uniphier-f: issue STOP only for last message or I2C_M_STOP Date: Fri, 31 Aug 2018 23:30:48 +0900 Message-Id: <1535725848-4076-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535725848-4076-1-git-send-email-yamada.masahiro@socionext.com> References: <1535725848-4076-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org This driver currently emits a STOP if the next message is not I2C_MD_RD. It should not do it because it disturbs the I2C_RDWR ioctl, where read/write transactions are combined without STOP between. Issue STOP only when the message is the last one _or_ flagged with I2C_M_STOP. Fixes: 6a62974b667f ("i2c: uniphier_f: add UniPhier FIFO-builtin I2C driver") Signed-off-by: Masahiro Yamada --- drivers/i2c/busses/i2c-uniphier-f.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/busses/i2c-uniphier-f.c b/drivers/i2c/busses/i2c-uniphier-f.c index 9918bdd..a403e85 100644 --- a/drivers/i2c/busses/i2c-uniphier-f.c +++ b/drivers/i2c/busses/i2c-uniphier-f.c @@ -401,11 +401,8 @@ static int uniphier_fi2c_master_xfer(struct i2c_adapter *adap, return ret; for (msg = msgs; msg < emsg; msg++) { - /* If next message is read, skip the stop condition */ - bool stop = !(msg + 1 < emsg && msg[1].flags & I2C_M_RD); - /* but, force it if I2C_M_STOP is set */ - if (msg->flags & I2C_M_STOP) - stop = true; + /* Emit STOP if it is the last message or I2C_M_STOP is set. */ + bool stop = (msg + 1 == emsg) || (msg->flags & I2C_M_STOP); ret = uniphier_fi2c_master_xfer_one(adap, msg, stop); if (ret)