mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Vidya Sagar <vidyas@nvidia.com>,
	Aishwarya Ramakrishnan <aishwaryarj100@gmail.com>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org,
	Julia Lawall <julia.lawall@inria.fr>
Subject: Re: [PATCH] phy: tegra: Use PTR_ERR_OR_ZERO() to simplify code
Date: Wed, 6 May 2020 18:40:25 +0300	[thread overview]
Message-ID: <d3397bc6-099e-591a-ff60-5e67da478526@gmail.com> (raw)
In-Reply-To: <be185976-3d12-f49d-6131-39f5075e0190@nvidia.com>

06.05.2020 14:47, Vidya Sagar пишет:
> Thanks for pushing this change.
> I'm fine with this change as it is attempting to change only the last
> occurrence of the (IS_ERR(...)) + PTR_ERR combination.
> But, this code was initially written with PTR_ERR_OR_ZERO() itself but
> later changed to use (IS_ERR(...)) + PTR_ERR based on the review comment
> from Dmitry Osipenko ( https://lkml.org/lkml/2019/6/20/1457 )
> 
> Adding Dmitry as well to review the change.
> 
> I'm fine with this change.
> Reviewed-by: Vidya Sagar <vidyas@nvidia.com>
> 
> On 05-May-20 8:30 PM, Aishwarya Ramakrishnan wrote:
>> External email: Use caution opening links or attachments
>>
>>
>> PTR_ERR_OR_ZERO contains if(IS_ERR(...)) + PTR_ERR.
>>
>> Generated by: scripts/coccinelle/api/ptr_ret.cocci
>>
>> Signed-off-by: Aishwarya Ramakrishnan <aishwaryarj100@gmail.com>
>> ---
>>   drivers/phy/tegra/phy-tegra194-p2u.c | 5 +----
>>   1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/drivers/phy/tegra/phy-tegra194-p2u.c
>> b/drivers/phy/tegra/phy-tegra194-p2u.c
>> index 7042bed9feaa..42394d27f4cb 100644
>> --- a/drivers/phy/tegra/phy-tegra194-p2u.c
>> +++ b/drivers/phy/tegra/phy-tegra194-p2u.c
>> @@ -92,10 +92,7 @@ static int tegra_p2u_probe(struct platform_device
>> *pdev)
>>          phy_set_drvdata(generic_phy, phy);
>>
>>          phy_provider = devm_of_phy_provider_register(dev,
>> of_phy_simple_xlate);
>> -       if (IS_ERR(phy_provider))
>> -               return PTR_ERR(phy_provider);
>> -
>> -       return 0;
>> +       return PTR_ERR_OR_ZERO(phy_provider);
>>   }

Quite some people think that such a change doesn't bring any benefits,
it doesn't help readability of the code, it even makes harder to read
the code for a human being.

IIRC, there were some requests in the past to remove that cocci rule to
stop such auto-generated patches to re-occur over and over again.

The PTR_ERR_OR_ZERO is good to use in a cases where it's not returned
directly, like this:

phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
err = PTR_ERR_OR_ZERO(phy_provider);
if (err)
	return err;

return 0;

      reply	other threads:[~2020-05-06 15:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-05 15:00 Aishwarya Ramakrishnan
2020-05-06 11:47 ` Vidya Sagar
2020-05-06 15:40   ` Dmitry Osipenko [this message]

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=d3397bc6-099e-591a-ff60-5e67da478526@gmail.com \
    --to=digetx@gmail.com \
    --cc=aishwaryarj100@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=julia.lawall@inria.fr \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=thierry.reding@gmail.com \
    --cc=vidyas@nvidia.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

all inboxes | Powered by JetHome®