From patchwork Tue Jan 9 13:58:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 10152103 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 C0466602CA for ; Tue, 9 Jan 2018 13:59:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2E4C289D6 for ; Tue, 9 Jan 2018 13:59:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7EAC289EC; Tue, 9 Jan 2018 13:59:15 +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 3BF40289D6 for ; Tue, 9 Jan 2018 13:59:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755587AbeAIN7M (ORCPT ); Tue, 9 Jan 2018 08:59:12 -0500 Received: from sauhun.de ([88.99.104.3]:41841 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753201AbeAIN7K (ORCPT ); Tue, 9 Jan 2018 08:59:10 -0500 Received: from localhost (p54B33354.dip0.t-ipconnect.de [84.179.51.84]) by pokefinder.org (Postfix) with ESMTPSA id DCF032C5EC5; Tue, 9 Jan 2018 14:59:08 +0100 (CET) From: Wolfram Sang To: linux-i2c@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Phil Reid , Wolfram Sang Subject: [PATCH v2 5/6] i2c: send STOP after successful bus recovery Date: Tue, 9 Jan 2018 14:58:58 +0100 Message-Id: <20180109135859.20771-6-wsa@the-dreams.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180109135859.20771-1-wsa@the-dreams.de> References: <20180109135859.20771-1-wsa@the-dreams.de> 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 From: Wolfram Sang If we managed to get a client release SDA again, send a STOP afterwards to make sure we have a consistent state on the bus again. Tested-by: Phil Reid Signed-off-by: Wolfram Sang --- drivers/i2c/i2c-core-base.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 54cef80990a11a..23f353630db32f 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -199,6 +199,18 @@ int i2c_generic_scl_recovery(struct i2c_adapter *adap) if (bri->get_sda && !bri->get_sda(adap)) ret = -EBUSY; + /* If all went well, send STOP for a sane bus state. */ + if (ret == 0 && bri->set_sda) { + bri->set_scl(adap, 0); + ndelay(RECOVERY_NDELAY / 2); + bri->set_sda(adap, 0); + ndelay(RECOVERY_NDELAY / 2); + bri->set_scl(adap, 1); + ndelay(RECOVERY_NDELAY / 2); + bri->set_sda(adap, 1); + ndelay(RECOVERY_NDELAY / 2); + } + if (bri->unprepare_recovery) bri->unprepare_recovery(adap);