linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Sowjanya Komatineni <skomatineni@nvidia.com>,
	"thierry.reding@gmail.com" <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Mantravadi Karthik <mkarthik@nvidia.com>,
	Shardar Mohammed <smohammed@nvidia.com>,
	Timo Alho <talho@nvidia.com>
Cc: "linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>
Subject: Re: [PATCH V15 4/6] i2c: tegra: Add DMA support
Date: Fri, 8 Feb 2019 19:15:20 +0300	[thread overview]
Message-ID: <21901823-2ec1-6bd5-d0df-2360858f2b7e@gmail.com> (raw)
In-Reply-To: <BYAPR12MB339863A43F030013DCA7F548C2690@BYAPR12MB3398.namprd12.prod.outlook.com>

08.02.2019 18:58, Sowjanya Komatineni пишет:
> 
> 
>>> Please use "release_dma:" variant that I suggested in the comment to v14 because:
>>>>
>>> 1) It's just a good (and common-style in kernel) tone to unwind errors handling in the opposite order, it makes code more straight forward and helps to avoid silly mistakes.
>>>
>>> 2) It keeps the current code consistent in regards to probe error-handling.
>>>
>>
>> Can move tegra_i2c_release_dma under the same disable_div_clk label before clk_disable
>>
>> Order in probe is
> 	clk_prepare
> 	i2c_runtime_resume
> 	clk_enable in case of multimaster mode
> 	i2c_init_dma
>>
>> unwinding should be order is
> 	release_dma
> 	disable_div_clk
> 	disable_rpm
> 	unprepared
>>
>> Probe failure from tegra_i2c_init_dma, tegra_i2c_init, devm_request_irq, i2c_add_numbered_adapter all of them perform goto disable_div_clk
>>
>> I can add tegra_i2c_release_dma before performing clock disable under same disable_div_clk so all existing disable_div_clk labels remain same.
>> Otherwise adding new label release_dma causes all goto disable_div_clk statement also to be changed but its same as adding release_dma under disable_div_clk above the clk_disable.
>>
> 
> OK, please ignore above. will add release_dma to show explicitly for readability.
> With release_dma all error handlers performing disable_clk_div need to go thru release dma and disable_clk_div label is not needed.

tegra_i2c_init_dma() releases dma itself in a case of error, hence it should jump to the disable_clk_div.

> So having release dma under disable_clk before clk_disable function is also same. 
> Please confirm if this is ok to use same disable_div_clk or do you prefer release_dma label removing disable_div_clk

In general goto-label naming should reflect the actual jump-action. If goto jumps to dma-releasing, then the action is release-dma and not disable-clk.

Hence the correct variant is:

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 7104213d813b..62e81096fb55 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -1604,14 +1604,14 @@ 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");
-               goto disable_div_clk;
+               goto release_dma;
        }
 
        ret = devm_request_irq(&pdev->dev, i2c_dev->irq,
                        tegra_i2c_isr, 0, dev_name(&pdev->dev), i2c_dev);
        if (ret) {
                dev_err(&pdev->dev, "Failed to request irq %i\n", i2c_dev->irq);
-               goto disable_div_clk;
+               goto release_dma;
        }
 
        i2c_set_adapdata(&i2c_dev->adapter, i2c_dev);
@@ -1625,14 +1625,16 @@ static int tegra_i2c_probe(struct platform_device *pdev)
 
        ret = i2c_add_numbered_adapter(&i2c_dev->adapter);
        if (ret)
-               goto disable_div_clk;
+               goto release_dma;
 
        return 0;
 
+release_dma:
+       tegra_i2c_release_dma(i2c_dev);
+
 disable_div_clk:
        if (i2c_dev->is_multimaster_mode)
                clk_disable(i2c_dev->div_clk);
-       tegra_i2c_release_dma(i2c_dev);
 
 disable_rpm:
        pm_runtime_disable(&pdev->dev);

  reply	other threads:[~2019-02-08 16:15 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-07 21:47 [PATCH V15 1/6] i2c: tegra: sort all the include headers alphabetically Sowjanya Komatineni
2019-02-07 21:47 ` [PATCH V15 2/6] i2c: tegra: add bus clear Master Support Sowjanya Komatineni
2019-02-07 21:47 ` [PATCH V15 3/6] i2c: tegra: fix maximum transfer size Sowjanya Komatineni
2019-02-07 22:09   ` Dmitry Osipenko
2019-02-07 22:25     ` Dmitry Osipenko
2019-02-08 12:46       ` Dmitry Osipenko
2019-02-08 14:12         ` Peter Rosin
2019-02-08 14:32           ` Dmitry Osipenko
2019-02-08 15:25             ` Sowjanya Komatineni
2019-02-08 15:44               ` Dmitry Osipenko
2019-02-07 21:47 ` [PATCH V15 4/6] i2c: tegra: Add DMA support Sowjanya Komatineni
2019-02-08 12:47   ` Dmitry Osipenko
2019-02-08 15:49     ` Sowjanya Komatineni
2019-02-08 15:55       ` Sowjanya Komatineni
2019-02-08 15:58         ` Sowjanya Komatineni
2019-02-08 16:15           ` Dmitry Osipenko [this message]
2019-02-07 21:47 ` [PATCH V15 5/6] i2c: tegra: update transfer timeout Sowjanya Komatineni
2019-02-07 21:47 ` [PATCH V15 6/6] i2c: tegra: add i2c interface timing support Sowjanya Komatineni
2019-02-08 12:53   ` Dmitry Osipenko
2019-02-08 13:00     ` Dmitry Osipenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=21901823-2ec1-6bd5-d0df-2360858f2b7e@gmail.com \
    --to=digetx@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mkarthik@nvidia.com \
    --cc=skomatineni@nvidia.com \
    --cc=smohammed@nvidia.com \
    --cc=talho@nvidia.com \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).