From: zhong jiang <zhongjiang@huawei.com>
To: Maxime Ripard <mripard@kernel.org>
Cc: <broonie@kernel.org>, <lgirdwood@gmail.com>, <perex@perex.cz>,
<tiwai@suse.com>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ASoC: sun4i: Use PTR_ERR_OR_ZERO to simplify the code
Date: Fri, 1 Nov 2019 19:55:42 +0800 [thread overview]
Message-ID: <5DBC1D3E.8080705@huawei.com> (raw)
In-Reply-To: <20191101091355.ibbet6a2zb23bpjn@hendrix>
On 2019/11/1 17:13, Maxime Ripard wrote:
> On Thu, Oct 31, 2019 at 10:09:39PM +0800, zhong jiang wrote:
>> It is better to use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR.
>>
>> Signed-off-by: zhong jiang <zhongjiang@huawei.com>
>> ---
>> sound/soc/sunxi/sun4i-i2s.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
>> index d0a8d58..72012a6 100644
>> --- a/sound/soc/sunxi/sun4i-i2s.c
>> +++ b/sound/soc/sunxi/sun4i-i2s.c
>> @@ -1174,10 +1174,8 @@ static int sun4i_i2s_init_regmap_fields(struct device *dev,
>> i2s->field_fmt_sr =
>> devm_regmap_field_alloc(dev, i2s->regmap,
>> i2s->variant->field_fmt_sr);
>> - if (IS_ERR(i2s->field_fmt_sr))
>> - return PTR_ERR(i2s->field_fmt_sr);
>>
>> - return 0;
>> + return PTR_ERR_OR_ZERO(i2s->field_fmt_sr);
> I don't find it "better". This couples the error handling and the
> success case, and it makes it harder to extend in the future.
PTR_ERR_OR_ZERO has implemented the if(IS_ERR(...)) + PTR_ERR. It is
feasible to replace it and more readable at least now.
As you said, PTR_ERR_OR_ZERO should be removed ? :-(
Thanks,
zhong jiang
> Maxime
next prev parent reply other threads:[~2019-11-01 11:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-31 14:09 [PATCH] ASoC: sun4i: Use PTR_ERR_OR_ZERO to simplify the code zhong jiang
2019-11-01 9:13 ` Maxime Ripard
2019-11-01 11:55 ` zhong jiang [this message]
2019-11-01 14:53 ` Maxime Ripard
2019-11-02 14:45 ` zhong jiang
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=5DBC1D3E.8080705@huawei.com \
--to=zhongjiang@huawei.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mripard@kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.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).