From patchwork Wed Jun 21 07:24:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Delvare X-Patchwork-Id: 9800983 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 33C99600C5 for ; Wed, 21 Jun 2017 07:24:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AF9F2853D for ; Wed, 21 Jun 2017 07:24:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F8F92854A; Wed, 21 Jun 2017 07:24:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D1622853D for ; Wed, 21 Jun 2017 07:24:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751994AbdFUHYG (ORCPT ); Wed, 21 Jun 2017 03:24:06 -0400 Received: from mx2.suse.de ([195.135.220.15]:38169 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751093AbdFUHYF (ORCPT ); Wed, 21 Jun 2017 03:24:05 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 45DEDABBD; Wed, 21 Jun 2017 07:24:04 +0000 (UTC) Date: Wed, 21 Jun 2017 09:24:02 +0200 From: Jean Delvare To: Linux I2C Cc: Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH v2] i2c: algo-bit: add support for I2C_M_STOP Message-ID: <20170621092402.773a4b14@endymion> Organization: SUSE Linux X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.31; x86_64-suse-linux-gnu) MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Support for enforced STOPs will allow us to use SCCB compatible devices. Based on a preliminary patch by Wolfram Sang. Signed-off-by: Jean Delvare Tested-by: Wolfram Sang --- Changes since v1: * Simplify logic drivers/i2c/algos/i2c-algo-bit.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) --- linux-4.11.orig/drivers/i2c/algos/i2c-algo-bit.c 2017-06-19 09:57:17.949074198 +0200 +++ linux-4.11/drivers/i2c/algos/i2c-algo-bit.c 2017-06-21 09:07:07.910049960 +0200 @@ -553,9 +553,18 @@ static int bit_xfer(struct i2c_adapter * nak_ok = pmsg->flags & I2C_M_IGNORE_NAK; if (!(pmsg->flags & I2C_M_NOSTART)) { if (i) { - bit_dbg(3, &i2c_adap->dev, "emitting " - "repeated start condition\n"); - i2c_repstart(adap); + if (msgs[i - 1].flags & I2C_M_STOP) { + bit_dbg(3, &i2c_adap->dev, + "emitting enforced stop condition\n"); + i2c_stop(adap); + bit_dbg(3, &i2c_adap->dev, + "emitting start condition\n"); + i2c_start(adap); + } else { + bit_dbg(3, &i2c_adap->dev, + "emitting repeated start condition\n"); + i2c_repstart(adap); + } } ret = bit_doAddress(i2c_adap, pmsg); if ((ret != 0) && !nak_ok) {