From patchwork Thu Sep 20 16:14:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 10608031 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5DE2714BD for ; Thu, 20 Sep 2018 16:15:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A3AA2DB8B for ; Thu, 20 Sep 2018 16:15:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3AC0828786; Thu, 20 Sep 2018 16:15:59 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A534C28786 for ; Thu, 20 Sep 2018 16:15:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=s+1jxZNj7rHKCnDEHdRdoIqgNTxx1RD1Bx5Eon2R7G4=; b=WdisLTESaFtBLYXruNxB8TYmlH OdMmwZ8T/dToQhcRcP1hhcIM06S62EuCcfHyxHlgmAWHoA4zaFs56vCEihM8KDJZ1SLieiUza3hop b1ssiL8EK5R0Nw1POGQoVyIt5HWXnZS6MQ0haTFcWK+6cAGNn33yAAeuSek6NMITjVfANxiLx2lKW a45SWieu5nW+RUzZVGE1/YLk2EFJbTBjwYaqUP87nikaFKjHkOASQohMFZlVvNIxmV/8l089qClbV 7ZHCjlAnIFbu6ffqXM8vRWmlnomtwMNYUJsPN5Xe7lKXSjIPnToepzfwKbT5hXszO4JYAvyd8q+qI QY1Endsg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g31cO-0005GJ-Mk; Thu, 20 Sep 2018 16:15:52 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g31bS-0003cZ-SN for linux-arm-kernel@bombadil.infradead.org; Thu, 20 Sep 2018 16:14:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=HzZFylXDOizFdFCcTj8IbForOT5wWm8HNwzL7sU5vIs=; b=C5gUKNLuhqiJgr44Pt6hUd7kx vCRzhcP/J1MCI2yCR2FXkO5Q7QYA6YWUW4oC+Y6WieAtWUANTK7Hu5WGxxw2jPFwri9bl+REp5qtK Y+aVqWvotln52sECATclq3vy4ul252FopvMr5ImjhgxaVNKmTSkLBj7rdj/6bzomQ/fqzrwqVHPYm Js7GSvwkyB7oU0bHVYNfpN+0O99c+tLgsB32T9MOJZUPoNzHnJJc8+riegM2tDzcjQN+GWxvwBtWQ Ti7N9PkZMIinafB7qD4lrrjblK4yvAS0NoQtZUlX/ye27KKI0xALmiJxNJ6RAb+fNYpw0T43XcMDq 4q+BtODuQ==; Received: from sauhun.de ([88.99.104.3] helo=pokefinder.org) by merlin.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g31bM-0003jw-T2 for linux-arm-kernel@lists.infradead.org; Thu, 20 Sep 2018 16:14:50 +0000 Received: from localhost (i577B999D.versanet.de [87.123.153.157]) by pokefinder.org (Postfix) with ESMTPSA id AC2962E35A2; Thu, 20 Sep 2018 18:14:33 +0200 (CEST) From: Wolfram Sang To: linux-i2c@vger.kernel.org Subject: [RFC PATCH 2/4] i2c: core: remove level of indentation in i2c_transfer Date: Thu, 20 Sep 2018 18:14:21 +0200 Message-Id: <20180920161423.13990-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180920161423.13990-1-wsa+renesas@sang-engineering.com> References: <20180920161423.13990-1-wsa+renesas@sang-engineering.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180920_121449_086283_D97A9595 X-CRM114-Status: GOOD ( 13.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tero Kristo , preid@electromag.com.au, Keerthy , Andy Shevchenko , linux-renesas-soc@vger.kernel.org, Wolfram Sang , Grygorii Strashko , Stefan Lengfeld , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Using the common kernel pattern to bail out at the beginning if some conditions are not met, we can save a level of indentation. No functional change. Signed-off-by: Wolfram Sang Acked-by: Peter Rosin --- drivers/i2c/i2c-core-base.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index c2b352c46fae..799776c6d421 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -1922,6 +1922,11 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) { int ret; + if (!adap->algo->master_xfer) { + dev_dbg(&adap->dev, "I2C level transfers not supported\n"); + return -EOPNOTSUPP; + } + /* REVISIT the fault reporting model here is weak: * * - When we get an error after receiving N bytes from a slave, @@ -1938,25 +1943,19 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) * one (discarding status on the second message) or errno * (discarding status on the first one). */ - - if (adap->algo->master_xfer) { - if (in_atomic() || irqs_disabled()) { - ret = i2c_trylock_bus(adap, I2C_LOCK_SEGMENT); - if (!ret) - /* I2C activity is ongoing. */ - return -EAGAIN; - } else { - i2c_lock_bus(adap, I2C_LOCK_SEGMENT); - } - - ret = __i2c_transfer(adap, msgs, num); - i2c_unlock_bus(adap, I2C_LOCK_SEGMENT); - - return ret; + if (in_atomic() || irqs_disabled()) { + ret = i2c_trylock_bus(adap, I2C_LOCK_SEGMENT); + if (!ret) + /* I2C activity is ongoing. */ + return -EAGAIN; } else { - dev_dbg(&adap->dev, "I2C level transfers not supported\n"); - return -EOPNOTSUPP; + i2c_lock_bus(adap, I2C_LOCK_SEGMENT); } + + ret = __i2c_transfer(adap, msgs, num); + i2c_unlock_bus(adap, I2C_LOCK_SEGMENT); + + return ret; } EXPORT_SYMBOL(i2c_transfer);