From patchwork Sat Sep 5 20:41:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254815 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 E3DD3C433E2 for ; Sat, 5 Sep 2020 20:46:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ABDCA20760 for ; Sat, 5 Sep 2020 20:46:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bDOJ059S" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728423AbgIEUqR (ORCPT ); Sat, 5 Sep 2020 16:46:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728719AbgIEUml (ORCPT ); Sat, 5 Sep 2020 16:42:41 -0400 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EA82C061246; Sat, 5 Sep 2020 13:42:38 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id m5so4718278lfp.7; Sat, 05 Sep 2020 13:42:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9sDkB98/BqDLzDJtZbPX/ic3OZ6YzNTO88MukIU98YA=; b=bDOJ059SB5waB5YdOiWCNmYXq95rEv+6bqiNjvp3Kr7eLkaPaD9qgoRGLoMnHWc3Wf YCj0SBZ4aLV5S/Ie2gtm338hJxLppFFY1Au10yiKkiOECf/OT2J8ugXkfwTXzd8UXpXT DdlJmltgRyLmc0Bnkh7j7vQXwJSPvjdDYphHIwDrITvFWscbwxFuGNWSTKSO1pLtpHzM kEZUi4Z02LKeOfXRexArDkjtzL7kNrqPrxJWY/JlATZqNCM0J6MSv3XHEwQhN+nhwHm7 zy+lUOddR1huIW5U6qHngOrOKfeZbeY5ScoB5xCDIE8h08WgC1T2dnrGnERuraPHR24K 6ADw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9sDkB98/BqDLzDJtZbPX/ic3OZ6YzNTO88MukIU98YA=; b=pUdYovBh7czHGZgtU9QNaLn5VvAuCMUrxalMGrUEyxx7n1ck912t3zKCo1Hh1Nb5p/ QbfE5HZ4o2hgCziuIhYG64WByP8qdYPirDpYMWqn/CiDwxqF4j+Rj7M0oCO2Y7lzDYLA EXtU/lY0mtnMoV/zXGKAZ3s9+tCh7ZGy0aWH2qZEEM14adpPdvwQf+sjrjV1NBgHFPGF B43oCw4tOfR+gY2lsDW1m9E/rOFLD/NPjboLcGOB2x/7dfYPoEp/WIzPgBg69OPzGt+S 2KPpigjqFyAaVeSL87TEnk+P7S91UZh/ienJbxDHqTsueBVmKIn0ShMPmJKtshKF5V9h N/2g== X-Gm-Message-State: AOAM533kQ7w1rqScatqvw/1a8X4BFZwm47TbfUfJ6KvVx7liEJVK+Vvw f00m0rUgUu3Z5Hh0bfM5/68= X-Google-Smtp-Source: ABdhPJwDv6TQxMYPx5kGwwZ4zd3ynhzOJcgn03qYzFLa3uBFrrRmL/mSORRDtVxXGXwAPEnVkTuV5g== X-Received: by 2002:a19:4a88:: with SMTP id x130mr6729007lfa.31.1599338546862; Sat, 05 Sep 2020 13:42:26 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id e17sm1677763ljn.18.2020.09.05.13.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 13:42:26 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Andy Shevchenko Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 02/31] i2c: tegra: Handle potential error of tegra_i2c_flush_fifos() Date: Sat, 5 Sep 2020 23:41:22 +0300 Message-Id: <20200905204151.25343-3-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200905204151.25343-1-digetx@gmail.com> References: <20200905204151.25343-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Technically the tegra_i2c_flush_fifos() may fail and transfer should be aborted in this case, but this shouldn't ever happen in practice unless there is a bug somewhere in the driver. Let's add the error check just for completeness. Reviewed-by: Michał Mirosław Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index ab88cdd70376..307df6f97ed0 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -1177,7 +1177,9 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, bool dma; u16 xfer_time = 100; - tegra_i2c_flush_fifos(i2c_dev); + err = tegra_i2c_flush_fifos(i2c_dev); + if (err) + return err; i2c_dev->msg_buf = msg->buf; i2c_dev->msg_buf_remaining = msg->len; From patchwork Sat Sep 5 20:41:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254813 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 3065CC2D0E1 for ; Sat, 5 Sep 2020 20:46:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E07FA2074B for ; Sat, 5 Sep 2020 20:46:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JKy7hhk5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728838AbgIEUqR (ORCPT ); Sat, 5 Sep 2020 16:46:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728717AbgIEUmj (ORCPT ); Sat, 5 Sep 2020 16:42:39 -0400 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EC00C061247; Sat, 5 Sep 2020 13:42:38 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id w11so5627786lfn.2; Sat, 05 Sep 2020 13:42:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TDcoq79wxs8DnD5gOirKnGZA0uEtHDM76HfqXVjfgrg=; b=JKy7hhk5iJ6RnN6GuYaE5tlkHfCNHehcAJXHqc5MD5j6cBQdA/ZfwAaXoeqlSSdq3P 7k7EYbcDjgbYHI2U/q7tEZbVyHeioLiuL6+jTvaSJ6lntQjlLv7uHJoti29S4b5PyT2j Y7Ds7s6ZTGkv1FDMS6kc6DROOrsMNmEN36uhLVQyVdgVgtrgP2jWi7gwyGTo0Osr+kQj IwIHDx0XQoI+Ay5Cz9CSFuhJlY9FbcLsVOD8tJHYYYQh9JC6xz4e9p1N4YG1rTzqIkT6 oM1jl23RdErY95Yc3U5ppYELjZ7GvG79VfJzjW/hroM3MMCcgPPocchUPcCZfpgIpQgB h0vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TDcoq79wxs8DnD5gOirKnGZA0uEtHDM76HfqXVjfgrg=; b=hmmz7oRFnJST02g0KPGHp29b22ZfPpe0O7lp3+mtqqG5NoAvDKBwWE8yAIMYK9FEVw 5RLDxUVS5dhpzHotFSKd9wdHot976mOGM7h60FVkH1ACGQrogerbzH+EiYUFIvNbVc8Q XcoKkFLlv+/6wP2yLc5/ZYddjo0dA9KYc/kbAdaB4iQdGF7ku+EyV+AeVKuBAZrT45PN O3fqauaWwMCib2PiYoCQIbWAdG6OVlQEZRrWuvuaV1f8f5sJMgvIaY4ZZhyPR0fVZz1C FAxsvKuZTV6oFd6J7ptnEkKH/g+AZHxNk3O/IseH31WmLhPeTkbknu/xrW79zZX0v+Z3 C/Bg== X-Gm-Message-State: AOAM5325E4Ab2trLLxvI1ILQBuPmAQlB64GQBvHOzuj1Kp5YeekmfHv7 dZNE6dxGXhAuWbp64roYMQw= X-Google-Smtp-Source: ABdhPJxI/zyyEbHmeb5T/XeDSsStWOqOvIt5TtNDql32UsUHW7XKEwYu9NO1GVdrBdEfd5nSg/w0Ug== X-Received: by 2002:a19:4251:: with SMTP id p78mr6880110lfa.154.1599338547735; Sat, 05 Sep 2020 13:42:27 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id e17sm1677763ljn.18.2020.09.05.13.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 13:42:27 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Andy Shevchenko Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 03/31] i2c: tegra: Initialization div-clk rate unconditionally Date: Sat, 5 Sep 2020 23:41:23 +0300 Message-Id: <20200905204151.25343-4-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200905204151.25343-1-digetx@gmail.com> References: <20200905204151.25343-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org It doesn't make sense to conditionalize the div-clk rate changes because rate is fixed and it won't ever change once it's set at the driver's probe time. All further changes are NO-OPs because CCF caches rate and skips rate-change if rate is unchanged. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 307df6f97ed0..56c5aff579b6 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -293,7 +293,7 @@ struct tegra_i2c_dev { bool is_curr_atomic_xfer; }; -static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev, bool clk_reinit); +static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev); static void dvc_writel(struct tegra_i2c_dev *i2c_dev, u32 val, unsigned long reg) @@ -691,7 +691,7 @@ static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev) * domain ON. */ if (i2c_dev->is_vi) { - ret = tegra_i2c_init(i2c_dev, true); + ret = tegra_i2c_init(i2c_dev); if (ret) goto disable_div_clk; } @@ -778,7 +778,7 @@ static void tegra_i2c_vi_init(struct tegra_i2c_dev *i2c_dev) i2c_writel(i2c_dev, 0x0, I2C_TLOW_SEXT); } -static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev, bool clk_reinit) +static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) { u32 val; int err; @@ -836,16 +836,14 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev, bool clk_reinit) if (i2c_dev->hw->has_interface_timing_reg && tsu_thd) i2c_writel(i2c_dev, tsu_thd, I2C_INTERFACE_TIMING_1); - if (!clk_reinit) { - clk_multiplier = (tlow + thigh + 2); - clk_multiplier *= (i2c_dev->clk_divisor_non_hs_mode + 1); - err = clk_set_rate(i2c_dev->div_clk, - i2c_dev->bus_clk_rate * clk_multiplier); - if (err) { - dev_err(i2c_dev->dev, - "failed changing clock rate: %d\n", err); - return err; - } + clk_multiplier = tlow + thigh + 2; + clk_multiplier *= i2c_dev->clk_divisor_non_hs_mode + 1; + + err = clk_set_rate(i2c_dev->div_clk, + i2c_dev->bus_clk_rate * clk_multiplier); + if (err) { + dev_err(i2c_dev->dev, "failed to set div-clk rate: %d\n", err); + return err; } if (!i2c_dev->is_dvc && !i2c_dev->is_vi) { @@ -1317,7 +1315,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, if (!time_left && !completion_done(&i2c_dev->dma_complete)) { dev_err(i2c_dev->dev, "DMA transfer timeout\n"); - tegra_i2c_init(i2c_dev, true); + tegra_i2c_init(i2c_dev); return -ETIMEDOUT; } @@ -1338,7 +1336,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, if (time_left == 0) { dev_err(i2c_dev->dev, "i2c transfer timed out\n"); - tegra_i2c_init(i2c_dev, true); + tegra_i2c_init(i2c_dev); return -ETIMEDOUT; } @@ -1350,7 +1348,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, if (likely(i2c_dev->msg_err == I2C_ERR_NONE)) return 0; - tegra_i2c_init(i2c_dev, true); + tegra_i2c_init(i2c_dev); /* start recovery upon arbitration loss in single master mode */ if (i2c_dev->msg_err == I2C_ERR_ARBITRATION_LOST) { if (!i2c_dev->is_multimaster_mode) @@ -1808,7 +1806,7 @@ static int tegra_i2c_probe(struct platform_device *pdev) if (ret < 0) goto disable_div_clk; - ret = tegra_i2c_init(i2c_dev, false); + ret = tegra_i2c_init(i2c_dev); if (ret) { dev_err(&pdev->dev, "Failed to initialize i2c controller\n"); goto release_dma; @@ -1916,7 +1914,7 @@ static int __maybe_unused tegra_i2c_resume(struct device *dev) if (err) return err; - err = tegra_i2c_init(i2c_dev, false); + err = tegra_i2c_init(i2c_dev); if (err) return err; From patchwork Sat Sep 5 20:41:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254811 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, 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 0EC9BC2D0A8 for ; Sat, 5 Sep 2020 20:46:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC08520738 for ; Sat, 5 Sep 2020 20:46:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EIthBN+1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729031AbgIEUqz (ORCPT ); Sat, 5 Sep 2020 16:46:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728665AbgIEUmd (ORCPT ); Sat, 5 Sep 2020 16:42:33 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97271C061246; Sat, 5 Sep 2020 13:42:30 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id w11so5627810lfn.2; Sat, 05 Sep 2020 13:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QMj/s4K97H8grdOpygKSw68Mm/Tx/Oq6EnRbophVBOI=; b=EIthBN+16r3Z0wTV7VPAVeJH3TqEeOEPRvQa83kBY0blFCdtkp2sMwDsY31rWX/3In p99eBv+4Yb2yNxkf2NboXT1ysxEYgX6x57F5kmkQBhi+aIqeYMtgxFGEdiF+oHq1X8qS JOI99SfzF2vQPM2faY8X2fzOKo1gjB9JwZ/ZPXXLiLRye2yUjoL/iH+qcDHQVuC0V/W8 Q2rgtWvQgrs/nh/BmhQVJRIEU9Rn3tplWa1P7lmSg4C/ch6J6pdPO13+Su4nOJecLgXi 2TEdIv3BdPKp77pqbAzqXkUe5F582osI3Oaq6ZrDw5S+6PmxgdhzglgYskSA14sHgMj+ oULQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QMj/s4K97H8grdOpygKSw68Mm/Tx/Oq6EnRbophVBOI=; b=TISwiSwtC013635m1G+NtZFP3hc9mFx5a6Nqyi/s6PldGqWdM1BBWks0BGqxUAEgpS hnfTf8EMMbtzXWzyR05Wybz7Ld4U9OAOLqqUhnNpOlbVXghzs/k1ItCH+4OiMchoxBj6 BFADMnEoPkkrh1umrKc3dzma0RCc221galz0YlXsIknOAS35x7SyNwPBRDw1HuNBLewP Mp810YU9R29IjY8EWGOeFoiO25DFSfhNsTFCxYPg2Jn6J+XlH3NkwsaNTL+22AXT7GnT 2fmcWZ9NeCvaB9VTxjKJRCtIgws+snjCGO6fnkt6cGCddzlOZWfm24DFOMnNhpxlIhxf IEPQ== X-Gm-Message-State: AOAM532sJFf/uv8taDwPkTqUfqRWjDcNeyPTap/rPyPMQqcuks2L39+g nI2Z1vem7yUg+SMts11Ys8xN9qjqwi8= X-Google-Smtp-Source: ABdhPJywMbhvZcuvk4k5Lnbh1hgdTT1mHZYradysifXwQQAsoNHjT/G3VlUV3V3K9RC26k14Ppn/tg== X-Received: by 2002:a19:915b:: with SMTP id y27mr6819862lfj.134.1599338548671; Sat, 05 Sep 2020 13:42:28 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id e17sm1677763ljn.18.2020.09.05.13.42.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 13:42:28 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Andy Shevchenko Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 04/31] i2c: tegra: Remove i2c_dev.clk_divisor_non_hs_mode member Date: Sat, 5 Sep 2020 23:41:24 +0300 Message-Id: <20200905204151.25343-5-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200905204151.25343-1-digetx@gmail.com> References: <20200905204151.25343-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The "non_hs_mode" divisor value is fixed, thus there is no need to have the variable i2c_dev.clk_divisor_non_hs_mode struct member. Let's remove it and move the mode selection into tegra_i2c_init() where it can be united with the timing selection. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 45 +++++++++++++++------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 56c5aff579b6..f5b9cdb65182 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -250,7 +250,6 @@ struct tegra_i2c_hw_feature { * @msg_buf_remaining: size of unsent data in the message buffer * @msg_read: identifies read transfers * @bus_clk_rate: current I2C bus clock rate - * @clk_divisor_non_hs_mode: clock divider for non-high-speed modes * @is_multimaster_mode: track if I2C controller is in multi-master mode * @tx_dma_chan: DMA transmit channel * @rx_dma_chan: DMA receive channel @@ -281,7 +280,6 @@ struct tegra_i2c_dev { size_t msg_buf_remaining; int msg_read; u32 bus_clk_rate; - u16 clk_divisor_non_hs_mode; bool is_multimaster_mode; struct dma_chan *tx_dma_chan; struct dma_chan *rx_dma_chan; @@ -783,6 +781,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) u32 val; int err; u32 clk_divisor, clk_multiplier; + u32 non_hs_mode; u32 tsu_thd; u8 tlow, thigh; @@ -805,24 +804,32 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) if (i2c_dev->is_vi) tegra_i2c_vi_init(i2c_dev); - /* Make sure clock divisor programmed correctly */ - clk_divisor = FIELD_PREP(I2C_CLK_DIVISOR_HSMODE, - i2c_dev->hw->clk_divisor_hs_mode) | - FIELD_PREP(I2C_CLK_DIVISOR_STD_FAST_MODE, - i2c_dev->clk_divisor_non_hs_mode); - i2c_writel(i2c_dev, clk_divisor, I2C_CLK_DIVISOR); - - if (i2c_dev->bus_clk_rate > I2C_MAX_STANDARD_MODE_FREQ && - i2c_dev->bus_clk_rate <= I2C_MAX_FAST_MODE_PLUS_FREQ) { + switch (i2c_dev->bus_clk_rate) { + case I2C_MAX_STANDARD_MODE_FREQ + 1 ... I2C_MAX_FAST_MODE_PLUS_FREQ: tlow = i2c_dev->hw->tlow_fast_fastplus_mode; thigh = i2c_dev->hw->thigh_fast_fastplus_mode; tsu_thd = i2c_dev->hw->setup_hold_time_fast_fast_plus_mode; - } else { + + if (i2c_dev->bus_clk_rate > I2C_MAX_FAST_MODE_FREQ) + non_hs_mode = i2c_dev->hw->clk_divisor_fast_plus_mode; + else + non_hs_mode = i2c_dev->hw->clk_divisor_fast_mode; + break; + + default: tlow = i2c_dev->hw->tlow_std_mode; thigh = i2c_dev->hw->thigh_std_mode; tsu_thd = i2c_dev->hw->setup_hold_time_std_mode; + non_hs_mode = i2c_dev->hw->clk_divisor_std_mode; + break; } + /* Make sure clock divisor programmed correctly */ + clk_divisor = FIELD_PREP(I2C_CLK_DIVISOR_HSMODE, + i2c_dev->hw->clk_divisor_hs_mode) | + FIELD_PREP(I2C_CLK_DIVISOR_STD_FAST_MODE, non_hs_mode); + i2c_writel(i2c_dev, clk_divisor, I2C_CLK_DIVISOR); + if (i2c_dev->hw->has_interface_timing_reg) { val = FIELD_PREP(I2C_INTERFACE_TIMING_THIGH, thigh) | FIELD_PREP(I2C_INTERFACE_TIMING_TLOW, tlow); @@ -837,7 +844,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) i2c_writel(i2c_dev, tsu_thd, I2C_INTERFACE_TIMING_1); clk_multiplier = tlow + thigh + 2; - clk_multiplier *= i2c_dev->clk_divisor_non_hs_mode + 1; + clk_multiplier *= non_hs_mode + 1; err = clk_set_rate(i2c_dev->div_clk, i2c_dev->bus_clk_rate * clk_multiplier); @@ -1748,18 +1755,6 @@ static int tegra_i2c_probe(struct platform_device *pdev) goto unprepare_fast_clk; } - if (i2c_dev->bus_clk_rate > I2C_MAX_FAST_MODE_FREQ && - i2c_dev->bus_clk_rate <= I2C_MAX_FAST_MODE_PLUS_FREQ) - i2c_dev->clk_divisor_non_hs_mode = - i2c_dev->hw->clk_divisor_fast_plus_mode; - else if (i2c_dev->bus_clk_rate > I2C_MAX_STANDARD_MODE_FREQ && - i2c_dev->bus_clk_rate <= I2C_MAX_FAST_MODE_FREQ) - i2c_dev->clk_divisor_non_hs_mode = - i2c_dev->hw->clk_divisor_fast_mode; - else - i2c_dev->clk_divisor_non_hs_mode = - i2c_dev->hw->clk_divisor_std_mode; - ret = clk_prepare(i2c_dev->div_clk); if (ret < 0) { dev_err(i2c_dev->dev, "Clock prepare failed %d\n", ret); From patchwork Sat Sep 5 20:41:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254812 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, 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 6E720C43461 for ; Sat, 5 Sep 2020 20:46:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3FC062074B for ; Sat, 5 Sep 2020 20:46:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QH+QpIys" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728853AbgIEUqq (ORCPT ); Sat, 5 Sep 2020 16:46:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728680AbgIEUmg (ORCPT ); Sat, 5 Sep 2020 16:42:36 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65008C061251; Sat, 5 Sep 2020 13:42:35 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id n25so874135ljj.4; Sat, 05 Sep 2020 13:42:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ypldeaZCI+lVDyJ1TAp37EOXECCvTrJEiX4igKe1ykw=; b=QH+QpIyscIeZTHooBjaJfExfnHpiSmdsbws1/DCbZGPMav01u6Dptx4d1wUasOKca5 VtyhcgR5dTwUezXkBdrgVduEiD56ju4nIUSdDFERYG8KT7a7zsKzf2qmmHTzUqbrlfXu SK57asEUzEcbj6UVg/BlCqz0FA3DyDquioNMWUyIxHpHbNgkPwItMcAm5Rtzdqu9ruue kaLrBrW0R+tNIfqb5dVIzaS5jLzVF6DalG+liEYiDmSbpl7uCSJCti9zbrovzq6l10JP LfYH5WycQxwrW7OIthry3vDNXE8qvdc9kxKeJ/ThY8xgW0yEg0XIO/3Oio/gMc3/wzkj THIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ypldeaZCI+lVDyJ1TAp37EOXECCvTrJEiX4igKe1ykw=; b=LZzlIlT8A9FRJ4rHe+qqDOiNu1pt2V624ZJpx9Tv7bx69sjNVKOdaxC/eVSylkGdPv bXfpUt2B5R/zYGj87ciXaGIa9cedHxuGcJarkx68Cn0Fk27QALENx02ZyVRp+tYH8VMk 3cQUadgjmVKg7htPYgIW9gcihen1Irbd48JEUS9roIeTwaig5psuvK/GrM2G0D0WDBKE 7J5gtCnNxroNf/bG96HX2+ct1gbOeWBG9Sa1aan9mOPz1h80S0sOe1ZWcJUYZg7BKYv2 5hk6GTI1f/0MQTiNERImHWmLURxJSbO62q8mlOivpOw7xLxONxikiaDvdLdFMkvyiMlu mb7Q== X-Gm-Message-State: AOAM530QqiVboSmPFIz9j9+f4K0ef0HUMfpGKBcd3yET2/KDJfTFQBjs NlopgpcBoJG2xzCRKVhKHS1eakGyTPg= X-Google-Smtp-Source: ABdhPJzNGfYVWpSD8YcJS2AfeXwx42jtBqEyt+WVvD1nvEX7XBJkk8b0ik9qbmvODW/V0gWsjiAa+A== X-Received: by 2002:a2e:8896:: with SMTP id k22mr6186586lji.298.1599338553143; Sat, 05 Sep 2020 13:42:33 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id e17sm1677763ljn.18.2020.09.05.13.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 13:42:32 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Andy Shevchenko Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 09/31] i2c: tegra: Use platform_get_irq() Date: Sat, 5 Sep 2020 23:41:29 +0300 Message-Id: <20200905204151.25343-10-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200905204151.25343-1-digetx@gmail.com> References: <20200905204151.25343-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Use common helper for retrieval of the interrupt number in order to make code cleaner. Note that platform_get_irq() prints error message by itself. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index abcfb53d649c..f1c4334faed3 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -1672,12 +1672,9 @@ static int tegra_i2c_probe(struct platform_device *pdev) base_phys = res->start; - res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); - if (!res) { - dev_err(&pdev->dev, "no irq resource\n"); - return -EINVAL; - } - irq = res->start; + irq = platform_get_irq(pdev, 0); + if (irq < 0) + return irq; div_clk = devm_clk_get(&pdev->dev, "div-clk"); if (IS_ERR(div_clk)) { From patchwork Sat Sep 5 20:41:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254814 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 06D1DC43461 for ; Sat, 5 Sep 2020 20:46:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BDF5520796 for ; Sat, 5 Sep 2020 20:46:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aD6Eowbx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728903AbgIEUqT (ORCPT ); Sat, 5 Sep 2020 16:46:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728704AbgIEUmg (ORCPT ); Sat, 5 Sep 2020 16:42:36 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 604B2C061244; Sat, 5 Sep 2020 13:42:36 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id w3so11781435ljo.5; Sat, 05 Sep 2020 13:42:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GIGeaR/EXi8wiuksPWP/N0eY23B0mtzvQ3a3fQz15Mk=; b=aD6EowbxnBo+ViiNw/F3OeUq4tJddcWLeFkto2z+SPdHHksrLBACJwA8jNRMB7gCNM +rERBWqI7l0P2m3mFfiWGfzjBkKYnou8Ghty95ZyhUdINLdw2Yw+1HFdb3d2JxTFshX7 SXSP1ZYljaFVmHoo4ptFGFjH6dCBLPKyVMa7aG6yBbMr3Z+D3Z0XbSHR+51ENKSImbir S28plwJqWdk74KXyisprtdLxmQTPgAY39GTat8BH+VLy8SUugGJ2/dODGQzj1jwiVMmf IqWB4dncy36RlescpK6yPaZEnaC/Bczw4XcZBmv2hQ47vwichhUCclPZEtFYVAsRgeSv y9cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GIGeaR/EXi8wiuksPWP/N0eY23B0mtzvQ3a3fQz15Mk=; b=Ax9WU9F7CKZ50guhzxG5djh0eY3W/Tgkw5J+1l8rNjZO7DfO7YuXVjl7FEs9okpJ/L 1Xn02jnzsAdGeubHKHaboq46e2GzQh/lDWYHEDeWf0u8/er8TMUZOfouPBSooAVumImt L26KBUgWSqq9Y6W6nUSwEyXp1L1jsg21RqMQjn9f3FWUU3Z0RoGU5Bf+/c8f6qNbsWAN YmHBcv8zTCTQFdodEuHDZdx89JKvbPKAvF1gH/XQNzeOYmanPC6ynSahFM0+fjYE6tG6 XbXeGan0n9JoYObKn9APf/bPRIJuv0PIXWCDelo+wirF0PuhUsIe87LVrlW+Q7lKc26v Q6fA== X-Gm-Message-State: AOAM531PJF54+DZD73ipT9j8yHTjEvLYlwrxK8V6msWH0EA2NGSZPVXc 38tVS166Z7ObhTX8nHsJhUGjDGxO2e4= X-Google-Smtp-Source: ABdhPJy2bFkfPXGnlxcMSLfTlR+W7rfG7mzedVqdBaXtb1vjs6KB7sG8TbPhs1Lg9EnuL+2t1Tt2ZA== X-Received: by 2002:a2e:9b97:: with SMTP id z23mr6284183lji.1.1599338554838; Sat, 05 Sep 2020 13:42:34 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id e17sm1677763ljn.18.2020.09.05.13.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 13:42:34 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Andy Shevchenko Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 11/31] i2c: tegra: Factor out runtime PM and hardware initialization Date: Sat, 5 Sep 2020 23:41:31 +0300 Message-Id: <20200905204151.25343-12-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200905204151.25343-1-digetx@gmail.com> References: <20200905204151.25343-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Factor out runtime PM and hardware initialization into separate function in order have a cleaner error unwinding in the probe function. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 68 +++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 8e4e72dec6ea..6e5af03d0b1d 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -1670,6 +1670,37 @@ static void tegra_i2c_release_clocks(struct tegra_i2c_dev *i2c_dev) clk_bulk_unprepare(i2c_dev->nclocks, i2c_dev->clocks); } +static int tegra_i2c_init_runtime_pm_and_hardware(struct tegra_i2c_dev *i2c_dev) +{ + int ret; + + /* + * VI I2C is in VE power domain which is not always on and not + * an IRQ safe. So, IRQ safe device can't be attached to a non-IRQ + * safe domain as it prevents powering off the PM domain. + * Also, VI I2C device don't need to use runtime IRQ safe as it will + * not be used for atomic transfers. + */ + if (!i2c_dev->is_vi) + pm_runtime_irq_safe(i2c_dev->dev); + + pm_runtime_enable(i2c_dev->dev); + + ret = pm_runtime_get_sync(i2c_dev->dev); + if (ret < 0) { + dev_err(i2c_dev->dev, "runtime resume failed: %d\n", ret); + pm_runtime_disable(i2c_dev->dev); + return ret; + } + + /* initialize hardware state */ + ret = tegra_i2c_init(i2c_dev); + + pm_runtime_put(i2c_dev->dev); + + return ret; +} + static int tegra_i2c_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1728,41 +1759,23 @@ static int tegra_i2c_probe(struct platform_device *pdev) platform_set_drvdata(pdev, i2c_dev); - /* - * VI I2C is in VE power domain which is not always on and not - * an IRQ safe. So, IRQ safe device can't be attached to a non-IRQ - * safe domain as it prevents powering off the PM domain. - * Also, VI I2C device don't need to use runtime IRQ safe as it will - * not be used for atomic transfers. - */ - if (!i2c_dev->is_vi) - pm_runtime_irq_safe(&pdev->dev); - pm_runtime_enable(&pdev->dev); - ret = pm_runtime_get_sync(i2c_dev->dev); - if (ret < 0) { - dev_err(dev, "runtime resume failed\n"); - goto disable_rpm; - } - if (i2c_dev->hw->supports_bus_clear) i2c_dev->adapter.bus_recovery_info = &tegra_i2c_recovery_info; ret = tegra_i2c_init_dma(i2c_dev); if (ret < 0) - goto put_rpm; + goto release_clocks; - ret = tegra_i2c_init(i2c_dev); - if (ret) { - dev_err(&pdev->dev, "Failed to initialize i2c controller\n"); + ret = tegra_i2c_init_runtime_pm_and_hardware(i2c_dev); + if (ret) goto release_dma; - } irq_set_status_flags(i2c_dev->irq, IRQ_NOAUTOEN); ret = devm_request_irq(&pdev->dev, i2c_dev->irq, tegra_i2c_isr, IRQF_NO_SUSPEND, dev_name(&pdev->dev), i2c_dev); if (ret) - goto release_dma; + goto release_rpm; i2c_set_adapdata(&i2c_dev->adapter, i2c_dev); i2c_dev->adapter.owner = THIS_MODULE; @@ -1777,18 +1790,13 @@ static int tegra_i2c_probe(struct platform_device *pdev) if (ret) goto release_dma; - pm_runtime_put(&pdev->dev); - return 0; +release_rpm: + pm_runtime_disable(i2c_dev->dev); release_dma: tegra_i2c_release_dma(i2c_dev); - -put_rpm: - pm_runtime_put_sync(&pdev->dev); - -disable_rpm: - pm_runtime_disable(&pdev->dev); +release_clocks: tegra_i2c_release_clocks(i2c_dev); return ret; From patchwork Sat Sep 5 20:41:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254819 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 0CA93C43461 for ; Sat, 5 Sep 2020 20:44:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C07AC20760 for ; Sat, 5 Sep 2020 20:44:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TQH3mROS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728735AbgIEUmo (ORCPT ); Sat, 5 Sep 2020 16:42:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728713AbgIEUmj (ORCPT ); Sat, 5 Sep 2020 16:42:39 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F7C3C061245; Sat, 5 Sep 2020 13:42:37 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id v23so11835759ljd.1; Sat, 05 Sep 2020 13:42:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=om5ZqYOPV7zYUej5+9JU/7wsUAJSLxumWbEil6zQbhY=; b=TQH3mROSnPqiFC5GgotpGRVgLnIsvuTdMNUq8gIWIbXUbjalS7xrvCFGcI9xcXkD9g TKUbgB220Vjm7mr4YR3XNLsf3wiMQoQkuWi2RX/XY9e4XMIRUS07RWhiX8coZQ7hVQ1B WprOEKphzSD+h+Ga7k+sJO8IClFTvVDRlDgyY/rjveFNeB/k77AksjQ7UWQ7xYc7vdOU /UCWu04V8ZADAIFrfNmejyOvK8Iu2lmWKcS2x1pHHj7BchezcKXlPueO1BmyjyrJLLJY D+85BQUXjPJoMMBwiJsXTkBfNch8YCveCzhpn/huVjYUEsxAcsJCvZX9T3Vmi6OV9KUV 6yVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=om5ZqYOPV7zYUej5+9JU/7wsUAJSLxumWbEil6zQbhY=; b=Tb2cE/+QpRR/YmED06Wkgu+n6PP9O8BTi6BHa5Rnrz4Ur9vrkK/fMVrycemFLn9f1+ 3Hv1J/wiNLUchsJ33QZMFKLxI7DcBVA761g9W0iuZ9WqcroN4Z+Qsq3Pg+2CMyUZFsXf zg1uSvpAWwkeooN7u4nnjWqwd1sGQ/YwpBsRGzQa4yEjNVBG3bPab7Q5a90jd9+QVhOP IjVZ5BbU5OPkKtQIMo2wsEqpcBAg85HqPR05f2OFciTjcP1LDRBiUgTV6minXblg7k3P jR/lUp4ujxXl2Dd4N42maEdrWjFMfjFAl1D6xrozrHPLfsyCbfyEx+Fceo4ewZfOeVkQ wWZg== X-Gm-Message-State: AOAM530e81f7RRALheW6r1GMDj9thEKF1RjTBQCqTfVuH0fPgZpNmT91 9mBsCMixMzsbMgImnvDQxnc= X-Google-Smtp-Source: ABdhPJyQtkh+776YlePdn2LGvn/pl5vPELb5m/QV1cHzjOk9tK6Mf7xGiW5grew8km+7rg9TZtILoQ== X-Received: by 2002:a2e:964a:: with SMTP id z10mr6719114ljh.463.1599338555890; Sat, 05 Sep 2020 13:42:35 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id e17sm1677763ljn.18.2020.09.05.13.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 13:42:35 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Andy Shevchenko Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 12/31] i2c: tegra: Move out all device-tree parsing into tegra_i2c_parse_dt() Date: Sat, 5 Sep 2020 23:41:32 +0300 Message-Id: <20200905204151.25343-13-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200905204151.25343-1-digetx@gmail.com> References: <20200905204151.25343-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Move out code related to device-tree parsing from the probe function into tegra_i2c_parse_dt() in order to make code more consistent. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 6e5af03d0b1d..d6bc23bf765e 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -1416,6 +1416,12 @@ static void tegra_i2c_parse_dt(struct tegra_i2c_dev *i2c_dev) multi_mode = of_property_read_bool(np, "multi-master"); i2c_dev->is_multimaster_mode = multi_mode; + + if (of_device_is_compatible(np, "nvidia,tegra20-i2c-dvc")) + i2c_dev->is_dvc = true; + + if (of_device_is_compatible(np, "nvidia,tegra210-i2c-vi")) + i2c_dev->is_vi = true; } static const struct i2c_algorithm tegra_i2c_algo = { @@ -1703,7 +1709,6 @@ static int tegra_i2c_init_runtime_pm_and_hardware(struct tegra_i2c_dev *i2c_dev) static int tegra_i2c_probe(struct platform_device *pdev) { - struct device *dev = &pdev->dev; struct tegra_i2c_dev *i2c_dev; struct resource *res; void __iomem *base; @@ -1747,10 +1752,6 @@ static int tegra_i2c_probe(struct platform_device *pdev) return ret; i2c_dev->hw = of_device_get_match_data(&pdev->dev); - i2c_dev->is_dvc = of_device_is_compatible(pdev->dev.of_node, - "nvidia,tegra20-i2c-dvc"); - i2c_dev->is_vi = of_device_is_compatible(dev->of_node, - "nvidia,tegra210-i2c-vi"); i2c_dev->adapter.quirks = i2c_dev->hw->quirks; i2c_dev->dma_buf_size = i2c_dev->adapter.quirks->max_write_len + I2C_PACKET_HEADER_SIZE; From patchwork Sat Sep 5 20:41:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254817 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 D10C1C2D0A7 for ; Sat, 5 Sep 2020 20:46:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9B1BD208C7 for ; Sat, 5 Sep 2020 20:46:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EcbBZPpW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728977AbgIEUpq (ORCPT ); Sat, 5 Sep 2020 16:45:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728720AbgIEUml (ORCPT ); Sat, 5 Sep 2020 16:42:41 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A10CC06125C; Sat, 5 Sep 2020 13:42:39 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id c2so11745777ljj.12; Sat, 05 Sep 2020 13:42:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yJ00lOCQCT7ORVZaWpSwIHQEVex93WHqEiG3flihqKQ=; b=EcbBZPpWn5meJPwWS3VmdqlFq4RAakAgIwnyCFxWCnvipviMq2gHi2FnXZaSJlPnyV cFqvUPTvEI2g2452PHIofFZfuoTygFhhrLHQc9lKtPnGCOgbG7bNztQlxEWTC7wQpqOr x0KH3E2wSgAhintBWnFYxLpqRNU25Bf+2CffiXHGkqDqHxGYPErfIZLUD2fXAe1OqOBH VkX87hlQX+MMSFexsM1yono1LsUCa7vugJK2T3LMEfMRR92CFJ9vG0elZGdq030AKICN Q99I4mu7kkq308FTc2iYBGRGGqb7SzWjCYnxp1tgbz3IBYkvJtZIfCetCOWy/kq6O2QW 2g4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yJ00lOCQCT7ORVZaWpSwIHQEVex93WHqEiG3flihqKQ=; b=h8Iv2o66aQrxYLtOE7j0807P8ji+fmo//aGyz4ahI9lvnPD6H0Uz+2EBS1DHktf31d Ijpici9xcZk+YOdW935xq7QFkNRz/VTj7B8jJS4p33Sa6zNvnf9FureVUxupmij8xyVf uoL8kWmw9j3T4FiqXbMJ/mrQKekAC5ZzkfC4mZmiRwC0mHdtuBzyv/Ljzg6K8dug5SUR ByH0YS6eGhwLk/n9dudBET1u1ztDBBpBVXDz5ICVgSMgNjmhYJuzIsWcbsDIvuNlky7v kGbo4Ktvf5/THgcR0M+bjgzE0Sy7C5cU+gk6WzsD+XWIVDtHr6lxnA8PyF25+MCqAnMP SVKg== X-Gm-Message-State: AOAM530FQDxL4ZF9rGo+c/MYwWchsZFHr5fehDA7y+unIehfamlN8yBj 3KN25Av9ZMmXzAzgtVIce6M= X-Google-Smtp-Source: ABdhPJxYZWfuktbdK+RbXnXlojjcRztyAe/wVCxitYso7h7vB8QOure5SDscGnN3gcFmOTm1yY2ZkA== X-Received: by 2002:a05:651c:32b:: with SMTP id b11mr1222693ljp.99.1599338556745; Sat, 05 Sep 2020 13:42:36 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id e17sm1677763ljn.18.2020.09.05.13.42.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 13:42:36 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Andy Shevchenko Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 13/31] i2c: tegra: Clean up probe function Date: Sat, 5 Sep 2020 23:41:33 +0300 Message-Id: <20200905204151.25343-14-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200905204151.25343-1-digetx@gmail.com> References: <20200905204151.25343-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The driver's probe function code is a bit difficult to read. This patch reorders code of the probe function, forming groups of code that are easy to work with. The reset_control_get() now may return -EPROBE_DEFER on newer Tegra SoCs because they use BPMP driver that provides reset controls and BPMP doesn't come up early during boot, previously rst was protected by other checks error checks in the code, hence dev_err_probe() is used now for the rst. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 120 +++++++++++++++++---------------- 1 file changed, 63 insertions(+), 57 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index d6bc23bf765e..d8b7373673ea 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -440,6 +440,9 @@ static int tegra_i2c_init_dma(struct tegra_i2c_dev *i2c_dev) i2c_dev->tx_dma_chan = chan; + i2c_dev->dma_buf_size = i2c_dev->hw->quirks->max_write_len + + I2C_PACKET_HEADER_SIZE; + dma_buf = dma_alloc_coherent(i2c_dev->dev, i2c_dev->dma_buf_size, &dma_phys, GFP_KERNEL | __GFP_NOWARN); if (!dma_buf) { @@ -1711,85 +1714,88 @@ static int tegra_i2c_probe(struct platform_device *pdev) { struct tegra_i2c_dev *i2c_dev; struct resource *res; - void __iomem *base; - phys_addr_t base_phys; - int irq; - int ret; - - base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); - if (IS_ERR(base)) - return PTR_ERR(base); - - base_phys = res->start; - - irq = platform_get_irq(pdev, 0); - if (irq < 0) - return irq; + int err; i2c_dev = devm_kzalloc(&pdev->dev, sizeof(*i2c_dev), GFP_KERNEL); if (!i2c_dev) return -ENOMEM; - i2c_dev->base = base; - i2c_dev->base_phys = base_phys; - i2c_dev->adapter.algo = &tegra_i2c_algo; - i2c_dev->adapter.retries = 1; - i2c_dev->adapter.timeout = 6 * HZ; - i2c_dev->irq = irq; + platform_set_drvdata(pdev, i2c_dev); + + init_completion(&i2c_dev->msg_complete); + init_completion(&i2c_dev->dma_complete); + + i2c_dev->hw = of_device_get_match_data(&pdev->dev); i2c_dev->cont_id = pdev->id; i2c_dev->dev = &pdev->dev; - i2c_dev->rst = devm_reset_control_get_exclusive(&pdev->dev, "i2c"); + /* initialize virt base of hardware registers */ + i2c_dev->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); + if (IS_ERR(i2c_dev->base)) + return PTR_ERR(i2c_dev->base); + + /* initialize phys base of hardware registers */ + i2c_dev->base_phys = res->start; + + /* initialize controller's interrupt */ + err = platform_get_irq(pdev, 0); + if (err < 0) + return err; + + i2c_dev->irq = err; + + /* interrupt will be enabled during of transfer time */ + irq_set_status_flags(i2c_dev->irq, IRQ_NOAUTOEN); + + err = devm_request_irq(i2c_dev->dev, i2c_dev->irq, tegra_i2c_isr, + IRQF_NO_SUSPEND, dev_name(i2c_dev->dev), + i2c_dev); + if (err) + return err; + + /* initialize hardware reset control */ + i2c_dev->rst = devm_reset_control_get_exclusive(i2c_dev->dev, "i2c"); if (IS_ERR(i2c_dev->rst)) { - dev_err(&pdev->dev, "missing controller reset\n"); + dev_err_probe(i2c_dev->dev, PTR_ERR(i2c_dev->rst), + "failed to get reset control\n"); return PTR_ERR(i2c_dev->rst); } tegra_i2c_parse_dt(i2c_dev); - ret = tegra_i2c_init_clocks(i2c_dev); - if (ret) - return ret; - - i2c_dev->hw = of_device_get_match_data(&pdev->dev); - i2c_dev->adapter.quirks = i2c_dev->hw->quirks; - i2c_dev->dma_buf_size = i2c_dev->adapter.quirks->max_write_len + - I2C_PACKET_HEADER_SIZE; - init_completion(&i2c_dev->msg_complete); - init_completion(&i2c_dev->dma_complete); - - platform_set_drvdata(pdev, i2c_dev); - - if (i2c_dev->hw->supports_bus_clear) - i2c_dev->adapter.bus_recovery_info = &tegra_i2c_recovery_info; + err = tegra_i2c_init_clocks(i2c_dev); + if (err) + return err; - ret = tegra_i2c_init_dma(i2c_dev); - if (ret < 0) + err = tegra_i2c_init_dma(i2c_dev); + if (err) goto release_clocks; - ret = tegra_i2c_init_runtime_pm_and_hardware(i2c_dev); - if (ret) + err = tegra_i2c_init_runtime_pm_and_hardware(i2c_dev); + if (err) goto release_dma; - irq_set_status_flags(i2c_dev->irq, IRQ_NOAUTOEN); - - ret = devm_request_irq(&pdev->dev, i2c_dev->irq, tegra_i2c_isr, - IRQF_NO_SUSPEND, dev_name(&pdev->dev), i2c_dev); - if (ret) - goto release_rpm; - - i2c_set_adapdata(&i2c_dev->adapter, i2c_dev); + i2c_dev->adapter.dev.of_node = i2c_dev->dev->of_node; + i2c_dev->adapter.dev.parent = i2c_dev->dev; + i2c_dev->adapter.retries = 1; + i2c_dev->adapter.timeout = 6 * HZ; + i2c_dev->adapter.quirks = i2c_dev->hw->quirks; i2c_dev->adapter.owner = THIS_MODULE; i2c_dev->adapter.class = I2C_CLASS_DEPRECATED; - strlcpy(i2c_dev->adapter.name, dev_name(&pdev->dev), + i2c_dev->adapter.algo = &tegra_i2c_algo; + i2c_dev->adapter.nr = i2c_dev->cont_id; + + if (i2c_dev->hw->supports_bus_clear) + i2c_dev->adapter.bus_recovery_info = &tegra_i2c_recovery_info; + + strlcpy(i2c_dev->adapter.name, dev_name(i2c_dev->dev), sizeof(i2c_dev->adapter.name)); - i2c_dev->adapter.dev.parent = &pdev->dev; - i2c_dev->adapter.nr = pdev->id; - i2c_dev->adapter.dev.of_node = pdev->dev.of_node; - ret = i2c_add_numbered_adapter(&i2c_dev->adapter); - if (ret) - goto release_dma; + i2c_set_adapdata(&i2c_dev->adapter, i2c_dev); + + err = i2c_add_numbered_adapter(&i2c_dev->adapter); + if (err) + goto release_rpm; return 0; @@ -1800,7 +1806,7 @@ static int tegra_i2c_probe(struct platform_device *pdev) release_clocks: tegra_i2c_release_clocks(i2c_dev); - return ret; + return err; } static int tegra_i2c_remove(struct platform_device *pdev) From patchwork Sat Sep 5 20:41:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254825 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 A43ECC43461 for ; Sat, 5 Sep 2020 20:42:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 720A0208C7 for ; Sat, 5 Sep 2020 20:42:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="j5qNZwmz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728742AbgIEUmp (ORCPT ); Sat, 5 Sep 2020 16:42:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728718AbgIEUml (ORCPT ); Sat, 5 Sep 2020 16:42:41 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8639AC061249; Sat, 5 Sep 2020 13:42:39 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id c2so11745797ljj.12; Sat, 05 Sep 2020 13:42:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HxuDydUSZoNI1+yqMsxkzReEarnq7zj4OINQ+mfVftk=; b=j5qNZwmzjvOCpiECSExMfb+O0OOPERaXVl7QgSzXSOq48f0jKrmM2R7YHOusPdm05d BDY/QyyEQjyMyGC/Ti0/MXOHWvBbKwwNR58oAj1oB7hJ8AFE1KctkeezVz30viCDZsBU M9KUhkHsyv/U5XrLYlQzY4AE9hvYGPATVPZlCVRnA2EE3JbajPYcBp7n64uLxCj/Ej+L rUizkebfgdWLS6u0lTrMn3FPmpnS21daRTxWXvWaCpsNXftCRws4UlrQCWnhkAMV+HTS lK6U61nWxrmRUjS1CZeF9WqwCD3cEcMrha938nyE26C9H1duRtlXa+9plo6oetNjT8RY EDug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HxuDydUSZoNI1+yqMsxkzReEarnq7zj4OINQ+mfVftk=; b=XMrW2gijpadGOXm2usVqEXpUNZwdXX+OxzKn0SIe8fFMzjbh4hwapj6okUszJpyhJk xzQ/TTlX2/Z3oaEcTPj+a4M/nlG193wgu0JLo6cSkxOaP9x3RDwSTtNBGqiuTKfa48PX eeHqH8nvNHb8OLV0PqluOlsqjfA0pi7760YqXmbNRIw3cRXSuuA+wIJ2RxgcFPJb/QLY rir7f4WgPgAY/9ia3KpLiPI6FoHhukB1BynY8/SUm5WcAeCx1jwpS20PHIu1eW8/OKe1 t4AFYbf7TqVLSMTEZ1iL3D/I5B4Sf4wQAOlBrf4x0nbQZ1ubKotZS3gQvBXoFQwQ+B4n HvzQ== X-Gm-Message-State: AOAM532NJtUCE+hRZpC+Q/ZK4ODT3rqxeJe/xQBzS4fK0DHJ4Q7dNWrB 2mpmfqsrXIrq4ad1/Z53Z+I= X-Google-Smtp-Source: ABdhPJzmcCMPtkC0n/mcrr/vCOS0MR2k7/LTSEX6mRWWdd9iUzDkGrJIQhh7BvPi47NOPhQTYJVZqQ== X-Received: by 2002:a05:651c:c6:: with SMTP id 6mr6925349ljr.237.1599338557668; Sat, 05 Sep 2020 13:42:37 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id e17sm1677763ljn.18.2020.09.05.13.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 13:42:37 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Andy Shevchenko Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 14/31] i2c: tegra: Remove likely/unlikely from the code Date: Sat, 5 Sep 2020 23:41:34 +0300 Message-Id: <20200905204151.25343-15-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200905204151.25343-1-digetx@gmail.com> References: <20200905204151.25343-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The likely/unlikely annotations should be used only in a hot paths of performance-critical code. The I2C driver doesn't have such paths, and thus, there is no justification for usage of likely/unlikely annotations in the code. Hence remove them. Reviewed-by: Michał Mirosław Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index d8b7373673ea..33d37a40fa83 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -890,7 +890,7 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id) goto err; } - if (unlikely(status & status_err)) { + if (status & status_err) { tegra_i2c_disable_packet_mode(i2c_dev); if (status & I2C_INT_NO_ACK) i2c_dev->msg_err |= I2C_ERR_NO_ACK; @@ -1330,7 +1330,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, i2c_dev->msg_err); i2c_dev->is_curr_dma_xfer = false; - if (likely(i2c_dev->msg_err == I2C_ERR_NONE)) + if (i2c_dev->msg_err == I2C_ERR_NONE) return 0; tegra_i2c_init(i2c_dev); From patchwork Sat Sep 5 20:41:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254816 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 04BC8C433E2 for ; Sat, 5 Sep 2020 20:46:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C608020760 for ; Sat, 5 Sep 2020 20:46:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a+iZWQEu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728824AbgIEUpo (ORCPT ); Sat, 5 Sep 2020 16:45:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728726AbgIEUmm (ORCPT ); Sat, 5 Sep 2020 16:42:42 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30F58C06125E; Sat, 5 Sep 2020 13:42:40 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id k25so11759407ljg.9; Sat, 05 Sep 2020 13:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6RRXFQ1kc/Y4nyCU/wNkP0keA+UqxgPIjRTZx+8dm4A=; b=a+iZWQEuFYJXTbNB5GtxF3034zigYvAk8cvLJCSMCu6JOV9tI9/rSoTO5n6COVYOUv UlVYahELxxiWU0sOvjbdzElJ7+7Khx6TXP2FOPlriEJhP7Py1jWDp6FbB2XXplu9hzci 4wGjglpXnL+NJ8ywMqyXOn5SLfNmXSw08FvhVGA+geydjgrnzVDiJe+YGq5y71p2AtI2 ERH4emHKOt9sK+wtDE9E9eHokJli+YE08Fg56QYEp4qGXx2hZvMUN6DC7JyBNjUF6foP io6sIlFOcGOJDcZbVdvVCOOEOPcECs7zplkr5jrrubcE2N0BwhNN4Qp3kBYrGdA/EzIa ocvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6RRXFQ1kc/Y4nyCU/wNkP0keA+UqxgPIjRTZx+8dm4A=; b=uTRmQfTbZZrbb1eU2qVPhxBvrvMSWTJDWul+kkyrqv/4zkfQesMZDwg9TBHSeCz+Wj 39D5QRx5XJ/Sc6h/7+Xfqip8ijmGaD6JO3UWxamZHvu6B+iBv74QLGN8Qax7xcrU8EoB Vc8puAQIL6S+VlKxLjKEBRPQ8oFg5ZT6jz7WFFqaJjHc8JSZG04fp1t1mawr2CYRA2zM uKoIovaacv5M05k+z1XRdZh0g8In25n5A0JH5A9zUMv4BfQwykW1RakhFFPWbb+gPf2h i7PuzhuYrBMRj4BoLUWQQMw1FyH5tVo+epPuMKm0FVu+M25iLMqU6Yg5KElGrx2Snywu aGOQ== X-Gm-Message-State: AOAM531EUk/7bMUPMpyHKJjpyfBZ4JPWTOvZGHKanzfAHEyPPxfi188t iW+eo5VngO6xxx3NC8cb0l4= X-Google-Smtp-Source: ABdhPJzmkohcwp5n3Kob3QdltSsLijAXqaBw2ePopAD4H4AQWjOvGgqy74RUdcYLtgAXsoynphQhug== X-Received: by 2002:a2e:8606:: with SMTP id a6mr3712386lji.299.1599338558570; Sat, 05 Sep 2020 13:42:38 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id e17sm1677763ljn.18.2020.09.05.13.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 13:42:38 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Andy Shevchenko Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 15/31] i2c: tegra: Remove bogus barrier() Date: Sat, 5 Sep 2020 23:41:35 +0300 Message-Id: <20200905204151.25343-16-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200905204151.25343-1-digetx@gmail.com> References: <20200905204151.25343-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Apparently barrier() was intended to reduce possibility of racing with the interrupt handler, but driver's code evolved significantly and today's driver enables interrupt only when it waits for completion notification. Hence barrier() has no good use anymore, let's remove it. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 33d37a40fa83..f69587ca163b 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -600,7 +600,6 @@ static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev *i2c_dev) i2c_dev->msg_buf_remaining = buf_remaining; i2c_dev->msg_buf = buf + words_to_transfer * BYTES_PER_FIFO_WORD; - barrier(); i2c_writesl(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer); @@ -624,7 +623,6 @@ static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev *i2c_dev) /* Again update before writing to FIFO to make sure isr sees. */ i2c_dev->msg_buf_remaining = 0; i2c_dev->msg_buf = NULL; - barrier(); i2c_writel(i2c_dev, val, I2C_TX_FIFO); } From patchwork Sat Sep 5 20:41:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254818 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 D9C8EC433E2 for ; Sat, 5 Sep 2020 20:45:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A321A20796 for ; Sat, 5 Sep 2020 20:45:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z7fm9c0x" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728678AbgIEUow (ORCPT ); Sat, 5 Sep 2020 16:44:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728737AbgIEUmp (ORCPT ); Sat, 5 Sep 2020 16:42:45 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C371C061245; Sat, 5 Sep 2020 13:42:44 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id u21so1537003ljl.6; Sat, 05 Sep 2020 13:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pEHmIb4d6XMROUI2DH0Ea67xbvLArLBVTrqBQH+Lcrs=; b=Z7fm9c0xw+dAAOdGX25/VDX68Y5naWg2ZdRE4MK0F1xd88nO+PYI8evUJkRtfmASgd X1YyGu7QVA6Ie96QizsnDdKv/ZGyfJ5N6Ax1CT+6mbpwBSGcV27835Tsv9xQPTvzmh03 /EIRRhW9qtZ6aAp6LEjFlhvgpafru55SDsPu3/dRgJgK38QsKlWHVxmHe4xCeBF5C18b cDSs81NgoMZN/DWFWV7ah4SnBEjFJoBOD3RjG7xEbUPH3xT8AZH3JHTQKQ3mfKDexuee XEqPEyfBBwwzxSxhxF2/FZLvax+XSzU988jOJTvV++0gCJHMeD+F/O6tlrdWsXpALaiX 5jpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pEHmIb4d6XMROUI2DH0Ea67xbvLArLBVTrqBQH+Lcrs=; b=Hgdsb0k+foAkjbUqVF+jpiF23ncORqV7hURUo+kCCh8EmfhjxdCDj7ZLRclb3DPIKj BDNNhBMx8eLwE2995CWXPM8iiPn7re2lupke2Q7Vzv9l0XO94qm1uPGewtiulTuungQq HW9wZdpaTiorOSqqqjS/EwHSoiZ2ICXjoNJvQnsenWm2pPPqid/iY4mysQUSGpHy6IBH WrW3dFnD5YZmGog+sgsXhGaoKWlPuPokMFCENWwogX+Rm2CbcW1f6dPMfwTP8FT253Wc qWik9rhohpHvlRDjFl+nH306pQha4ygaJzSHcBkLNRMYcKqgnbR9FbCvkknLV+H3jCes QaEA== X-Gm-Message-State: AOAM530GUt9Svr5QyxnELror7GlfPx3jlu/sc5SlvM14wq/FbgbhZHAc npBYmfNONwZYe+gqOgikv2k= X-Google-Smtp-Source: ABdhPJznSbdTMBxUgOgE20zXY6jOTU/G5DkiPy3yiChechbFydNBc+phR/JeTP9ZSOlexVOu6Fzmuw== X-Received: by 2002:a2e:5c89:: with SMTP id q131mr4725689ljb.352.1599338562990; Sat, 05 Sep 2020 13:42:42 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id e17sm1677763ljn.18.2020.09.05.13.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 13:42:42 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Andy Shevchenko Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 20/31] i2c: tegra: Rename variable in tegra_i2c_issue_bus_clear() Date: Sat, 5 Sep 2020 23:41:40 +0300 Message-Id: <20200905204151.25343-21-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200905204151.25343-1-digetx@gmail.com> References: <20200905204151.25343-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Rename variable "reg" to "val" in order to better reflect the actual usage of the variable in the code and to make naming consistent with the rest of the code. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index c2ff55e8db54..6ec6161a1895 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -1100,21 +1100,21 @@ static int tegra_i2c_issue_bus_clear(struct i2c_adapter *adap) { struct tegra_i2c_dev *i2c_dev = i2c_get_adapdata(adap); unsigned long time_left; - u32 reg; + u32 val; int err; reinit_completion(&i2c_dev->msg_complete); - reg = FIELD_PREP(I2C_BC_SCLK_THRESHOLD, 9) | I2C_BC_STOP_COND | + val = FIELD_PREP(I2C_BC_SCLK_THRESHOLD, 9) | I2C_BC_STOP_COND | I2C_BC_TERMINATE; - i2c_writel(i2c_dev, reg, I2C_BUS_CLEAR_CNFG); + i2c_writel(i2c_dev, val, I2C_BUS_CLEAR_CNFG); if (i2c_dev->hw->has_config_load_reg) { err = tegra_i2c_wait_for_config_load(i2c_dev); if (err) return err; } - reg |= I2C_BC_ENABLE; - i2c_writel(i2c_dev, reg, I2C_BUS_CLEAR_CNFG); + val |= I2C_BC_ENABLE; + i2c_writel(i2c_dev, val, I2C_BUS_CLEAR_CNFG); tegra_i2c_unmask_irq(i2c_dev, I2C_INT_BUS_CLR_DONE); time_left = tegra_i2c_wait_completion(i2c_dev, &i2c_dev->msg_complete, @@ -1124,8 +1124,8 @@ static int tegra_i2c_issue_bus_clear(struct i2c_adapter *adap) return -ETIMEDOUT; } - reg = i2c_readl(i2c_dev, I2C_BUS_CLEAR_STATUS); - if (!(reg & I2C_BC_STATUS)) { + val = i2c_readl(i2c_dev, I2C_BUS_CLEAR_STATUS); + if (!(val & I2C_BC_STATUS)) { dev_err(i2c_dev->dev, "un-recovered arbitration lost\n"); return -EIO; From patchwork Sat Sep 5 20:41:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254824 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 EFA12C43461 for ; Sat, 5 Sep 2020 20:43:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF84220760 for ; Sat, 5 Sep 2020 20:43:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z+0v/6nR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728787AbgIEUm6 (ORCPT ); Sat, 5 Sep 2020 16:42:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728758AbgIEUms (ORCPT ); Sat, 5 Sep 2020 16:42:48 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73A8AC061247; Sat, 5 Sep 2020 13:42:46 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id z17so5581342lfi.12; Sat, 05 Sep 2020 13:42:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3KS8oso7xw2Kqf6psNafzD7AGG/eXNfR4CiTjMdd6I0=; b=Z+0v/6nRRBQRAjtVHPUFURbCMwCl8DzFQME0ZvlHZq4IX38HqUGO/bvJt6es4fUNSc lITAFL4dDyywRd2HyNtWfCqCQ2pbttqYkYAs42N4VEbSAniY5t1Vklyh9hP7Fh/Mk1rh jpdpVfH8AXOYryKFDHDr+PSy6CWqbeAM5njcW/VCrDUJPvZmJOQ53eJRHZtTeJSEn+wK tTzRoCKCe3gpAVEIkTrGA5ybHAY/f2sMgC+sjdRi0Qub+fZqFffw6SfjZ5Wq2VqyHigY r0yGJztbBCiTNpzidNqaKgTV60PEv7KQ8GsZ93NaaTDDZvMxtirHdDxbe+LpRMNplKRl 1jhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3KS8oso7xw2Kqf6psNafzD7AGG/eXNfR4CiTjMdd6I0=; b=Q4ICO1kkKKafz5XzA16N98J9Kh77sbdrqhWmSeBScomuEoTfZdwKa7y8E9Ri7jXsYq K+7k7NIV1DN0eixoxXBrfw0mDAXUD+v3OityiAV2l59dGa3JBs7m+0oJsKwqdficlpbT NeXyRTIu7po7vbMXujqbfjS44qtg3oOuOiYWkzWYGWuM27oB+LyFPvAhaaPWwKVE3lzr JFEyOjdB2wjUzmi45Jc0kytWK6/PI/7/MQiEvt8EIs113WkW2uR6DmM/UltFgMhESFiZ ylLl4XVY2ZuZL6Hlk4DjicLsbvob7zo+NUDlX28VOg9AEAy88N/kyneQa1G2Rc2Zku0L gEmQ== X-Gm-Message-State: AOAM532rI1TncsMiUTw8O+zsuehmR7Y15uVseo053mrMUvebdCpqBo/i N2EIoL4zmQ8J/6aADy9opD3b8k8AJII= X-Google-Smtp-Source: ABdhPJygqzydOHv3dMep7S0qiiifdQqn5LnINZ1zvbIVm3nS9wR6iuD8MLNVI2UikpIhZyT3fXkuIg== X-Received: by 2002:a19:6a08:: with SMTP id u8mr6784465lfu.51.1599338564710; Sat, 05 Sep 2020 13:42:44 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id e17sm1677763ljn.18.2020.09.05.13.42.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 13:42:44 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Andy Shevchenko Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 22/31] i2c: tegra: Factor out packet header setup from tegra_i2c_xfer_msg() Date: Sat, 5 Sep 2020 23:41:42 +0300 Message-Id: <20200905204151.25343-23-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200905204151.25343-1-digetx@gmail.com> References: <20200905204151.25343-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The code related to packet header setting up is a bit messy and makes tegra_i2c_xfer_msg() more difficult to read than it could be. Let's factor the packet header setup from tegra_i2c_xfer_msg() into separate function in order to make code easier to read and follow. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 93 ++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 39 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index aa7adf8df668..129ca5a6cb85 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -1134,6 +1134,57 @@ static int tegra_i2c_issue_bus_clear(struct i2c_adapter *adap) return -EAGAIN; } +static void tegra_i2c_push_packet_header(struct tegra_i2c_dev *i2c_dev, + struct i2c_msg *msg, + enum msg_end_type end_state) +{ + u32 *dma_buf = i2c_dev->dma_buf; + u32 packet_header; + + packet_header = FIELD_PREP(PACKET_HEADER0_HEADER_SIZE, 0) | + FIELD_PREP(PACKET_HEADER0_PROTOCOL, + PACKET_HEADER0_PROTOCOL_I2C) | + FIELD_PREP(PACKET_HEADER0_CONT_ID, i2c_dev->cont_id) | + FIELD_PREP(PACKET_HEADER0_PACKET_ID, 1); + + if (i2c_dev->is_curr_dma_xfer && !i2c_dev->msg_read) + *dma_buf++ = packet_header; + else + i2c_writel(i2c_dev, packet_header, I2C_TX_FIFO); + + packet_header = msg->len - 1; + + if (i2c_dev->is_curr_dma_xfer && !i2c_dev->msg_read) + *dma_buf++ = packet_header; + else + i2c_writel(i2c_dev, packet_header, I2C_TX_FIFO); + + packet_header = I2C_HEADER_IE_ENABLE; + + if (end_state == MSG_END_CONTINUE) + packet_header |= I2C_HEADER_CONTINUE_XFER; + else if (end_state == MSG_END_REPEAT_START) + packet_header |= I2C_HEADER_REPEAT_START; + + if (msg->flags & I2C_M_TEN) { + packet_header |= msg->addr; + packet_header |= I2C_HEADER_10BIT_ADDR; + } else { + packet_header |= msg->addr << I2C_HEADER_SLAVE_ADDR_SHIFT; + } + + if (msg->flags & I2C_M_IGNORE_NAK) + packet_header |= I2C_HEADER_CONT_ON_NAK; + + if (msg->flags & I2C_M_RD) + packet_header |= I2C_HEADER_READ; + + if (i2c_dev->is_curr_dma_xfer && !i2c_dev->msg_read) + *dma_buf++ = packet_header; + else + i2c_writel(i2c_dev, packet_header, I2C_TX_FIFO); +} + static int tegra_i2c_error_recover(struct tegra_i2c_dev *i2c_dev, struct i2c_msg *msg) { @@ -1165,9 +1216,8 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, enum msg_end_type end_state) { unsigned long time_left, xfer_time = 100; - u32 packet_header, int_mask; - u32 *buffer = NULL; size_t xfer_size; + u32 int_mask; int err; err = tegra_i2c_flush_fifos(i2c_dev); @@ -1219,49 +1269,14 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, i2c_dev->dma_phys, xfer_size, DMA_TO_DEVICE); - buffer = i2c_dev->dma_buf; } } - packet_header = FIELD_PREP(PACKET_HEADER0_HEADER_SIZE, 0) | - FIELD_PREP(PACKET_HEADER0_PROTOCOL, - PACKET_HEADER0_PROTOCOL_I2C) | - FIELD_PREP(PACKET_HEADER0_CONT_ID, i2c_dev->cont_id) | - FIELD_PREP(PACKET_HEADER0_PACKET_ID, 1); - if (i2c_dev->is_curr_dma_xfer && !i2c_dev->msg_read) - *buffer++ = packet_header; - else - i2c_writel(i2c_dev, packet_header, I2C_TX_FIFO); - - packet_header = msg->len - 1; - if (i2c_dev->is_curr_dma_xfer && !i2c_dev->msg_read) - *buffer++ = packet_header; - else - i2c_writel(i2c_dev, packet_header, I2C_TX_FIFO); - - packet_header = I2C_HEADER_IE_ENABLE; - if (end_state == MSG_END_CONTINUE) - packet_header |= I2C_HEADER_CONTINUE_XFER; - else if (end_state == MSG_END_REPEAT_START) - packet_header |= I2C_HEADER_REPEAT_START; - if (msg->flags & I2C_M_TEN) { - packet_header |= msg->addr; - packet_header |= I2C_HEADER_10BIT_ADDR; - } else { - packet_header |= msg->addr << I2C_HEADER_SLAVE_ADDR_SHIFT; - } - if (msg->flags & I2C_M_IGNORE_NAK) - packet_header |= I2C_HEADER_CONT_ON_NAK; - if (msg->flags & I2C_M_RD) - packet_header |= I2C_HEADER_READ; - if (i2c_dev->is_curr_dma_xfer && !i2c_dev->msg_read) - *buffer++ = packet_header; - else - i2c_writel(i2c_dev, packet_header, I2C_TX_FIFO); + tegra_i2c_push_packet_header(i2c_dev, msg, end_state); if (!i2c_dev->msg_read) { if (i2c_dev->is_curr_dma_xfer) { - memcpy(buffer, msg->buf, msg->len); + memcpy(i2c_dev->dma_buf, msg->buf, msg->len); dma_sync_single_for_device(i2c_dev->dev, i2c_dev->dma_phys, xfer_size, From patchwork Sat Sep 5 20:41:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254820 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, 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 A3F00C43461 for ; Sat, 5 Sep 2020 20:44:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 72C8E20796 for ; Sat, 5 Sep 2020 20:44:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KIZ0ost6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728935AbgIEUoE (ORCPT ); Sat, 5 Sep 2020 16:44:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728771AbgIEUmu (ORCPT ); Sat, 5 Sep 2020 16:42:50 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 290B5C061258; Sat, 5 Sep 2020 13:42:49 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id y4so11783612ljk.8; Sat, 05 Sep 2020 13:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SVIZolRkigMG5KeyY60o0qplGOEf+YGse9lnTNFQTF8=; b=KIZ0ost64cHgPw+51EqE+n9nLPp6Damip2giJDJtSVL+rn4I4JJV2FNk1TpE93KYbW 9J70UEgw7GR3wXyg2fxqLmQkSHHElh3nrKwZRuS0uoIW787EUP2QvzBUBySLjpAepC1x l0GsgIM0P0sGYgKuAZHSs9vaGZ3z78AEJnnK714qVmUoqMritALAbmLk51gZTm1v0zoI RflZgt8BESf9H8pCfBHd7c6rt4ol1rvmX6JTFzXfsbDKYZdyPllVPQl8N+hS/tyEcGdC xjMa8L5wr/p+ftFOJEKI8dpxCYN+CfDTrPued0uF+DHA/IxdAwtLvEg9APKuGmcv17wp iXYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SVIZolRkigMG5KeyY60o0qplGOEf+YGse9lnTNFQTF8=; b=mg7D6FNaQfY0ki+1pwFPROGpiryFCTfHK87+ORl/Lp3Sdkg6+c5IyevnLJrd5tr/gO /Mn1C5K8+aj2fCwc+ZTnGsYkBncn9vbT6GkKBrbfurhOtJD/LXE2jusGFI4xVEYUAeZD ScC3AqyrOi7qNc06RiClwiVs9Md8Ki4F/F65OorqpGp14vxJLMtT3L3aOnugSZ6rUija V4VUt0P8vuSbLwuzlrJPrQ4/p/bl3AiQgCy9F5hOl3Hx++bnbBGOKv3jjM7qgiJ53Z1v hQTLcT0TYacmxap7+QPsYy84PVvHOzQ9x85bjPf3Rb51gTTkMVVQCN3E99c79oZoahtQ Ktuw== X-Gm-Message-State: AOAM530ozE+XBethp8LmVYrU04zLKbzgAhLtKXGW+fvMmwvKa5UKKBkT BAsD9r994b10ydLAiXIY+iE= X-Google-Smtp-Source: ABdhPJz4mB6yn7gy1KC9/kUrOaH5rUaQwGCC4JaWDd85sZ/UZUJpXci8/OOJ1HWK1AaehpH2XCeaZw== X-Received: by 2002:a2e:9c9:: with SMTP id 192mr6350314ljj.197.1599338567640; Sat, 05 Sep 2020 13:42:47 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id e17sm1677763ljn.18.2020.09.05.13.42.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 13:42:46 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Andy Shevchenko Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 25/31] i2c: tegra: Check errors for both positive and negative values Date: Sat, 5 Sep 2020 23:41:45 +0300 Message-Id: <20200905204151.25343-26-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200905204151.25343-1-digetx@gmail.com> References: <20200905204151.25343-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The driver's code is inconsistent in regards to the error values checking. The correct way should be to check both positive and negative values. This patch cleans up the error-checks in the code. Note that the pm_runtime_get_sync() could return positive value on success, hence only relevant parts of the code are changed by this patch. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 9b4107b07135..64776cd8e0ff 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -969,7 +969,7 @@ static void tegra_i2c_config_fifo_trig(struct tegra_i2c_dev *i2c_dev, slv_config.device_fc = true; ret = dmaengine_slave_config(chan, &slv_config); - if (ret < 0) { + if (ret) { dev_err(i2c_dev->dev, "DMA slave config failed: %d\n", ret); dev_err(i2c_dev->dev, "falling back to PIO\n"); @@ -1208,7 +1208,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, xfer_size, DMA_FROM_DEVICE); err = tegra_i2c_dma_submit(i2c_dev, xfer_size); - if (err < 0) { + if (err) { dev_err(i2c_dev->dev, "starting RX DMA failed, err %d\n", err); @@ -1233,7 +1233,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, xfer_size, DMA_TO_DEVICE); err = tegra_i2c_dma_submit(i2c_dev, xfer_size); - if (err < 0) { + if (err) { dev_err(i2c_dev->dev, "starting TX DMA failed, err %d\n", err); From patchwork Sat Sep 5 20:41:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254822 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 E47D4C43461 for ; Sat, 5 Sep 2020 20:44:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC64720796 for ; Sat, 5 Sep 2020 20:44:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JMns3m5i" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728846AbgIEUnW (ORCPT ); Sat, 5 Sep 2020 16:43:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728776AbgIEUmx (ORCPT ); Sat, 5 Sep 2020 16:42:53 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEB03C06125E; Sat, 5 Sep 2020 13:42:50 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id a15so11865828ljk.2; Sat, 05 Sep 2020 13:42:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=71X7gV0UsJDQK+ZE1hDXzomab/CdlvY7d7EaOYOUeXU=; b=JMns3m5ipp94OA8ijBfOwT2MwKrTMyR6stCQhc4rBBFyDRZdb2mcJA+JV7cmZyB1Q4 ReLk+/ISlakqCOGIf3syJst5IlCbpn1M2SGFA5PMPMx3JSo/+6DD0oCq461+/1DvCqwX epkApJYeCVf0ebonHtzmeWUmL+y+YSw/9TO8hndnP+yCKg2KPEhRsQtzHoXmNoow5Zqf miTyKl1SarNWNB04ILjsEe1sAVuSJ/nRCttpLmK9a00o4lgHr/HKyxpLMhctg+znGwBJ 2fPZa3Onw0NC3F8Xn/bgKt3mhwKWuE63kuDkcJx71lpt+/7zHCSAVshq1LEb+vH/BEsU rqFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=71X7gV0UsJDQK+ZE1hDXzomab/CdlvY7d7EaOYOUeXU=; b=HgH/Uk8XUunyelAMLsk/LMDLS68xKqHpGAj3BjemFa9U3H2nWp5XmhJh/rRkSmpTOM 8vCfIEV5+fdNiTqP9K5nFQlGkIgYcmyh19SlTlJxZHkggk4qb7Zj0AtOIzVIEwE6AF8I E3fv9Wr6IaocddCeg9cd9tlcJ9j5TbnYQkLP4E1WY/SJK4OjEHwfrbULOHjdi9a6my66 NAgBEWrUT3JYIt2ZA0weaPmuqQeGKGV4oW0NnCjqGgJNUW0BcbtAI+2GV4nIjlHtN6Gd USYMfMCqghW0ol7jUqiGbrDaPv97g9CDadPmNTzQrQQlANqtizm6QJoRMlPZNYb7Nnyg sOEg== X-Gm-Message-State: AOAM530W3G4VqOFLk+3NOSKVjIrX97KQLWgRKOLvqhfg5S/ihiFqIEZS t73M8ZRd7JIZ8GuyWGHoxB0= X-Google-Smtp-Source: ABdhPJxwahSNBTmkvi2W0YXOSkJ4n0xundj62JfHNw8fDZUA7MmmKt/sgaqWhjSSSMFjimCsEzb7Bw== X-Received: by 2002:a2e:958:: with SMTP id 85mr6274441ljj.151.1599338569413; Sat, 05 Sep 2020 13:42:49 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id e17sm1677763ljn.18.2020.09.05.13.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 13:42:48 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Andy Shevchenko Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 27/31] i2c: tegra: Clean up printk messages Date: Sat, 5 Sep 2020 23:41:47 +0300 Message-Id: <20200905204151.25343-28-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200905204151.25343-1-digetx@gmail.com> References: <20200905204151.25343-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org This patch unifies style of all messages in the driver by starting them with a lowercase letter and using consistent capitalization and wording for all messages. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 3dd688e9462a..2dd97540f14f 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -377,7 +377,8 @@ static int tegra_i2c_dma_submit(struct tegra_i2c_dev *i2c_dev, size_t len) len, dir, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); if (!dma_desc) { - dev_err(i2c_dev->dev, "failed to get DMA descriptor\n"); + dev_err(i2c_dev->dev, "failed to get %s DMA descriptor\n", + i2c_dev->msg_read ? "RX" : "TX"); return -EINVAL; } @@ -418,7 +419,7 @@ static int tegra_i2c_init_dma(struct tegra_i2c_dev *i2c_dev) return 0; if (!IS_ENABLED(CONFIG_TEGRA20_APB_DMA)) { - dev_dbg(i2c_dev->dev, "Support for APB DMA not enabled!\n"); + dev_dbg(i2c_dev->dev, "DMA support not enabled\n"); return 0; } @@ -444,7 +445,7 @@ static int tegra_i2c_init_dma(struct tegra_i2c_dev *i2c_dev) dma_buf = dma_alloc_coherent(i2c_dev->dev, i2c_dev->dma_buf_size, &dma_phys, GFP_KERNEL | __GFP_NOWARN); if (!dma_buf) { - dev_err(i2c_dev->dev, "failed to allocate the DMA buffer\n"); + dev_err(i2c_dev->dev, "failed to allocate DMA buffer\n"); err = -ENOMEM; goto err_out; } @@ -541,7 +542,7 @@ static int tegra_i2c_wait_for_config_load(struct tegra_i2c_dev *i2c_dev) err = tegra_i2c_poll_register(i2c_dev, I2C_CONFIG_LOAD, 0xffffffff, 1000, I2C_CONFIG_LOAD_TIMEOUT); if (err) { - dev_warn(i2c_dev->dev, "timeout waiting for config load\n"); + dev_err(i2c_dev->dev, "failed to load config\n"); return err; } @@ -825,7 +826,7 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id) status = i2c_readl(i2c_dev, I2C_INT_STATUS); if (status == 0) { - dev_warn(i2c_dev->dev, "irq status 0 %08x %08x %08x\n", + dev_warn(i2c_dev->dev, "IRQ status 0 %08x %08x %08x\n", i2c_readl(i2c_dev, I2C_PACKET_TRANSFER_STATUS), i2c_readl(i2c_dev, I2C_STATUS), i2c_readl(i2c_dev, I2C_CNFG)); @@ -970,8 +971,7 @@ static void tegra_i2c_config_fifo_trig(struct tegra_i2c_dev *i2c_dev, slv_config.device_fc = true; ret = dmaengine_slave_config(chan, &slv_config); if (ret) { - dev_err(i2c_dev->dev, "DMA slave config failed: %d\n", - ret); + dev_err(i2c_dev->dev, "DMA config failed: %d\n", ret); dev_err(i2c_dev->dev, "falling back to PIO\n"); tegra_i2c_release_dma(i2c_dev); i2c_dev->is_curr_dma_xfer = false; @@ -1077,8 +1077,7 @@ static int tegra_i2c_issue_bus_clear(struct i2c_adapter *adap) val = i2c_readl(i2c_dev, I2C_BUS_CLEAR_STATUS); if (!(val & I2C_BC_STATUS)) { - dev_err(i2c_dev->dev, - "un-recovered arbitration lost\n"); + dev_err(i2c_dev->dev, "un-recovered arbitration lost\n"); return -EIO; } @@ -1208,12 +1207,8 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, xfer_size, DMA_FROM_DEVICE); err = tegra_i2c_dma_submit(i2c_dev, xfer_size); - if (err) { - dev_err(i2c_dev->dev, - "starting RX DMA failed, err %d\n", - err); + if (err) return err; - } } else { dma_sync_single_for_cpu(i2c_dev->dev, @@ -1233,12 +1228,8 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, xfer_size, DMA_TO_DEVICE); err = tegra_i2c_dma_submit(i2c_dev, xfer_size); - if (err) { - dev_err(i2c_dev->dev, - "starting TX DMA failed, err %d\n", - err); + if (err) return err; - } } else { tegra_i2c_fill_tx_fifo(i2c_dev); } @@ -1254,7 +1245,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, } tegra_i2c_unmask_irq(i2c_dev, int_mask); - dev_dbg(i2c_dev->dev, "unmasked irq: %02x\n", + dev_dbg(i2c_dev->dev, "unmasked IRQ: %02x\n", i2c_readl(i2c_dev, I2C_INT_MASK)); if (i2c_dev->is_curr_dma_xfer) { @@ -1297,7 +1288,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, tegra_i2c_mask_irq(i2c_dev, int_mask); if (time_left == 0) { - dev_err(i2c_dev->dev, "i2c transfer timed out\n"); + dev_err(i2c_dev->dev, "I2C transfer timed out\n"); err = -ETIMEDOUT; goto reset_hardware; } From patchwork Sat Sep 5 20:41:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254823 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, 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 01C60C433E2 for ; Sat, 5 Sep 2020 20:43:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF5D620797 for ; Sat, 5 Sep 2020 20:43:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aFNWEw2X" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728850AbgIEUnW (ORCPT ); Sat, 5 Sep 2020 16:43:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728774AbgIEUmw (ORCPT ); Sat, 5 Sep 2020 16:42:52 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E19C6C06125F; Sat, 5 Sep 2020 13:42:51 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id a15so11865845ljk.2; Sat, 05 Sep 2020 13:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=W9tEHaCutKChDWGj40n/tLK6DvHWgOOiB1AYU6tLOMc=; b=aFNWEw2XIr2auPUrtEqyMWpjxBJF3MNP8qNQ9KR9vMSkE7BRSf90FHPZaXHLGpBOkC bkmvZ6rvWKUp/0yre8J3G2+38CADohXXFiv/jMp3yIQm1HTyKzNOHw6u4pgyGmdMA/J+ 3wvIuk+MOifCCkenLnCIwVVouHfOu9nI1Y1IqzkpTexoRVUZ5xhUU+FHIU30uExqLDMW Tl51fJfnmcC7Vf3YP236z9Q/TFrfLX2EvHBZ6PbnQqJfbcC1RJ0w25nhnI+Fxdd7G0+n Q1nrFMJs146OSrMJQZzy5XEhomub++wkNRrIEBq5IzUwM1ige1ImMq+m3UW1KGlm7/Vy e82g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=W9tEHaCutKChDWGj40n/tLK6DvHWgOOiB1AYU6tLOMc=; b=leErH37RLV7t9R6MGjEbBqzahr6EXHJ4pPe1AqJ8UF0d82QpDbIQoNYo27uUe6fZZ+ yx557+8MhA+a9PFPWLT7RoOlWN1bOnpRS4UB0K0SxOXRspdNvzngfgk7cT2PVUazUShq v68dzSM0QozBNfilUKsNGCZbQrNrz8bV/5mclWdTi5P9Hh/KUoQL1j1hvt8h3PVK1DUl EYNl30qo5MHpirjzzuxhdXX4pdT/WJramg+Gc7iSAFava7SnMj2rip3DHS5GXxbORzxe JaIS1A8GLb5jVhwGZdRFv/yZ+De3XMG9pRhP8h1mzf3tdS4mjJOLuVgcUGnht887d2ju 6LUg== X-Gm-Message-State: AOAM5309H8bPfCJieDPmR+0lsha5mnPXBtwpDUI2xjd7LXLT21anZ9kZ yV4YBI4lKiBSk44nqSfV/bkcBjQ/maU= X-Google-Smtp-Source: ABdhPJxdO5tW362OKBzRh1Cr6tjoq87VBxJRmUdfobpmQpM7I/JCwiGVohqUE84LYWlz5q+Ion+qdw== X-Received: by 2002:a2e:86d3:: with SMTP id n19mr7215888ljj.368.1599338570361; Sat, 05 Sep 2020 13:42:50 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id e17sm1677763ljn.18.2020.09.05.13.42.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 13:42:49 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Andy Shevchenko Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 28/31] i2c: tegra: Clean up whitespaces, newlines and indentation Date: Sat, 5 Sep 2020 23:41:48 +0300 Message-Id: <20200905204151.25343-29-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200905204151.25343-1-digetx@gmail.com> References: <20200905204151.25343-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Some places in the code are missing newlines or have unnecessary whitespaces and newlines. This creates inconsistency of the code and hurts readability. This patch removes the unnecessary and adds necessary whitespaces / newlines, clears indentation of the code. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 52 ++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 2dd97540f14f..c36f2bed0240 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -310,6 +310,7 @@ static unsigned long tegra_i2c_reg_addr(struct tegra_i2c_dev *i2c_dev, reg += (reg >= I2C_TX_FIFO) ? 0x10 : 0x40; else if (i2c_dev->is_vi) reg = 0xc00 + (reg << 2); + return reg; } @@ -370,9 +371,12 @@ static int tegra_i2c_dma_submit(struct tegra_i2c_dev *i2c_dev, size_t len) struct dma_chan *chan; dev_dbg(i2c_dev->dev, "starting DMA for length: %zu\n", len); + reinit_completion(&i2c_dev->dma_complete); + dir = i2c_dev->msg_read ? DMA_DEV_TO_MEM : DMA_MEM_TO_DEV; chan = i2c_dev->msg_read ? i2c_dev->rx_dma_chan : i2c_dev->tx_dma_chan; + dma_desc = dmaengine_prep_slave_single(chan, i2c_dev->dma_phys, len, dir, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); @@ -386,6 +390,7 @@ static int tegra_i2c_dma_submit(struct tegra_i2c_dev *i2c_dev, size_t len) dma_desc->callback_param = i2c_dev; dmaengine_submit(dma_desc); dma_async_issue_pending(chan); + return 0; } @@ -573,6 +578,7 @@ static int tegra_i2c_flush_fifos(struct tegra_i2c_dev *i2c_dev) dev_err(i2c_dev->dev, "failed to flush FIFO\n"); return err; } + return 0; } @@ -784,9 +790,9 @@ static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev *i2c_dev) */ buf_remaining -= words_to_transfer * BYTES_PER_FIFO_WORD; tx_fifo_avail -= words_to_transfer; + i2c_dev->msg_buf_remaining = buf_remaining; - i2c_dev->msg_buf = buf + - words_to_transfer * BYTES_PER_FIFO_WORD; + i2c_dev->msg_buf = buf + words_to_transfer * BYTES_PER_FIFO_WORD; i2c_writesl(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer); @@ -1186,9 +1192,11 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, xfer_size = msg->len + I2C_PACKET_HEADER_SIZE; xfer_size = ALIGN(xfer_size, BYTES_PER_FIFO_WORD); + i2c_dev->is_curr_dma_xfer = (xfer_size > I2C_PIO_MODE_PREFERRED_LEN) && i2c_dev->dma_buf && !i2c_dev->is_curr_atomic_xfer; + tegra_i2c_config_fifo_trig(i2c_dev, xfer_size); /* @@ -1196,25 +1204,24 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, * Total bits = 9 bits per byte (including ACK bit) + Start & stop bits */ xfer_time += DIV_ROUND_CLOSEST(((xfer_size * 9) + 2) * MSEC_PER_SEC, - i2c_dev->bus_clk_rate); + i2c_dev->bus_clk_rate); int_mask = I2C_INT_NO_ACK | I2C_INT_ARBITRATION_LOST; tegra_i2c_unmask_irq(i2c_dev, int_mask); + if (i2c_dev->is_curr_dma_xfer) { if (i2c_dev->msg_read) { dma_sync_single_for_device(i2c_dev->dev, i2c_dev->dma_phys, - xfer_size, - DMA_FROM_DEVICE); + xfer_size, DMA_FROM_DEVICE); + err = tegra_i2c_dma_submit(i2c_dev, xfer_size); if (err) return err; - } else { dma_sync_single_for_cpu(i2c_dev->dev, i2c_dev->dma_phys, - xfer_size, - DMA_TO_DEVICE); + xfer_size, DMA_TO_DEVICE); } } @@ -1223,10 +1230,11 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, if (!i2c_dev->msg_read) { if (i2c_dev->is_curr_dma_xfer) { memcpy(i2c_dev->dma_buf, msg->buf, msg->len); + dma_sync_single_for_device(i2c_dev->dev, i2c_dev->dma_phys, - xfer_size, - DMA_TO_DEVICE); + xfer_size, DMA_TO_DEVICE); + err = tegra_i2c_dma_submit(i2c_dev, xfer_size); if (err) return err; @@ -1237,6 +1245,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, if (i2c_dev->hw->has_per_pkt_xfer_complete_irq) int_mask |= I2C_INT_PACKET_XFER_COMPLETE; + if (!i2c_dev->is_curr_dma_xfer) { if (msg->flags & I2C_M_RD) int_mask |= I2C_INT_RX_FIFO_DATA_REQ; @@ -1275,10 +1284,9 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, if (i2c_dev->msg_read && i2c_dev->msg_err == I2C_ERR_NONE) { dma_sync_single_for_cpu(i2c_dev->dev, i2c_dev->dma_phys, - xfer_size, - DMA_FROM_DEVICE); - memcpy(i2c_dev->msg_buf, i2c_dev->dma_buf, - msg->len); + xfer_size, DMA_FROM_DEVICE); + + memcpy(i2c_dev->msg_buf, i2c_dev->dma_buf, msg->len); } } @@ -1363,6 +1371,7 @@ static u32 tegra_i2c_func(struct i2c_adapter *adap) if (i2c_dev->hw->has_continue_xfer_support) ret |= I2C_FUNC_NOSTART; + return ret; } @@ -1774,11 +1783,11 @@ static int tegra_i2c_remove(struct platform_device *pdev) struct tegra_i2c_dev *i2c_dev = platform_get_drvdata(pdev); i2c_del_adapter(&i2c_dev->adapter); - - pm_runtime_disable(&pdev->dev); + pm_runtime_disable(i2c_dev->dev); tegra_i2c_release_dma(i2c_dev); tegra_i2c_release_clocks(i2c_dev); + return 0; } @@ -1877,15 +1886,14 @@ static const struct dev_pm_ops tegra_i2c_pm = { }; static struct platform_driver tegra_i2c_driver = { - .probe = tegra_i2c_probe, - .remove = tegra_i2c_remove, - .driver = { - .name = "tegra-i2c", + .probe = tegra_i2c_probe, + .remove = tegra_i2c_remove, + .driver = { + .name = "tegra-i2c", .of_match_table = tegra_i2c_of_match, - .pm = &tegra_i2c_pm, + .pm = &tegra_i2c_pm, }, }; - module_platform_driver(tegra_i2c_driver); MODULE_DESCRIPTION("nVidia Tegra2 I2C Bus Controller driver"); From patchwork Sat Sep 5 20:41:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254821 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 64891C2D0A8 for ; Sat, 5 Sep 2020 20:44:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3160920796 for ; Sat, 5 Sep 2020 20:44:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QpVEf4XR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728327AbgIEUnV (ORCPT ); Sat, 5 Sep 2020 16:43:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728780AbgIEUmz (ORCPT ); Sat, 5 Sep 2020 16:42:55 -0400 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAAFEC061251; Sat, 5 Sep 2020 13:42:54 -0700 (PDT) Received: by mail-lf1-x143.google.com with SMTP id d15so4721234lfq.11; Sat, 05 Sep 2020 13:42:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jM6mZMS3phZex18xRxgLb8dTfS3i1wzqX7A67SdzArY=; b=QpVEf4XR/wrDAnscle5Y3vF5VsY2yDje+XxXNxx0K6LAlcil+blfQ/6Drei+QuGemA GV+yRmP1tXbrq4I7EW/6tcmBcUlf+2+GGx2tjJdHyEVJNkb2cHpgIjcZQP1sb8HHUI/Q FYapWb8IpQgoQnki1N+RGtymjt0e4JEeFA7Xv+/44ugRJOvuY9L5IHMJtHaPdmdJOhqK qlX5J0Tbta5zb1HfkvSL5yOfXyXDITJOxiz5756DQsrgpGKbcnHFtXtE7rlAw4ptiK17 hPQ/J/DbItvAq+M1+zgxnL3baVvDiP9IQUsNSvDxDA8RCJsX5c8Y2pI7lQK90hzqZnQc DKrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jM6mZMS3phZex18xRxgLb8dTfS3i1wzqX7A67SdzArY=; b=nXlYJwClVk6ChlSieRwAuNns72Jz9C8t/itVY5VlCfNugPkqhdsgpQPqSlHDu3dxY4 1Sww5Tpu8L1Fa+q03HTbb1GBg1Nfr6s5oEQCGKHkRkJwVekL047nGiWZSQPXn3GeVykU rOTEPnwnSAeOi8h7qECGnrfAi2s6dp/+zZmhuExO52zhVin3FXaPA+RnVgmRmdbG/n/W bmRoH//p1u/7LHwUqlR0oSVBoH4guam2Sc1c/p1IYS1oef/8D1184lwdmly9qgl6Vr9Z xOVXoWNzRIic+AOibkVXAGHukFrXXn2xxZqEgBvILGsXk8O1l8yuBIg9YXTqY9Ix/kLn 5Ybw== X-Gm-Message-State: AOAM5330othOC18BUuZln0BefMNcdeCd19PL6eqrXC9NlMeRpbzs85/L hnkJd05JtPDAZ0ePloRR1UY= X-Google-Smtp-Source: ABdhPJy4/4rI717ynezqEUoBsa4mLZSJXWegT/gG4g5/D0EUJxjcdpbNKt4OHZS7i+ThPsZSX84htA== X-Received: by 2002:ac2:5597:: with SMTP id v23mr6743710lfg.5.1599338573105; Sat, 05 Sep 2020 13:42:53 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id e17sm1677763ljn.18.2020.09.05.13.42.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 13:42:52 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Andy Shevchenko Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 31/31] i2c: tegra: Rename couple "ret" variables to "err" Date: Sat, 5 Sep 2020 23:41:51 +0300 Message-Id: <20200905204151.25343-32-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200905204151.25343-1-digetx@gmail.com> References: <20200905204151.25343-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Rename "ret" variables to "err" in order to make code a bit more expressive, emphasizing that the returned value is a error code. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index d389ea5813c3..2c84d5848e29 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -935,7 +935,7 @@ static void tegra_i2c_config_fifo_trig(struct tegra_i2c_dev *i2c_dev, unsigned long reg_offset; u32 val, reg, dma_burst; struct dma_chan *chan; - int ret; + int err; if (i2c_dev->hw->has_mst_fifo) reg = I2C_MST_FIFO_CONTROL; @@ -975,9 +975,9 @@ static void tegra_i2c_config_fifo_trig(struct tegra_i2c_dev *i2c_dev, } slv_config.device_fc = true; - ret = dmaengine_slave_config(chan, &slv_config); - if (ret) { - dev_err(i2c_dev->dev, "DMA config failed: %d\n", ret); + err = dmaengine_slave_config(chan, &slv_config); + if (err) { + dev_err(i2c_dev->dev, "DMA config failed: %d\n", err); dev_err(i2c_dev->dev, "falling back to PIO\n"); tegra_i2c_release_dma(i2c_dev); i2c_dev->is_curr_dma_xfer = false; @@ -1584,11 +1584,11 @@ static void tegra_i2c_parse_dt(struct tegra_i2c_dev *i2c_dev) { struct device_node *np = i2c_dev->dev->of_node; bool multi_mode; - int ret; + int err; - ret = of_property_read_u32(np, "clock-frequency", + err = of_property_read_u32(np, "clock-frequency", &i2c_dev->bus_clk_rate); - if (ret) + if (err) i2c_dev->bus_clk_rate = I2C_MAX_STANDARD_MODE_FREQ; multi_mode = of_property_read_bool(np, "multi-master"); @@ -1796,15 +1796,15 @@ static int tegra_i2c_remove(struct platform_device *pdev) static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev) { struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev); - int ret; + int err; - ret = pinctrl_pm_select_default_state(i2c_dev->dev); - if (ret) - return ret; + err = pinctrl_pm_select_default_state(i2c_dev->dev); + if (err) + return err; - ret = clk_bulk_enable(i2c_dev->nclocks, i2c_dev->clocks); - if (ret) - return ret; + err = clk_bulk_enable(i2c_dev->nclocks, i2c_dev->clocks); + if (err) + return err; /* * VI I2C device is attached to VE power domain which goes through @@ -1812,8 +1812,8 @@ static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev) * controller needs to be re-initialized after power ON. */ if (i2c_dev->is_vi) { - ret = tegra_i2c_init(i2c_dev); - if (ret) + err = tegra_i2c_init(i2c_dev); + if (err) goto disable_clocks; } @@ -1822,7 +1822,7 @@ static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev) disable_clocks: clk_bulk_disable(i2c_dev->nclocks, i2c_dev->clocks); - return ret; + return err; } static int __maybe_unused tegra_i2c_runtime_suspend(struct device *dev)