From patchwork Fri Aug 18 07:45:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13357407 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 DE65DC05052 for ; Fri, 18 Aug 2023 07:46:16 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Fn46PeVnoOWhEv3duEs7tb+XC4oSMuKAYQnebc0/aRQ=; b=QPChFPt7BBcdol k95DOlZGnwsya/iSzU9g7lexLcQKcVACxleUGUiEYy1f7ENxbrcCUXSa3aM07+g3rl4BpvdwSXEFa X4pX+SCiyNNY7auEjeC1Z2x30kehelb26I5razRKzoITYMfxoaCctnkiFThrfOqJb8lfisSFrOlPz 0Mq6Oiv1uC4j6JQ630J7FWK51twnxhYkLvUjxwFTV+xRKMkuSZ/6RK1McLGQFrWzqIR9utVMwddDC qqI74Q1xKvOC51inND6t6TH944mbDh3PjYvKUMnPSEVoq4NRoM96FfKv0HrnyHTLp0Kxv8eMh91ci b8E0/2ds45UkEvTTaG7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWuAz-007u5n-0t; Fri, 18 Aug 2023 07:45:45 +0000 Received: from szxga03-in.huawei.com ([45.249.212.189]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qWuAt-007u4X-0C for linux-arm-kernel@lists.infradead.org; Fri, 18 Aug 2023 07:45:43 +0000 Received: from kwepemi500008.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RRv3V59bHzFqk9; Fri, 18 Aug 2023 15:42:30 +0800 (CST) Received: from huawei.com (10.90.53.73) 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; Fri, 18 Aug 2023 15:45:29 +0800 From: Ruan Jinjie To: , , , , , , , Codrin Ciubotariu , Andi Shyti , Alexandre Belloni , Claudiu Beznea , Oleksij Rempel , Pengutronix Kernel Team , Shawn Guo , Fabio Estevam , NXP Linux Team , Wolfram Sang , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= CC: Subject: [PATCH -next v2 RESEND] I2C: Fix return value check for devm_pinctrl_get() Date: Fri, 18 Aug 2023 15:45:08 +0800 Message-ID: <20230818074509.295220-1-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi500008.china.huawei.com (7.221.188.139) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230818_004539_590054_E7EE11F1 X-CRM114-Status: GOOD ( 14.54 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Though the devm_pinctrl_get() function returns error pointers when CONFIG_PINCTRL is defined and NULL otherwise. NULL is returned on purpose for devm_pinctrl_get(). When PINCTRL is disabled NULL becomes a valid pinctrl cookie which can be passed to the other stub functions. With this drivers using pinctrl can get through their probe function without an error when PINCTRL is disabled. The same approach is taken by the clk and regulator API. It is correct to test the return value of devm_pinctrl_get() with IS_ERR(). So update the checks accordingly. Fixes: 543aa2c4da8b ("i2c: at91: Move to generic GPIO bus recovery") Fixes: fd8961c5ba9e ("i2c: imx: make bus recovery through pinctrl optional") Signed-off-by: Ruan Jinjie Acked-by: Oleksij Rempel Reviewed-by: Linus Walleij Acked-by: Nicolas Ferre --- v2: - Remove NULL check instead of using IS_ERR_OR_NULL() to avoid leaving them behind. - Update the commit title and message. --- 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..2bf1df5ef473 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(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..05d55893f04e 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(i2c_imx->pinctrl)) { dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n"); return PTR_ERR(i2c_imx->pinctrl); }