From patchwork Wed Aug 16 20:04:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Sionneau X-Patchwork-Id: 13355629 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 D20FDC25B76 for ; Wed, 16 Aug 2023 20:11:46 +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:References:In-Reply-To: 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: List-Owner; bh=qZCVCT5fKs7JjZpr2U3QwXrfSROlWcRxWVxEF8gN7ds=; b=4IHnsIiPryEriZ g57vZpfX0EKwiqpywCI73f3NA/2K1he1Jh2brJ7HOuV0SyXTE2saFVkzzBnwdi3dTMA+GyM1bkh+q aWv3dGMVdGtxZjWMUk6Jt5v798PwuYLPUCRcup/exus5KID7yC/f4wdnS7Jbp+zXfa0mFlbH4QvfD C/tP2gm5yIAGqvxlCZGvbzDqZSrdgJTlkdczQC3Ub2HO2qqxt4UugWm5/qtut3M0wvEb3QajD1hOO hu3U0papffcjEu5Xjod+NrauAVwawtcgFtD/bfI5FRPjBpJZJeuBSiX59BzLz1rTyeAF3iwGK7Wpl zgJfbyeEPGA0Hawuq1Uw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWMrS-004vvp-0t; Wed, 16 Aug 2023 20:11:22 +0000 Received: from mx4.sionneau.net ([51.15.250.1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qWMrE-004vqn-2I for linux-arm-kernel@lists.infradead.org; Wed, 16 Aug 2023 20:11:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sionneau.net; s=selectormx4; t=1692216268; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9z8MSlMelNlflt6ODHLzPuDfrH7+1zhOszToYuWOP8k=; b=zHMl55jDuyuMVmijysBOPCvsx49I3VW7DZd+TmjKXnJzJykmrnhuPpd7ruaAZ71kceJCTk dx8sFRGPibQvR8Q4K7HAxxsq/U8dcjXU2D2MxhWt4IcDXYWUSOBj0JYx0gOrZdYZMYuMjU W1+rJ8SvfhkSClQmDUvNWd41VJSIBb4= Received: from fallen-ThinkPad-X260.hotspot.hub-one.net ( [37.169.176.143]) by mx4.sionneau.net (OpenSMTPD) with ESMTPSA id 5d17dcb0 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 16 Aug 2023 20:04:27 +0000 (UTC) From: Yann Sionneau To: Andi Shyti , Codrin Ciubotariu , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Michal Simek , Oleksij Rempel , Pengutronix Kernel Team , Shawn Guo , Sascha Hauer , Fabio Estevam , NXP Linux Team Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Yann Sionneau Subject: [PATCH 3/4] i2c: i2c-cadence: Reset pinctrl to NULL in case devm_pinctrl_get() fails Date: Wed, 16 Aug 2023 22:04:09 +0200 Message-Id: <20230816200410.62131-4-yann@sionneau.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816200410.62131-1-yann@sionneau.net> References: <20230816200410.62131-1-yann@sionneau.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230816_131109_026128_74B8F7DD X-CRM114-Status: GOOD ( 10.77 ) 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 The core i2c code generally checks if pinctrl has been properly initialized by just doing 'if (p) some_pinctrl_function(p)'. In case devm_pinctrl_get() fails, pinctrl variable contains an error instead of a valid pointer. To prevent core i2c code to crash, reset back pinctrl pointer to NULL when this happens. Signed-off-by: Yann Sionneau --- drivers/i2c/busses/i2c-cadence.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c index 9849f4502570..aa9ae0755674 100644 --- a/drivers/i2c/busses/i2c-cadence.c +++ b/drivers/i2c/busses/i2c-cadence.c @@ -1299,6 +1299,7 @@ static int cdns_i2c_probe(struct platform_device *pdev) if (IS_ERR(id->rinfo.pinctrl)) { int err = PTR_ERR(id->rinfo.pinctrl); + id->rinfo.pinctrl = NULL; dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n"); if (err != -ENODEV) return err;