Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp370593ybx; Fri, 1 Nov 2019 04:57:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHlkpDbEyuofICDslBzZgg910N9faZ8h+Vb8/p8vtvdADfu+xXgAQybIV84d66LdF6IzPg X-Received: by 2002:a50:cd14:: with SMTP id z20mr11797222edi.226.1572609453800; Fri, 01 Nov 2019 04:57:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572609453; cv=none; d=google.com; s=arc-20160816; b=iMLutmdXxm8PFhdJo/5PgFwEN8fsFX623pnzKcO90sBYNy/z2/Nsx2MgpY3XBlu+CG qaru0e1xpt7aa+Bw5gSWzmEWSWua3i6ATtBFgBUpHUt7s5bBNzHFY8+6FHWnA3v3hihe zSTuhc70VxeMuryZJBqhrrmgQ41GNZt1Q022NN6khZGA0QjftWSw7D18R3sdJD/bfZ8b HghGlPilFIco4wIpNbybLAomUDhK3g8+wyXD1kCWFQimz5fnEdh33KlHNr3J3/qBQM+G 9Sz4WbnSkaKa9icoqHtE1BdXbkFJcWz9xL/G/iru9w3mRrYiCKNSTWJx1xdnxgdNYBLs 3wFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :references:subject:cc:to:mime-version:user-agent:from:date :message-id; bh=M1FQVqctvcwXpsQfpMKhng0st/FvEJNOsadVkiaRfas=; b=O3YuDjA4pZzcboecf4tPXQRL3cvGb16fGJf2GVq50W0t83ZpJnIW4nQG2mhMlHfJqp MJCo0Tb6XqYc38qgYBs1zOGGLYoGmllM4fbre5WjCcmFgLxv7mz9Y9yZ9RIqqJhdpNKd quOZIDF7DuCcyGLYnxNMHdOnw2CfNWKhHaRA2jBJ0a8s0fHc0MICyG7dBfFALS6Y191X MJRBE+6TSpIdsmNAnpbiKizYyYpbHGi5oqCYapIMp3bC05jEy6C5jMb0Dv33PtgVOjn2 +9PnAajasi4/gCBsDc7AIikixzN2Xf1FBwQWT0yFI4WNgE6fwqwK6VAOgwEFxd8X8Ntu T1ug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y11si90850edd.182.2019.11.01.04.57.10; Fri, 01 Nov 2019 04:57:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730489AbfKALzt (ORCPT + 99 others); Fri, 1 Nov 2019 07:55:49 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:56848 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726957AbfKALzt (ORCPT ); Fri, 1 Nov 2019 07:55:49 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 201F2492D232B3534227; Fri, 1 Nov 2019 19:55:46 +0800 (CST) Received: from [127.0.0.1] (10.133.219.218) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.439.0; Fri, 1 Nov 2019 19:55:43 +0800 Message-ID: <5DBC1D3E.8080705@huawei.com> Date: Fri, 1 Nov 2019 19:55:42 +0800 From: zhong jiang User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Maxime Ripard CC: , , , , Subject: Re: [PATCH] ASoC: sun4i: Use PTR_ERR_OR_ZERO to simplify the code References: <1572530979-27595-1-git-send-email-zhongjiang@huawei.com> <20191101091355.ibbet6a2zb23bpjn@hendrix> In-Reply-To: <20191101091355.ibbet6a2zb23bpjn@hendrix> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.133.219.218] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> --- >> 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