From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F3ABC05052 for ; Thu, 17 Aug 2023 01:40:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244138AbjHQBjm (ORCPT ); Wed, 16 Aug 2023 21:39:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347577AbjHQBjl (ORCPT ); Wed, 16 Aug 2023 21:39:41 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B734C272B for ; Wed, 16 Aug 2023 18:39:40 -0700 (PDT) Received: from kwepemi500008.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RR71j5xssz1GDVL; Thu, 17 Aug 2023 09:38:17 +0800 (CST) Received: from [10.67.109.254] (10.67.109.254) by kwepemi500008.china.huawei.com (7.221.188.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 17 Aug 2023 09:39:38 +0800 Message-ID: <7932ba22-8f1d-745d-fbfd-2984e90c66c9@huawei.com> Date: Thu, 17 Aug 2023 09:39:37 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH -next] I2C: Use helper function IS_ERR_OR_NULL() Content-Language: en-US To: "Russell King (Oracle)" CC: , , Codrin Ciubotariu , Andi Shyti , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Oleksij Rempel , Pengutronix Kernel Team , Shawn Guo , Sascha Hauer , Fabio Estevam , NXP Linux Team References: <20230816094618.2854084-1-ruanjinjie@huawei.com> From: Ruan Jinjie In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.109.254] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500008.china.huawei.com (7.221.188.139) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org On 2023/8/16 18:22, Russell King (Oracle) wrote: > On Wed, Aug 16, 2023 at 05:46:18PM +0800, Ruan Jinjie wrote: >> Use IS_ERR_OR_NULL() instead of open-coding it >> to simplify the code. >> >> Signed-off-by: Ruan Jinjie >> --- >> drivers/i2c/busses/i2c-at91-master.c | 2 +- >> drivers/i2c/busses/i2c-imx.c | 2 +- >> 2 files changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/i2c/busses/i2c-at91-master.c b/drivers/i2c/busses/i2c-at91-master.c >> index 94cff1cd527e..0e454c04a145 100644 >> --- a/drivers/i2c/busses/i2c-at91-master.c >> +++ b/drivers/i2c/busses/i2c-at91-master.c >> @@ -831,7 +831,7 @@ static int at91_init_twi_recovery_gpio(struct platform_device *pdev, >> struct i2c_bus_recovery_info *rinfo = &dev->rinfo; >> >> rinfo->pinctrl = devm_pinctrl_get(&pdev->dev); >> - if (!rinfo->pinctrl || IS_ERR(rinfo->pinctrl)) { >> + if (IS_ERR_OR_NULL(rinfo->pinctrl)) { >> dev_info(dev->dev, "can't get pinctrl, bus recovery not supported\n"); >> return PTR_ERR(rinfo->pinctrl); >> } >> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c >> index 10e89586ca72..8807c90df749 100644 >> --- a/drivers/i2c/busses/i2c-imx.c >> +++ b/drivers/i2c/busses/i2c-imx.c >> @@ -1388,7 +1388,7 @@ static int i2c_imx_init_recovery_info(struct imx_i2c_struct *i2c_imx, >> struct i2c_bus_recovery_info *rinfo = &i2c_imx->rinfo; >> >> i2c_imx->pinctrl = devm_pinctrl_get(&pdev->dev); >> - if (!i2c_imx->pinctrl || IS_ERR(i2c_imx->pinctrl)) { >> + if (!IS_ERR_OR_NULL(i2c_imx->pinctrl)) { >> dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n"); >> return PTR_ERR(i2c_imx->pinctrl); >> } > > As stated in my previous reply to a similar patch, devm_pinctrl_get() > can not return NULL, so it makes more sense to remove the test for NULL > rather than "cleaning up" the buggy code, but leaving the bugs behind. Right! I'll fix it sooner. Thank you very much. >