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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EC8C6C001B0 for ; Wed, 16 Aug 2023 10:10:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MbTzJ3XkMEl5m2gMuIAUX515eoxBgkwXTi2EQFq0AjM=; b=qf56/ckiHZPULr J0UiNTEb6BgE87GKuHYTzMlEsHoRPkqE5aTdIidOTRWe/s6IU4gAX4CRu62oG+mvUCmTHLJkiIomo IgEiIJUfoee5+q+crJVuNYSD2l1DtQVaIJxRl2y/yTWT82c8wgS8eDPR+1xHs9P9wWS5+/URJqkMh D9jSLIv+9wM/emGOSMOW+tjxejP18WAX78vKu/iVnYqhsvrx6UYeLBCs457VtAth5wOkSgdGRwVH4 DROy4Egilyff1Ld+V4mdCwT7me1ik4LdlAv9PV6fVx2jsDQwlOqvhPGG2OfMjjM+JlL4ZxygV+ylc ikPjyePtqaTXtA7fy3tg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWDTq-003haZ-15; Wed, 16 Aug 2023 10:10:22 +0000 Received: from [2001:4d48:ad52:32c8:5054:ff:fe00:142] (helo=pandora.armlinux.org.uk) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qWDTm-003hPR-1q for linux-arm-kernel@lists.infradead.org; Wed, 16 Aug 2023 10:10:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=jS5E3IDC20yQUz3d27cNi5f4Pv23ioPbtrI9hkgtSzc=; b=iMaYJgBeJAMEf9HdYIjCwHAOvR QxSI7uColcdNvmfU+YwTm5t5MsXqC/kiCB9i+nukULQBddYA+em7erv2iHXSPNYX7+pfuI65R1ph1 D3zheN9aJaNBRMHRMdzQkWC29cb/f4arJzikIEhAwVfVpKQb3nzbivlPcLy88ZO+iJ7KwXWx58KZB q2M15h+DMa4uiKkw1q9nXO7L7Ei+NZERaMfrACZhZMH29TdkABDx/i9FdboU0gfYkpadsBtgdkMKA ZeJvjBRXCi5OS/5RpR+GD1DgBZbR6m91yV8MftrCz0kj+MBHPGXpRcAphERXn6zjf5VkgNm9TgDJS /Pceuhow==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:45230) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qWDRe-0002co-15; Wed, 16 Aug 2023 11:08:06 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qWDRb-0007ut-EU; Wed, 16 Aug 2023 11:08:03 +0100 Date: Wed, 16 Aug 2023 11:08:03 +0100 From: "Russell King (Oracle)" To: Ruan Jinjie Subject: Re: [PATCH -next] I2C: Use helper function IS_ERR_OR_NULL() Message-ID: References: <20230816094618.2854084-1-ruanjinjie@huawei.com> <50f61322-de65-1632-d404-7dcfe9a82744@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <50f61322-de65-1632-d404-7dcfe9a82744@huawei.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230816_031018_607435_77D909B9 X-CRM114-Status: GOOD ( 21.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Andi Shyti , Fabio Estevam , Sascha Hauer , Claudiu Beznea , linux-i2c@vger.kernel.org, Pengutronix Kernel Team , Codrin Ciubotariu , Oleksij Rempel , Shawn Guo , linux-arm-kernel@lists.infradead.org, NXP Linux Team Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Aug 16, 2023 at 05:48:34PM +0800, Ruan Jinjie wrote: > > > On 2023/8/16 17:46, 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)) { > > Sorry, there is a problem, please ignore it. I don't think these conversions are appropriate for devm_pinctrl_get(). If one reads the code for devm_pinctrl_get() and pinctrl_get(), then one finds that it will never return NULL. So the tests for NULL do not serve any practical purpose than giving coders a warm fuzzy feeling that they've tested for a NULL pointer. Practically, they are of no use, so should be removed... thus making the conversion to IS_ERR_OR_NULL() irrelevant. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel