lkml.org 
[lkml]   [2019]   [Nov]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] ASoC: sun4i: Use PTR_ERR_OR_ZERO to simplify the code
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.

Maxime
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2019-11-01 10:51    [W:0.646 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site