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 90547C678DC for ; Fri, 18 Aug 2023 08:20:50 +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=yzc/LVXh8qZyOBfppBqh+rDGqLYCw7iMeZUrAnCCmiE=; b=PPUXLYpuN6VrXM u4kZ/B6tlURq39MCYynYT0j0WyjeUKuoeYg1a4M1l5IvQ4OlLvsd7UxsV8LJhGS72drJ4JOna8mu3 D2j4w+3blNs0zTbEuhQLw6SfUeQy6s/xNW5K0HKWJ5iMwhYIGN0UbmaUsMfJIq1Ac78YclweEfxfG Oc9Kcck83WP5AIGuWARECXmZsPkOTkV5ZYQh0dFDWs+gG0L8D3KaiIMkT0b4NqpBFwGnFewsqP9Xj LLUgkVMoVxPR0I5q6SAlMcUnpB+cURK/xeZrFfooI3l63Vvz2oHqctBlqjpYqTNheyXlUZDFmJXe4 H/lf+HxPtyh2fpDVczTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWuiY-007zEM-1q; Fri, 18 Aug 2023 08:20:26 +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 1qWuiN-007zBx-2u for linux-arm-kernel@lists.infradead.org; Fri, 18 Aug 2023 08:20:25 +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=owpgb5l/lxuxepAaApb9Hlae+aWMk7hqPLR/YcXjBK0=; b=b+Wia7Y2Sb+DLz7GFyL7e7dNRF btSEw8VOxVMSMoqWr8HbRvseHpA2lHDL5Lf6OYswtryIOjZrh5xgPq0xzE5yUpBJ8TDgrMcVnnYzQ S4U2LdptlrGzRN+kA21b08foJsTJHCUh00/lVpOMS7f4CC4bfP3hMxIpNGwg4K+0EXrCh9Ywm47PU d/sbScrd04aSDJUL/tTzjtH/D2owtcVvxaLd9lxvKJ0DTFHFWG6LwB2JRMVSl8ZTGJqT48+a6sMqv nqk+1nDwb/TkRRL8kasuGpj+5s4veAljEan96agfUoNVJQAM7qWRzUx4g/DB+fEC0wzCJ9PqMjNwD raBsalfg==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:60982) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qWuiG-0005Jc-10; Fri, 18 Aug 2023 09:20:08 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qWuiD-0001TD-9m; Fri, 18 Aug 2023 09:20:05 +0100 Date: Fri, 18 Aug 2023 09:20:05 +0100 From: "Russell King (Oracle)" To: Ruan Jinjie Subject: Re: [PATCH -next v2 RESEND] I2C: Fix return value check for devm_pinctrl_get() Message-ID: References: <20230818074509.295220-1-ruanjinjie@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230818074509.295220-1-ruanjinjie@huawei.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230818_012015_983215_1855B0E2 X-CRM114-Status: GOOD ( 15.02 ) 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 , linus.walleij@linaro.org, Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , leoyang.li@nxp.com, Wolfram Sang , o.rempel@pengutronix.de, linux-i2c@vger.kernel.org, Pengutronix Kernel Team , Claudiu Beznea , Codrin Ciubotariu , Oleksij Rempel , Shawn Guo , s.hauer@pengutronix.de, 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 Fri, Aug 18, 2023 at 03:45:08PM +0800, Ruan Jinjie wrote: > 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); > } I haven't looked at the AT91 version, but... isn't the original code entirely correct? If pinctrl is not available (thus devm_pinctrl_get() returns NULL) then recovery can't work, because we can't switch the I2C pins between the I2C controller and GPIO. So, isn't it quite correct to print "can't get pinctrl, bus recovery not supported" because the I2C bus can't be recovered without pinctrl? The PTR_ERR() is also fine - because if pinctrl is not present and returns NULL, we'll end up returning zero, which is exactly what we want. The alternative would be to open code that, maybe with a more accurate message: if (!i2c_imx->pinctrl) { dev_info(&pdev->dev, "pinctrl unavailable, bus recovery not supported\n"); return 0; } if (IS_ERR(i2c_imx->pinctrl) { ... -- 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