From patchwork Wed Aug 16 20:04:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Sionneau X-Patchwork-Id: 1822022 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sionneau.net header.i=@sionneau.net header.a=rsa-sha256 header.s=selectormx4 header.b=PWgD44hK; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4RQzdk4RdXz1yXY for ; Thu, 17 Aug 2023 06:05:30 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237492AbjHPUE6 (ORCPT ); Wed, 16 Aug 2023 16:04:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239509AbjHPUEZ (ORCPT ); Wed, 16 Aug 2023 16:04:25 -0400 Received: from mx4.sionneau.net (mx4.sionneau.net [51.15.250.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBEFA1BE8; Wed, 16 Aug 2023 13:04:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sionneau.net; s=selectormx4; t=1692216262; 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=ZyPwLzsO5Iq18JykTf6YehEkeDl4Bvn+ZZAZBGf+JIM=; b=PWgD44hKBNwvnR/2y9IyD/C+e96cOmyQJRqYvith4gpGhFq0j8i3KPzo/pjCslMT7BcgrE QeM2SAkHTlYEM59jP6XP7eVUDHzJagCyS74SKDmflbCZ7wEpU654N2eTkp4lv8IxlAP7Nm k7e/ukCccQLpcohO0P8FE0iKLyG5GK8= Received: from fallen-ThinkPad-X260.hotspot.hub-one.net ( [37.169.176.143]) by mx4.sionneau.net (OpenSMTPD) with ESMTPSA id 8204e85d (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 16 Aug 2023 20:04:21 +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 1/4] i2c: mv64xxx: devm_pinctrl_get() cannot return NULL Date: Wed, 16 Aug 2023 22:04:07 +0200 Message-Id: <20230816200410.62131-2-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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Remove unnecessary check against NULL for devm_pinctrl_get() return value. Signed-off-by: Yann Sionneau --- drivers/i2c/busses/i2c-mv64xxx.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index fd8403b07fa6..0c4a0110978f 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c @@ -947,8 +947,6 @@ static int mv64xxx_i2c_init_recovery_info(struct mv64xxx_i2c_data *drv_data, return -EPROBE_DEFER; dev_info(dev, "can't get pinctrl, bus recovery not supported\n"); return PTR_ERR(rinfo->pinctrl); - } else if (!rinfo->pinctrl) { - return -ENODEV; } drv_data->adapter.bus_recovery_info = rinfo; From patchwork Wed Aug 16 20:04:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Sionneau X-Patchwork-Id: 1822021 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sionneau.net header.i=@sionneau.net header.a=rsa-sha256 header.s=selectormx4 header.b=bmf5vcGV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4RQzdk1bRTz1xrk for ; Thu, 17 Aug 2023 06:05:30 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345895AbjHPUE6 (ORCPT ); Wed, 16 Aug 2023 16:04:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345874AbjHPUE1 (ORCPT ); Wed, 16 Aug 2023 16:04:27 -0400 Received: from mx4.sionneau.net (mx4.sionneau.net [51.15.250.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2D861BE8; Wed, 16 Aug 2023 13:04:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sionneau.net; s=selectormx4; t=1692216265; 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=TR5waAKqgJDCuh+rCJahhuidB0eME1Oapggx75cClbQ=; b=bmf5vcGVXogUm50nsSTAHcIBD2I5AmKXA/kHZTFQJuyCiNvaiqrwt3o7cPD78DrqxN1NkR Gh6buxGqfMDtuyP0h/tT5166PzLHRd1Dnw7OYAd0Bs1I5bBMopB1FOA6ivRAO6vo/lO4KG n/tTHz+mtjj1MDoJ9ii7i9koJG2eYP4= Received: from fallen-ThinkPad-X260.hotspot.hub-one.net ( [37.169.176.143]) by mx4.sionneau.net (OpenSMTPD) with ESMTPSA id b10c9cd5 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 16 Aug 2023 20:04:24 +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 2/4] i2c: at91-master: devm_pinctrl_get() cannot return NULL Date: Wed, 16 Aug 2023 22:04:08 +0200 Message-Id: <20230816200410.62131-3-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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Remove unnecessary check against NULL for devm_pinctrl_get() return value. Signed-off-by: Yann Sionneau Acked-by: Hari Prasath Gujulan Elango --- drivers/i2c/busses/i2c-at91-master.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-at91-master.c b/drivers/i2c/busses/i2c-at91-master.c index c0c35785a0dc..b598d2439eb1 100644 --- a/drivers/i2c/busses/i2c-at91-master.c +++ b/drivers/i2c/busses/i2c-at91-master.c @@ -832,7 +832,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); } 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: 1822023 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sionneau.net header.i=@sionneau.net header.a=rsa-sha256 header.s=selectormx4 header.b=zHMl55jD; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4RQzdk5hrKz1yXZ for ; Thu, 17 Aug 2023 06:05:30 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345971AbjHPUE7 (ORCPT ); Wed, 16 Aug 2023 16:04:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346019AbjHPUEb (ORCPT ); Wed, 16 Aug 2023 16:04:31 -0400 Received: from mx4.sionneau.net (mx4.sionneau.net [51.15.250.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 179BB1FE3; Wed, 16 Aug 2023 13:04:28 -0700 (PDT) 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.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; From patchwork Wed Aug 16 20:04:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Sionneau X-Patchwork-Id: 1822024 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sionneau.net header.i=@sionneau.net header.a=rsa-sha256 header.s=selectormx4 header.b=SRo7JCOY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4RQzdl0mKHz1yXb for ; Thu, 17 Aug 2023 06:05:31 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239509AbjHPUFA (ORCPT ); Wed, 16 Aug 2023 16:05:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346031AbjHPUEe (ORCPT ); Wed, 16 Aug 2023 16:04:34 -0400 Received: from mx4.sionneau.net (mx4.sionneau.net [51.15.250.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21F732110; Wed, 16 Aug 2023 13:04:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sionneau.net; s=selectormx4; t=1692216270; 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=26DUZLe4PV/0nEWQNlxeRLfNg1jDJUvrXE6RFg1ThPg=; b=SRo7JCOYfnLKt/roeC4G6zaXhgZ8gfwdQ52MwzmbFJUQLcW4J7OpqrjU7aa6OSvPCxk8H2 XlUK5hS6P81rJOdSZ9sQJu72UpGRB0zBphTcHmBmBRnxV7onSSw/WnwHfyNwJk4zi5QlIb tdsuR+X8pdGTCMaihQaiPRSlS6XlkB0= Received: from fallen-ThinkPad-X260.hotspot.hub-one.net ( [37.169.176.143]) by mx4.sionneau.net (OpenSMTPD) with ESMTPSA id dbbb5935 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 16 Aug 2023 20:04:30 +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 4/4] i2c: imx: devm_pinctrl_get() cannot return NULL Date: Wed, 16 Aug 2023 22:04:10 +0200 Message-Id: <20230816200410.62131-5-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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Remove unnecessary check against NULL for devm_pinctrl_get() return value. Signed-off-by: Yann Sionneau Acked-by: Oleksij Rempel --- drivers/i2c/busses/i2c-imx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 65128a73e8a3..502276e8ded5 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -1389,7 +1389,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); }