From patchwork Mon Aug 31 20:22:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254867 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 26DB5C433E2 for ; Mon, 31 Aug 2020 20:24:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F022E21532 for ; Mon, 31 Aug 2020 20:24:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dP1lmEFy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727955AbgHaUY0 (ORCPT ); Mon, 31 Aug 2020 16:24:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729978AbgHaUXb (ORCPT ); Mon, 31 Aug 2020 16:23:31 -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 EA171C061755; Mon, 31 Aug 2020 13:23:30 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id w14so8242559ljj.4; Mon, 31 Aug 2020 13:23: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=LlFFuQSVpP4nuOnidxL8KPHKkAPDk1QX0MDXTli+RAU=; b=dP1lmEFyf6frzJ1B8XZwURB2SeEh72JMFlrp4WrwxklfKetjzVQguOcrFwb0h1Wtn6 OE6DtQMLQMy8dyGpXFcOWw9t6rIcMz6FOWXTspiLX++zGiiVnnIp4AzPuCQpMnftCFc8 9Repl1fNNy4fQMNZgKJYxWeAjjTE4Pixxk0hQDke8SMzEzniV5lqq0gEn3mPWCcO4iKQ vw5KC+SgWXCZAzFaoOZg0TAe5SjFqmiBZREiEcuTYaLmv9haR8XIq4UQjX3hE/LpxgeW YVUyKoRpA5NhubrAaLS/iE4B45mNIgzXT8BPliqFxKAJ4n1iz3u4FrnCkjXk/JCMgoE7 0w0Q== 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=LlFFuQSVpP4nuOnidxL8KPHKkAPDk1QX0MDXTli+RAU=; b=HoiE1himpQt4ADDKe95lRxLo/zyca/BsKn7r5GQCid9AYpW3av749zNN1aUZoUTa5S rdutUA2+yq6ETl3MDSuFwPQbDiRsW7kHaXL9YcveEsPmFqRUijboCxX4TSztj4qjHLSI LEHLYgCyN4BCktD4Sp/aPxVP07COytEHJ8tUWsAwufr2qxs/3eU3kaSRRepGwernTyn0 7gIjBHN/fiJwYzsodidrtIXqRBfxVr138cbPorIaP8H/eseEikELa21ENWt+rfPgNqgH gzqFpTEHNvJ3pB0H97sZlwz/FhIRxI3mR8EmM/48BWqGgWMYfbpAfh5+/aNo+X+BehyO Gkfw== X-Gm-Message-State: AOAM532dRv2/ffYWOmTjeOO/n816unsvweDiNlhBJQt0+u3VVI651dkX ueWVG5+f7aEcIgPGVE9wBLO5AotExFo= X-Google-Smtp-Source: ABdhPJwVuNjpPMZLuTwO3BMasZHAYnlVKPN4KyfqL+kt3zKw0lRQAeuEw6UDBzbhWJsOO7BbJzp25w== X-Received: by 2002:a2e:a58a:: with SMTP id m10mr1311257ljp.247.1598905408626; Mon, 31 Aug 2020 13:23: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 z20sm1769054ljk.97.2020.08.31.13.23.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2020 13:23:28 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 03/12] i2c: tegra: Clean up messages in the code Date: Mon, 31 Aug 2020 23:22:54 +0300 Message-Id: <20200831202303.15391-4-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200831202303.15391-1-digetx@gmail.com> References: <20200831202303.15391-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 lowercase and consistent wording for all messages in the code. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 50 ++++++++++++++++------------------ 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 9bd91b6f32f4..efbb20049cf8 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -427,7 +427,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; } @@ -450,7 +450,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; } @@ -672,8 +672,7 @@ static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev) ret = clk_enable(i2c_dev->fast_clk); if (ret < 0) { - dev_err(i2c_dev->dev, - "Enabling fast clk failed, err %d\n", ret); + dev_err(dev, "failed to enable fast clock: %d\n", ret); return ret; } @@ -685,8 +684,7 @@ static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev) ret = clk_enable(i2c_dev->div_clk); if (ret < 0) { - dev_err(i2c_dev->dev, - "Enabling div clk failed, err %d\n", ret); + dev_err(dev, "failed to enable div clock: %d\n", ret); goto disable_slow_clk; } @@ -850,7 +848,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev, bool clk_reinit) i2c_dev->bus_clk_rate * clk_multiplier); if (err) { dev_err(i2c_dev->dev, - "failed changing clock rate: %d\n", err); + "failed to set div-clk rate: %d\n", err); return err; } } @@ -1052,7 +1050,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) { - dev_err(i2c_dev->dev, "DMA slave config failed: %d\n", + dev_err(i2c_dev->dev, "dma slave config failed: %d\n", ret); dev_err(i2c_dev->dev, "falling back to PIO\n"); tegra_i2c_release_dma(i2c_dev); @@ -1163,8 +1161,7 @@ static int tegra_i2c_issue_bus_clear(struct i2c_adapter *adap) reg = i2c_readl(i2c_dev, I2C_BUS_CLEAR_STATUS); if (!(reg & 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; } @@ -1221,8 +1218,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, err = tegra_i2c_dma_submit(i2c_dev, xfer_size); if (err < 0) { dev_err(i2c_dev->dev, - "starting RX DMA failed, err %d\n", - err); + "starting rx dma failed: %d\n", err); return err; } @@ -1281,8 +1277,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, err = tegra_i2c_dma_submit(i2c_dev, xfer_size); if (err < 0) { dev_err(i2c_dev->dev, - "starting TX DMA failed, err %d\n", - err); + "starting tx dma failed: %d\n", err); return err; } } else { @@ -1321,7 +1316,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, i2c_dev->tx_dma_chan); if (!time_left && !completion_done(&i2c_dev->dma_complete)) { - dev_err(i2c_dev->dev, "DMA transfer timeout\n"); + dev_err(i2c_dev->dev, "dma transfer timeout\n"); tegra_i2c_init(i2c_dev, true); return -ETIMEDOUT; } @@ -1676,7 +1671,7 @@ static int tegra_i2c_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!res) { - dev_err(&pdev->dev, "no irq resource\n"); + dev_err(dev, "no irq resource\n"); return -EINVAL; } irq = res->start; @@ -1705,7 +1700,9 @@ static int tegra_i2c_probe(struct platform_device *pdev) i2c_dev->rst = devm_reset_control_get_exclusive(&pdev->dev, "i2c"); if (IS_ERR(i2c_dev->rst)) { - dev_err(&pdev->dev, "missing controller reset\n"); + dev_err(dev, "failed to get controller reset: %pe\n", + i2c_dev->rst); + return PTR_ERR(i2c_dev->rst); } @@ -1725,7 +1722,9 @@ static int tegra_i2c_probe(struct platform_device *pdev) if (!i2c_dev->hw->has_single_clk_source) { fast_clk = devm_clk_get(&pdev->dev, "fast-clk"); if (IS_ERR(fast_clk)) { - dev_err(&pdev->dev, "missing fast clock\n"); + dev_err(dev, "failed to get fast clock\n: %ld\n", + PTR_ERR(fast_clk)); + return PTR_ERR(fast_clk); } i2c_dev->fast_clk = fast_clk; @@ -1746,7 +1745,7 @@ static int tegra_i2c_probe(struct platform_device *pdev) ret = clk_prepare(i2c_dev->fast_clk); if (ret < 0) { - dev_err(i2c_dev->dev, "Clock prepare failed %d\n", ret); + dev_err(dev, "failed to prepare fast clock: %d\n", ret); return ret; } @@ -1770,7 +1769,7 @@ static int tegra_i2c_probe(struct platform_device *pdev) ret = clk_prepare(i2c_dev->div_clk); if (ret < 0) { - dev_err(i2c_dev->dev, "Clock prepare failed %d\n", ret); + dev_err(dev, "failed to prepare div-clk: %d\n", ret); goto unprepare_slow_clk; } @@ -1787,13 +1786,13 @@ static int tegra_i2c_probe(struct platform_device *pdev) if (!pm_runtime_enabled(&pdev->dev)) { ret = tegra_i2c_runtime_resume(&pdev->dev); if (ret < 0) { - dev_err(&pdev->dev, "runtime resume failed\n"); + dev_err(dev, "runtime resume failed\n"); goto unprepare_div_clk; } } else { ret = pm_runtime_get_sync(i2c_dev->dev); if (ret < 0) { - dev_err(&pdev->dev, "runtime resume failed\n"); + dev_err(dev, "runtime resume failed\n"); goto disable_rpm; } } @@ -1801,8 +1800,7 @@ static int tegra_i2c_probe(struct platform_device *pdev) if (i2c_dev->is_multimaster_mode) { ret = clk_enable(i2c_dev->div_clk); if (ret < 0) { - dev_err(i2c_dev->dev, "div_clk enable failed %d\n", - ret); + dev_err(dev, "failed to enable div-clk: %d\n", ret); goto put_rpm; } } @@ -1816,7 +1814,7 @@ static int tegra_i2c_probe(struct platform_device *pdev) ret = tegra_i2c_init(i2c_dev, false); if (ret) { - dev_err(&pdev->dev, "Failed to initialize i2c controller\n"); + dev_err(dev, "failed to initialize i2c controller\n"); goto release_dma; } @@ -1825,7 +1823,7 @@ static int tegra_i2c_probe(struct platform_device *pdev) ret = devm_request_irq(&pdev->dev, i2c_dev->irq, tegra_i2c_isr, IRQF_NO_SUSPEND, dev_name(&pdev->dev), i2c_dev); if (ret) { - dev_err(&pdev->dev, "Failed to request irq %i\n", i2c_dev->irq); + dev_err(dev, "failed to request irq %i\n", i2c_dev->irq); goto release_dma; } From patchwork Mon Aug 31 20:22:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254868 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 BD895C433E6 for ; Mon, 31 Aug 2020 20:24:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9785820FC3 for ; Mon, 31 Aug 2020 20:24:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B/KOs4w0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730084AbgHaUYR (ORCPT ); Mon, 31 Aug 2020 16:24:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729982AbgHaUXc (ORCPT ); Mon, 31 Aug 2020 16:23:32 -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 E9B0BC061573; Mon, 31 Aug 2020 13:23:31 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id j15so4235992lfg.7; Mon, 31 Aug 2020 13:23:31 -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=gHgiuwktFuNHisqmCuic313IjjZCR0r8Yab3mbg/wXU=; b=B/KOs4w02g8hE+IsBUTqQnmPot9G0NMpLoolhcnpdPOZ52L8Fly9+DRSScCdIe1Qho Ryr1dS3S6EvZGJ619GEYzZSMb2WuC5BbpXVseDU1Xt0IsRB9hw4pRM2w530PbY12zwkt Mt7U/3AD6iCIgt5QqgRrUp/WOTJVQbLxXOSydezCzPitbKeaqN/XHWlwuGow0+YaNpmr S3PfoyFV4fAm+dnLzAXU6/pYe95YFsU7Hn3IJ2mtQaWbtU4CwBPmylEkZV0WYq3+GhbQ f3NxcB96omwY8drfT03TlMKg9QmY5ZaOrZr7x8tonxPm1O4SJZobCgR8KKZQRhZm6Ahn EY+Q== 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=gHgiuwktFuNHisqmCuic313IjjZCR0r8Yab3mbg/wXU=; b=oaSFrycO3imk46BjWrXLSGXOTeiM/RML/8O1bWjQ7LIU+UUg6DcWJDpDKdSq6iRk7y qsz91IgrXLI1hEA3L+C402u3GlidU052fVEXGp6jcIbbSRkeEtwRSlUaImtooLLesVyR HAbwm2bOglXyDWHG84J030CIQoYVK5NsAUXScLC9l7Y85gjOOEcwbmXrVOJSuHwMGeE+ 6d5N+bEzfVE5MP9lq6uthDqaoIKS+zbqkflSL09emY3CBdqCp+FR77c7LtrmMHIB0pFI w0wcsWGAeQEPIqmvKnSpyZfdDNq1SgRF6kQT/5bd+5gio61WQ926Vluo56XFwekbFDly PHeg== X-Gm-Message-State: AOAM533oJGKHIlm8lL8eSUAVxmzhBG2w88yzF3USRgl+60dFlZCKXqoG 4ypxT96EFn+o8syym9BslEQ= X-Google-Smtp-Source: ABdhPJxt9ABEAYWD+Ee6lkGkyhj6ob/OlMlRV1yzeBhAbCEpBchmHKVUrbzxHNNT7lBYIDhO0pnlyg== X-Received: by 2002:a05:6512:2010:: with SMTP id a16mr1414256lfb.196.1598905410419; Mon, 31 Aug 2020 13:23:30 -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 z20sm1769054ljk.97.2020.08.31.13.23.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2020 13:23:29 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 05/12] i2c: tegra: Use reset_control_reset() Date: Mon, 31 Aug 2020 23:22:56 +0300 Message-Id: <20200831202303.15391-6-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200831202303.15391-1-digetx@gmail.com> References: <20200831202303.15391-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 a single reset_control_reset() instead of assert/deasset couple in order to make code cleaner a tad. Note that the reset_control_reset() uses 1 microsecond delay instead of 2 that was used previously, but this shouldn't matter. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index a7ef3a93e1b5..6957be34bc41 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -791,9 +791,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev, bool clk_reinit) u32 tsu_thd; u8 tlow, thigh; - reset_control_assert(i2c_dev->rst); - udelay(2); - reset_control_deassert(i2c_dev->rst); + reset_control_reset(i2c_dev->rst); if (i2c_dev->is_dvc) tegra_dvc_init(i2c_dev); From patchwork Mon Aug 31 20:22:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254869 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=-10.0 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, UNWANTED_LANGUAGE_BODY, 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 2F209C433E7 for ; Mon, 31 Aug 2020 20:24:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 082DA2087D for ; Mon, 31 Aug 2020 20:24:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="s2SjT3e5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727088AbgHaUYH (ORCPT ); Mon, 31 Aug 2020 16:24:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729993AbgHaUXe (ORCPT ); Mon, 31 Aug 2020 16:23:34 -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 CD0AFC061575; Mon, 31 Aug 2020 13:23:32 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id w14so8242698ljj.4; Mon, 31 Aug 2020 13:23:32 -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=GLHlPtKZW3oaSnAxdxb6Ut2lkaobqhUaiSU4BDIhVwo=; b=s2SjT3e5zert8kx3/5iT0KLS2r/M2QZPRU+fOo1Ej8jCqasA/C4EWk65mCz8t0Abc8 rJ/2+iRYqi71Uy6+XL8I0hekJbHq+WKIBOjSAbGRtJDb81Lji9CgJX8G56PuVsvneJd9 VtKq/wECUEW0A45aqY5UAPgqIZMLFFYxDHxwxc2+X/hrZStL8gEg/gDXdwa5IOGDQ4vp nQ/0HMfT69UJHBNev9lNZ5EjG3GWI+4UBVvuxWkxpdY/iWXB5IuWtNdHPV+vd/IzFaOq ghNkoR9hvpe5Id8CQRADbkItJOdQB68tDu8LXH/Btw5vNLiMqu7Ik6HugHsUZKp4gKcK KC3w== 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=GLHlPtKZW3oaSnAxdxb6Ut2lkaobqhUaiSU4BDIhVwo=; b=nGmEHifOifSq4uvMrvfDAw61F9gwuuEjRZhzstDTR/qrac6W/3EXlZsjZPOCEsktUU EndT1GKHteAJ9FQYqJhHiHrcO8W4qiIr/0BxSDJOT44sNU+w8qJoSr/VkIYf2zJSHExj w/944ITzaqMWCrNzAekcK+Pr+cyvaFhj1KS6Yu0gXnYkcfi1M2ZZOgYxwA7DtqNDirX6 kuuoZ1D+WUoA+/H1rJPV1y9ZUFqdZQtqg4Y41JijfQ1mOldgiZWiyZ8SpaQ0Q2x5d0qn GmL6f29In+jfbLbvISnhxXuop7U/jkBiP4IhSxs6aLUI8dVEZWajle21knsA0GfksQCI 5zRg== X-Gm-Message-State: AOAM530wbc65y0HAX3jtWzTuSykBuFNI/ZEHLNyd8Sc5af4eOv7jLxOH sQ063hlowGQuXviEe9iBUzs= X-Google-Smtp-Source: ABdhPJxUJ8ffttDOOKmAUBy3luHUOjhvo5Ks3SEUuUzrQnHA6uys/qvPMM57XkQ+cMi1ywycUB6DLw== X-Received: by 2002:a05:651c:1b4:: with SMTP id c20mr1320998ljn.432.1598905411289; Mon, 31 Aug 2020 13:23:31 -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 z20sm1769054ljk.97.2020.08.31.13.23.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2020 13:23:30 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 06/12] i2c: tegra: Improve formatting of function variables Date: Mon, 31 Aug 2020 23:22:57 +0300 Message-Id: <20200831202303.15391-7-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200831202303.15391-1-digetx@gmail.com> References: <20200831202303.15391-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 Reorder the definition of variables in the code in order to make code easier to read. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 51 ++++++++++++++-------------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 6957be34bc41..2c00f2e39514 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -419,8 +419,8 @@ static void tegra_i2c_release_dma(struct tegra_i2c_dev *i2c_dev) static int tegra_i2c_init_dma(struct tegra_i2c_dev *i2c_dev) { struct dma_chan *chan; - u32 *dma_buf; dma_addr_t dma_phys; + u32 *dma_buf; int err; if (!i2c_dev->hw->has_apb_dma || i2c_dev->is_vi) @@ -513,11 +513,11 @@ static int tegra_i2c_flush_fifos(struct tegra_i2c_dev *i2c_dev) static int tegra_i2c_empty_rx_fifo(struct tegra_i2c_dev *i2c_dev) { - u32 val; - int rx_fifo_avail; - u8 *buf = i2c_dev->msg_buf; size_t buf_remaining = i2c_dev->msg_buf_remaining; + u8 *buf = i2c_dev->msg_buf; int words_to_transfer; + int rx_fifo_avail; + u32 val; /* * Catch overflow due to message fully sent @@ -574,11 +574,11 @@ static int tegra_i2c_empty_rx_fifo(struct tegra_i2c_dev *i2c_dev) static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev *i2c_dev) { - u32 val; - int tx_fifo_avail; - u8 *buf = i2c_dev->msg_buf; size_t buf_remaining = i2c_dev->msg_buf_remaining; + u8 *buf = i2c_dev->msg_buf; int words_to_transfer; + int tx_fifo_avail; + u32 val; if (i2c_dev->hw->has_mst_fifo) { val = i2c_readl(i2c_dev, I2C_MST_FIFO_STATUS); @@ -785,11 +785,8 @@ static void tegra_i2c_vi_init(struct tegra_i2c_dev *i2c_dev) static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev, bool clk_reinit) { - u32 val; + u32 val, clk_divisor, clk_multiplier, tsu_thd, tlow, thigh; int err; - u32 clk_divisor, clk_multiplier; - u32 tsu_thd; - u8 tlow, thigh; reset_control_reset(i2c_dev->rst); @@ -895,9 +892,9 @@ static int tegra_i2c_disable_packet_mode(struct tegra_i2c_dev *i2c_dev) static irqreturn_t tegra_i2c_isr(int irq, void *dev_id) { - u32 status; const u32 status_err = I2C_INT_NO_ACK | I2C_INT_ARBITRATION_LOST; struct tegra_i2c_dev *i2c_dev = dev_id; + u32 status; status = i2c_readl(i2c_dev, I2C_INT_STATUS); @@ -1001,12 +998,11 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id) static void tegra_i2c_config_fifo_trig(struct tegra_i2c_dev *i2c_dev, size_t len) { - u32 val, reg; - u8 dma_burst; struct dma_slave_config slv_config = {0}; + unsigned long reg_offset; + u32 val, reg, dma_burst; struct dma_chan *chan; int ret; - unsigned long reg_offset; if (i2c_dev->hw->has_mst_fifo) reg = I2C_MST_FIFO_CONTROL; @@ -1132,9 +1128,9 @@ tegra_i2c_wait_completion_timeout(struct tegra_i2c_dev *i2c_dev, static int tegra_i2c_issue_bus_clear(struct i2c_adapter *adap) { struct tegra_i2c_dev *i2c_dev = i2c_get_adapdata(adap); - int err; unsigned long time_left; u32 reg; + int err; reinit_completion(&i2c_dev->msg_complete); reg = FIELD_PREP(I2C_BC_SCLK_THRESHOLD, 9) | I2C_BC_STOP_COND | @@ -1170,14 +1166,12 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, struct i2c_msg *msg, enum msg_end_type end_state) { - u32 packet_header; - u32 int_mask; - unsigned long time_left; - size_t xfer_size; + unsigned long time_left, xfer_time = 100; + u32 packet_header, int_mask; u32 *buffer = NULL; - int err = 0; + size_t xfer_size; bool dma; - u16 xfer_time = 100; + int err; err = tegra_i2c_flush_fifos(i2c_dev); if (err) @@ -1371,8 +1365,7 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) { struct tegra_i2c_dev *i2c_dev = i2c_get_adapdata(adap); - int i; - int ret; + int i, ret; ret = pm_runtime_get_sync(i2c_dev->dev); if (ret < 0) { @@ -1427,8 +1420,8 @@ static u32 tegra_i2c_func(struct i2c_adapter *adap) static void tegra_i2c_parse_dt(struct tegra_i2c_dev *i2c_dev) { struct device_node *np = i2c_dev->dev->of_node; - int ret; bool multi_mode; + int ret; ret = of_property_read_u32(np, "clock-frequency", &i2c_dev->bus_clk_rate); @@ -1654,14 +1647,12 @@ MODULE_DEVICE_TABLE(of, tegra_i2c_of_match); static int tegra_i2c_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct clk *div_clk, *fast_clk; struct tegra_i2c_dev *i2c_dev; + phys_addr_t base_phys; struct resource *res; - struct clk *div_clk; - struct clk *fast_clk; void __iomem *base; - phys_addr_t base_phys; - int irq; - int ret; + int irq, ret; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base_phys = res->start; From patchwork Mon Aug 31 20:22:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254872 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 10572C433E2 for ; Mon, 31 Aug 2020 20:23:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D9D3C2083E for ; Mon, 31 Aug 2020 20:23:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cYVaZxhb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730006AbgHaUXh (ORCPT ); Mon, 31 Aug 2020 16:23:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730003AbgHaUXg (ORCPT ); Mon, 31 Aug 2020 16:23:36 -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 C145BC061573; Mon, 31 Aug 2020 13:23:34 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id i10so8265247ljn.2; Mon, 31 Aug 2020 13:23:34 -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=NLHjuAzOuZSHd7eSjO+fVmyPsvQw6RuPt2s9HQlH5zc=; b=cYVaZxhbYOsEZ7KLVudLAlT5m70uAnVXUFjg6Aj3Sjzp6KQwyErJ2aRa8FTaGPnGpw EjZYAZVz/rRWYjevDjEDCR64elZSxJt3QySO7Rqx25z6UdSo47+1caJYkD83ck73hBlz 6BLFlOYxKSIJuk5o3nTlv1tbHZmfS9vgN+nTS2hsBlO+gxHMJxgz+6Snd7zt4/xXCJe0 CfJZGECHifRqe8FDsJiHKtdWTNgLQiRdoEI/bBNkF5yP7BfihyeBEVbyDJ6PhZbNwWqG km2ojhNqvydrUViaZwR7v5uuHeYhGYSr3iJJBvFCnVnHsIrfUnpuWCIQtdJKpDhlLqvT Zk1A== 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=NLHjuAzOuZSHd7eSjO+fVmyPsvQw6RuPt2s9HQlH5zc=; b=oVWEYZvyWjl2lJ/dP9ckF0GE9n1uVi++l80ex/D0Sk2H378yXEkEZP0RgXAh+1IkDf 3B81dCHVm5i/rQz0DLWLM5ucbUrks9T+eGkcSEiYrt3NwtzQaZ4hobSsYecKsELBuDvv 4IKp+p/XNyFMBAliAj3a3xBCc9KqZRMb3Cds2apGyWbvkFLV34XfXkcdxkrqrvtwPZqd ct7qEFotqcRTRQF9aeHw7VSNIK2ezGHdxXehJfddgKpRvJ46R/dyuizYmfCjWU6vVcu3 eA/B41p4GwgNH/3biB4w2Ef0bIrF+nQ6/gNboy64mlHLP5RGA53DTHhxRxCOBDAo29JA M0Wg== X-Gm-Message-State: AOAM5338doNbJdUnNPY59l44PtKAiwI0Nj0rytbtJ6iBQCWtdMqqozM5 t6FCXsn2C5i0MF/zXlOiIQo= X-Google-Smtp-Source: ABdhPJwLtpISZ3sz4+Yc7b9gpScF/LB0sk9/4oMzj3TxzE9hsK4Edko4jVQQWqLhH7LJbbz5ZYvs7Q== X-Received: by 2002:a05:651c:102c:: with SMTP id w12mr1499516ljm.464.1598905413238; Mon, 31 Aug 2020 13:23: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 z20sm1769054ljk.97.2020.08.31.13.23.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2020 13:23:32 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 08/12] i2c: tegra: Runtime PM always available on Tegra Date: Mon, 31 Aug 2020 23:22:59 +0300 Message-Id: <20200831202303.15391-9-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200831202303.15391-1-digetx@gmail.com> References: <20200831202303.15391-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 runtime PM is guaranteed to be always available on Tegra after commit 40b2bb1b132a ("ARM: tegra: enforce PM requirement"). Hence let's remove all the RPM-availability checking and handling from the code. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 525a757bdc66..ca8c16b1c049 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -1767,18 +1767,10 @@ static int tegra_i2c_probe(struct platform_device *pdev) if (!i2c_dev->is_vi) pm_runtime_irq_safe(&pdev->dev); pm_runtime_enable(&pdev->dev); - if (!pm_runtime_enabled(&pdev->dev)) { - ret = tegra_i2c_runtime_resume(&pdev->dev); - if (ret < 0) { - dev_err(dev, "runtime resume failed\n"); - goto unprepare_div_clk; - } - } else { - ret = pm_runtime_get_sync(i2c_dev->dev); - if (ret < 0) { - dev_err(dev, "runtime resume failed\n"); - goto disable_rpm; - } + ret = pm_runtime_get_sync(i2c_dev->dev); + if (ret < 0) { + dev_err(dev, "runtime resume failed\n"); + goto disable_rpm; } if (i2c_dev->is_multimaster_mode) { @@ -1836,16 +1828,10 @@ static int tegra_i2c_probe(struct platform_device *pdev) clk_disable(i2c_dev->div_clk); put_rpm: - if (pm_runtime_enabled(&pdev->dev)) - pm_runtime_put_sync(&pdev->dev); - else - tegra_i2c_runtime_suspend(&pdev->dev); + pm_runtime_put_sync(&pdev->dev); disable_rpm: - if (pm_runtime_enabled(&pdev->dev)) - pm_runtime_disable(&pdev->dev); - -unprepare_div_clk: + pm_runtime_disable(&pdev->dev); clk_unprepare(i2c_dev->div_clk); unprepare_slow_clk: @@ -1867,8 +1853,6 @@ static int tegra_i2c_remove(struct platform_device *pdev) clk_disable(i2c_dev->div_clk); pm_runtime_disable(&pdev->dev); - if (!pm_runtime_status_suspended(&pdev->dev)) - tegra_i2c_runtime_suspend(&pdev->dev); clk_unprepare(i2c_dev->div_clk); clk_unprepare(i2c_dev->slow_clk); From patchwork Mon Aug 31 20:23:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254870 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 10A8DC433E6 for ; Mon, 31 Aug 2020 20:24:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DEA762083E for ; Mon, 31 Aug 2020 20:24:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fCU/Dx8t" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728967AbgHaUYB (ORCPT ); Mon, 31 Aug 2020 16:24:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730008AbgHaUXh (ORCPT ); Mon, 31 Aug 2020 16:23:37 -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 5C96CC061573; Mon, 31 Aug 2020 13:23:37 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id h19so8183393ljg.13; Mon, 31 Aug 2020 13:23: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=jmovjAY9j0dVZf96aSac3Dc+xJBuOPrZDQWdllUq+pE=; b=fCU/Dx8tvbcoyvNUPtaTDfKJ8A7FbQiEvlY2BmXaOkJS13gveH47Yi45ImNVrGnKZS kKmwhsvSb8Kd13lZayV5/MgrEn+RCeYNtQMJ8yKOfsUFjG9EE045P8TN+BqR3gBSUQ7n 40/RO5jybe72Ty1mQr2Hl97hw0qDX2DuvW0L+F4VIpDZ0tFJ23XzTTYogj1T5Igk2SHH ep9xSMIw93HkfMS3Kri8hgKPrljp4xFiff/MTolx5UpCqiS5mGUmrKSjGl0F8Q+F72+j LT3mwXPwmWt+hOmvIxVGGc1Id9l5J6dQOYvO836o08ynX3JnMHZ2ylUD695qmZyvayf3 UZnA== 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=jmovjAY9j0dVZf96aSac3Dc+xJBuOPrZDQWdllUq+pE=; b=RaMmWwmEbLucCfP/Lg6WFEebtGaG/D8HEOCwC8w6aO01qQKhpvgaGRXUNH2yZ6/DE6 PxTvtHu1DY1byW7SpNrILjCXZ71IvhE+NQYqjf9ke1Dwvt3GoOr9bvOS9yMF5loy+cac bjdxhGwFe5cqSgNK1+KZdb1rAMxx17jbWxlDkz0/b5IS5P5SBpLGQLL8gCY74tfTE+Rr 5hs5oBQcjLX0k77iIOckCWzsV3cttjiYeMD+r5UvLIAOKXz2NmVsbAewDLDYTTtAdGXv YN5n/BErmd46PyFtJ2VHj3bVr4s4XCBbJmftK4DYK0WjHpi7C7siUNaYzTNVOBD5YfGW sl3A== X-Gm-Message-State: AOAM530IvnBYqvMNfoavRjzY6qkxGdTETkjSUiFJFIbQfUu8j9MlWTgQ 9ruSmZ1mSYprfE2/uGReqAs= X-Google-Smtp-Source: ABdhPJyDsebouJmCUaVM3mg/nCCMNc4U5uho2p+q/dBV12nLUJ5aUkeoZBXZXWR8y3L8cwD7jisoKw== X-Received: by 2002:a2e:9810:: with SMTP id a16mr1235522ljj.157.1598905415849; Mon, 31 Aug 2020 13:23: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 z20sm1769054ljk.97.2020.08.31.13.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2020 13:23:35 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 11/12] i2c: tegra: Remove likely/unlikely from the code Date: Mon, 31 Aug 2020 23:23:02 +0300 Message-Id: <20200831202303.15391-12-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200831202303.15391-1-digetx@gmail.com> References: <20200831202303.15391-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. 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 8c8f3189928e..d9b9fe6b5637 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -910,7 +910,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; @@ -1341,7 +1341,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, true); From patchwork Mon Aug 31 20:23:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254871 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 535C0C433E7 for ; Mon, 31 Aug 2020 20:23:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 286C12087D for ; Mon, 31 Aug 2020 20:23:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EZzqYpEO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730021AbgHaUXm (ORCPT ); Mon, 31 Aug 2020 16:23:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730012AbgHaUXi (ORCPT ); Mon, 31 Aug 2020 16:23:38 -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 44B06C061755; Mon, 31 Aug 2020 13:23:38 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id t23so8246041ljc.3; Mon, 31 Aug 2020 13:23: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=5O0l+Bq/1wXJwQvYBDxAgJWZ0eTWjkmkrvvVOAIAir0=; b=EZzqYpEO992KMUFaPjDM10IzYBgd2wd1BfoO4qpLA88MEuESOvEuC4k4PhwlB6VGLX csjALF/iMczy/bt9yWYAhRDVxsLMKvV88Rq7FOiQJaqekqSBLMy3Lt6fCnp1p76oY0/D MDqm8mw6poUaD8sSSVSdVfK5V6T17bl2Mr02WYIqVmaGSZ+/ZHGJtFlSGTWgcvqqr3ZA rMVheDSxnfBqiTAxVBa4o0c+3mtzgr0TVib4zRVXjb1EMqp30y+Fa8OuQY9XXcHYgKem NhRh7WdHzQe7qpco0xHHcZZ2Wd5OlVYxELWlWhP6MGByLN4Qh8pGUDAY6KcaJk1RJA3v KTdQ== 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=5O0l+Bq/1wXJwQvYBDxAgJWZ0eTWjkmkrvvVOAIAir0=; b=a53Pc5jbalfo7SFfwbGGzO1RKmGPDxdbL9a5WTlOdUgRKVtUTbxOTFwxhzxGNsTJ72 Sh0JtrgSVl4BLm7chdITX6VM64WN7iiUqLC4gtejeLlQalPha7bdB9UmrxY8t6XEJ+14 m0M+e7auoeKen1fdquOUw/RVajflqZqWW5JAYeSYmBseCWJQEv3dIx726sCOMxcu0Ufu C4KMhwOBq2kDkiX6NHSEDkzR1PwowPo268szYzVzXHaBAJmp4DHniQAx8MCeUvwI8csy 0kX4/S0L/Z39kWAOnQHYWH8MvLaqZS2mlacUXOyrM+xoC6YD6p/JlzG50X2SlYGa+j6b aSOA== X-Gm-Message-State: AOAM533CnObwtYrNbU+84wza2INucIB2Zv15adw6UnLiH4xE42Sc0OCv CJCsOQVteANsQz53mj7AyFc= X-Google-Smtp-Source: ABdhPJxkqPcqa95PPehmNojOvbeYBYkWZ/z5d1pbUE1VKbiuLHKegekHB2uGofevUy1PCMj8dop6PQ== X-Received: by 2002:a2e:7c0f:: with SMTP id x15mr1437701ljc.205.1598905416785; Mon, 31 Aug 2020 13:23: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 z20sm1769054ljk.97.2020.08.31.13.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2020 13:23:36 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 12/12] i2c: tegra: Factor out error recovery from tegra_i2c_xfer_msg() Date: Mon, 31 Aug 2020 23:23:03 +0300 Message-Id: <20200831202303.15391-13-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200831202303.15391-1-digetx@gmail.com> References: <20200831202303.15391-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 error recovery code from tegra_i2c_xfer_msg() in order to make this function easier to read and follow. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 46 ++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index d9b9fe6b5637..c2803fe9d834 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -1161,6 +1161,32 @@ static int tegra_i2c_issue_bus_clear(struct i2c_adapter *adap) return -EAGAIN; } +static int tegra_i2c_error_recover(struct tegra_i2c_dev *i2c_dev, + struct i2c_msg *msg) +{ + if (i2c_dev->msg_err == I2C_ERR_NONE) + return 0; + + tegra_i2c_init(i2c_dev, true); + + /* start recovery upon arbitration loss in single master mode */ + if (i2c_dev->msg_err == I2C_ERR_ARBITRATION_LOST) { + if (!i2c_dev->is_multimaster_mode) + return i2c_recover_bus(&i2c_dev->adapter); + + return -EAGAIN; + } + + if (i2c_dev->msg_err == I2C_ERR_NO_ACK) { + if (msg->flags & I2C_M_IGNORE_NAK) + return 0; + + return -EREMOTEIO; + } + + return -EIO; +} + static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, struct i2c_msg *msg, enum msg_end_type end_state) @@ -1341,24 +1367,12 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, i2c_dev->msg_err); i2c_dev->is_curr_dma_xfer = false; - if (i2c_dev->msg_err == I2C_ERR_NONE) - return 0; - tegra_i2c_init(i2c_dev, true); - /* start recovery upon arbitration loss in single master mode */ - if (i2c_dev->msg_err == I2C_ERR_ARBITRATION_LOST) { - if (!i2c_dev->is_multimaster_mode) - return i2c_recover_bus(&i2c_dev->adapter); - return -EAGAIN; - } - - if (i2c_dev->msg_err == I2C_ERR_NO_ACK) { - if (msg->flags & I2C_M_IGNORE_NAK) - return 0; - return -EREMOTEIO; - } + err = tegra_i2c_error_recover(i2c_dev, msg); + if (err) + return err; - return -EIO; + return 0; } static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],