Message ID | 20231207075835.3091694-1-r.czerwinski@pengutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4618530vqy; Wed, 6 Dec 2023 23:59:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IGp4mxMIMPb0st+xwwMU0UgwV3qPc6S9SPMGqCCTBpNM25fG1hk9UBemkSbD3scy6Q5cb1R X-Received: by 2002:a17:902:7004:b0:1d0:4c09:7d31 with SMTP id y4-20020a170902700400b001d04c097d31mr1999199plk.65.1701935955438; Wed, 06 Dec 2023 23:59:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701935955; cv=none; d=google.com; s=arc-20160816; b=uCJq8wauJ9cvDOZIy++tFd+cJFCgezk8bErgEmoHFpGm+lBHtqFWvPi5u8jQ7RVqt0 KkAvhriEqy4JwglXz1SwuxjyuhJsOXiv9uJTuOEEwd/49833Nz0OIoiRFWC/G4aL6E8W p8mN29QB7BCJ/+8vL8LARp5jax0ddDGtfLUol5564Jmj6Ni3rqxzKKuxrKpJoL51Z0+p aYNGEvWqG9s89YvE5LCdvkLgUXBlJhbYaeCJmgreKHzKCMje9Y2+hhZxJ/7IuHYoa/qX rcx4vqjeFYyW+HTKrZVoQkGx/5IKVagLV9dDV2opUj9zmdbRCXAqo5GRafiUnobll+Jp o8VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=PD3HPsXbMpNvWmGcN03QUeNavu7XzJ0mobag/cOQb8Q=; fh=vyyh1ZCJj39iLlPzyJsCy9G3/eYXDPriHsE8TX/rDmY=; b=MGHMp7d6Y6NY9lUp2QQHnJJ4bCntCAGaN9/jjI/25bxZZswfdidRelWa8y2bf5gc+y bNMWP6q3k9TtwfoXkhriks1IiBPsAM8JtJiVWqgRssm03tzR6HXBBa+Um59Al43R5RNM RlqG6+odxEwi1L88L0q1pobGJrWybVGuT5Qu0gQHzJ0BwOyS28bhHjD9o3NDC8ogiwIC jfftxaJRp1X4SVr7b0LADmZqWdhZlTSA3Y32Ek7ls3BCpCbNFVph8QdjGGBAE1YBjiTx D17thciKZSpEG89ViPo7/p3RTopJms5zHaP7oKmJ5kIBumeIkMdHIEEPI2e9UbYW+AwY YFhg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id h4-20020a170902748400b001cfcc0ca762si700739pll.108.2023.12.06.23.59.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 23:59:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 5F14681FEC55; Wed, 6 Dec 2023 23:59:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229809AbjLGH7C (ORCPT <rfc822;pusanteemu@gmail.com> + 99 others); Thu, 7 Dec 2023 02:59:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231218AbjLGH66 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 7 Dec 2023 02:58:58 -0500 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 D7724DD for <linux-kernel@vger.kernel.org>; Wed, 6 Dec 2023 23:59:04 -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 <rcz@pengutronix.de>) 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 <rcz@pengutronix.de>) 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 <rcz@pengutronix.de>) id 1rB9Ha-00CyIz-0I; Thu, 07 Dec 2023 08:58:54 +0100 From: Rouven Czerwinski <r.czerwinski@pengutronix.de> To: Johannes Berg <johannes.berg@intel.com>, Josua Mayer <josua@solid-run.com>, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: pza@pengutronix.de, Rouven Czerwinski <r.czerwinski@pengutronix.de>, stable@vger.kernel.org, Johannes Berg <johannes@sipsolutions.net>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> 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> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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-kernel@vger.kernel.org X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 23:59:11 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784538405744681608 X-GMAIL-MSGID: 1784609195921332181 |
Series |
[v2] net: rfkill: gpio: set GPIO direction
|
|
Commit Message
Rouven Czerwinski
Dec. 7, 2023, 7:58 a.m. UTC
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 <r.czerwinski@pengutronix.de>
---
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
Comments
On Thu, Dec 07, 2023 at 08:58:36AM +0100, Rouven Czerwinski wrote: > 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 <r.czerwinski@pengutronix.de> Reviewed-by: Simon Horman <horms@kernel.org>
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);