From patchwork Tue Jul 27 11:15:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Codrin Ciubotariu X-Patchwork-Id: 12402543 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1827BC4338F for ; Tue, 27 Jul 2021 11:19:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CDCC56054F for ; Tue, 27 Jul 2021 11:19:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CDCC56054F Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AyRKFVTEOsrTtPBvoRrMcrEDyKENOieI5iF4+Z0JEEY=; b=vBXHShzbr1zTeC rDAHyU5LUqO+nyssZjuk/rdFB7X4NfnL/u+KnOg0QaaHYrrR1/NyPyNmRYJJqafIw6Y8DTlRYBCa1 0FktdXwU8zdHcCGX5c0INvMLMx5IUP7gVaWq9iOm5S8zS+6MT6nHj9OY+i3S6bxhxsQ6P8hhYFAYy MmfaVRYezrYVHE3ejHDxYbr9/ifrH3xugnHpWwVYghtLd10drcWGKex5fne02l4P/Cjr4ZuTRELh/ G0otNpeMfUdGCVDXhN4gmQcdOgSg8t3h9Rl1RzNlMaMYVj4v9/tFI1/7CXF4CYyI2hz/nkqX4/GWF +Y8ZfjLwhadsbWq+p7Zw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8L4V-00Eac4-Ax; Tue, 27 Jul 2021 11:16:27 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8L4G-00EaXT-Tj for linux-arm-kernel@lists.infradead.org; Tue, 27 Jul 2021 11:16:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1627384573; x=1658920573; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LmOuN2SVEtSgfrh3uY3qWbumcwZ7+Y6c5mA+/uQGPx4=; b=WCOMrCpODjG1FFcNOYEzdgTxhHw5Y/fje6Tg4Lf2lh9BooaN49EX0bvb c25jmR0BBs4BEvzvgPCPOW85uFk0aaWUblKxR21T/H3ns1QDqOj52q0CH Beg3GINm5FvTjZSyBJgSXYcBjBI+DKZEmVZ2BYWD1+VfP2qWOVliPUz/y fCHwmErWj5l7wS+s0LJc0T+rbYljAYXAao/mQJDD9vx2I1nECTiiafr9E 1qVlURPMH+NMlakUh0AmrT2IO4LFT5YTq2Iw8cN3RVdQ/0qYRKrxBUk9a 4FrFEt6e9lboRnoi1yhS1lZY2SyeCWJXG/IuJzaWQtyM/zCU9IHSQedRx Q==; IronPort-SDR: okGvVLCzbmU3BhDmS3Fi/GveNvMwePKJVkXXSMG3FK9SkdeXKXitFXLuoXC6Yvixex2gyJwz6s /ltff842MnPKvs+BmhRxbpUCyKbnLj1xONtWnjtJ4o4hzH6wa40E8M55NEgT3IxsMI+UJgcn3c 6k7WqQswwY7zZOs1AKLt9OvucO9aRiGeUgaxjJF6XGGUPOrlrw1tQ8OVZY/yM0B1iKhzU89rj/ XgxnnNXX4SXG4l1KG0GTf8kxgxQgwAJ/Plh9rNfXeGmI1rkZaz/q3oAPSBjglr0OOOaVLkAevi I8C8YS7APRmWeIUqFUB5gKeK X-IronPort-AV: E=Sophos;i="5.84,273,1620716400"; d="scan'208";a="126088286" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 27 Jul 2021 04:16:12 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.87.72) by chn-vm-ex02.mchp-main.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 27 Jul 2021 04:16:11 -0700 Received: from rob-ult-m19940.amer.actel.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Tue, 27 Jul 2021 04:16:08 -0700 From: Codrin Ciubotariu To: , , Subject: [PATCH 1/3] i2c: at91: move i2c_recover_bus() outside of at91_do_twi_transfer() Date: Tue, 27 Jul 2021 14:15:52 +0300 Message-ID: <20210727111554.1338832-2-codrin.ciubotariu@microchip.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210727111554.1338832-1-codrin.ciubotariu@microchip.com> References: <20210727111554.1338832-1-codrin.ciubotariu@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210727_041613_108743_4B8C8570 X-CRM114-Status: GOOD ( 12.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alexandre.belloni@bootlin.com, wsa@kernel.org, mhoffman@lightlink.com, ludovic.desroches@microchip.com, khali@linux-fr.org, andrew@sanpeople.com, Codrin Ciubotariu Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch doesn't add a functional change, it just separates the recovery from the transfer itself. Fixes: d3d3fdcc4c90 ("i2c: at91: implement i2c bus recovery") Signed-off-by: Codrin Ciubotariu --- drivers/i2c/busses/i2c-at91-master.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/i2c/busses/i2c-at91-master.c b/drivers/i2c/busses/i2c-at91-master.c index 1cceb6866689..0352dc09d697 100644 --- a/drivers/i2c/busses/i2c-at91-master.c +++ b/drivers/i2c/busses/i2c-at91-master.c @@ -639,13 +639,6 @@ static int at91_do_twi_transfer(struct at91_twi_dev *dev) AT91_TWI_THRCLR | AT91_TWI_LOCKCLR); } - /* - * some faulty I2C slave devices might hold SDA down; - * we can send a bus clear command, hoping that the pins will be - * released - */ - i2c_recover_bus(&dev->adapter); - return ret; } @@ -705,7 +698,17 @@ static int at91_twi_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, int num) ret = at91_do_twi_transfer(dev); - ret = (ret < 0) ? ret : num; + if (ret < 0) { + /* + * some faulty I2C slave devices might hold SDA down; + * we can send a bus clear command, hoping that the pins will be + * released + */ + i2c_recover_bus(&dev->adapter); + } else { + ret = num; + } + out: pm_runtime_mark_last_busy(dev->dev); pm_runtime_put_autosuspend(dev->dev);