From patchwork Thu Dec 7 07:58:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rouven Czerwinski X-Patchwork-Id: 13482854 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0F3F10F4 for ; Wed, 6 Dec 2023 23:58:58 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rB9Hb-0007wI-Ry; Thu, 07 Dec 2023 08:58:55 +0100 Received: from [2a0a:edc0:0:1101:1d::54] (helo=dude05.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rB9Ha-00E8h2-4m; Thu, 07 Dec 2023 08:58:54 +0100 Received: from rcz by dude05.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rB9Ha-00CyIz-0I; Thu, 07 Dec 2023 08:58:54 +0100 From: Rouven Czerwinski To: Johannes Berg , Josua Mayer , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: pza@pengutronix.de, Rouven Czerwinski , stable@vger.kernel.org, Johannes Berg , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH v2] net: rfkill: gpio: set GPIO direction Date: Thu, 7 Dec 2023 08:58:36 +0100 Message-Id: <20231207075835.3091694-1-r.czerwinski@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231206131336.3099727-1-r.czerwinski@pengutronix.de> References: <20231206131336.3099727-1-r.czerwinski@pengutronix.de> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: rcz@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-wireless@vger.kernel.org Fix the undefined usage of the GPIO consumer API after retrieving the GPIO description with GPIO_ASIS. The API documentation mentions that GPIO_ASIS won't set a GPIO direction and requires the user to set a direction before using the GPIO. This can be confirmed on i.MX6 hardware, where rfkill-gpio is no longer able to enabled/disable a device, presumably because the GPIO controller was never configured for the output direction. Fixes: b2f750c3a80b ("net: rfkill: gpio: prevent value glitch during probe") Cc: stable@vger.kernel.org Signed-off-by: Rouven Czerwinski Reviewed-by: Simon Horman --- v2: - remove the if clauses, the gpiod_direction_* functions can handle NULL gpio descriptors. net/rfkill/rfkill-gpio.c | 8 ++++++++ 1 file changed, 8 insertions(+) base-commit: 994d5c58e50e91bb02c7be4a91d5186292a895c8 diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c index 5a81505fba9ac..4e32d659524e0 100644 --- a/net/rfkill/rfkill-gpio.c +++ b/net/rfkill/rfkill-gpio.c @@ -126,6 +126,14 @@ static int rfkill_gpio_probe(struct platform_device *pdev) return -EINVAL; } + ret = gpiod_direction_output(rfkill->reset_gpio, true); + if (ret) + return ret; + + ret = gpiod_direction_output(rfkill->shutdown_gpio, true); + if (ret) + return ret; + rfkill->rfkill_dev = rfkill_alloc(rfkill->name, &pdev->dev, rfkill->type, &rfkill_gpio_ops, rfkill);