From patchwork Wed Dec 6 13:13:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rouven Czerwinski X-Patchwork-Id: 174572 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4094684vqy; Wed, 6 Dec 2023 05:14:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IE8K9MOZwYKre/fzEDmf6OXGpNCzIAoo3cvuuyvWOGBzXpHErPpqDXY3mExcXESrIO/4yh4 X-Received: by 2002:a17:90b:384d:b0:288:67f6:2cf2 with SMTP id nl13-20020a17090b384d00b0028867f62cf2mr509043pjb.19.1701868444312; Wed, 06 Dec 2023 05:14:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701868444; cv=none; d=google.com; s=arc-20160816; b=c2SF0K4BPA3gPXw7ByAvDbGoczxUtkYWxokrT0ASirZ2Vpzrk50XQOVSIGoJ4hGgEz SRPFVeQWm+4WE3LbYTA8o6t9OmdhMwd91PaikdEZwGKfgDz9vFNLTQNGx780DtHjUJLb HQOyUBBmIaBQDP+A92tbISXXRDDcfB3frj6ykYetRPxd+a5AVK35nrDv0yQDHL7ten5p tUtqqb3QhIz+0RYCsnTl52IZ9VimMYB7eKxuDgVfg3gN+mH5AXx1SSrgKWXn5wmcYU8K Bk5pHM+GShk8KF0XD9tCFmMRtERmRPwrttY+aw8grI4Xi7VqhuuNWqSPFm+BW9ZqDodC mBTg== 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 :message-id:date:subject:cc:to:from; bh=K23DuCWgsXDvwZDOSUrEHVYJoBnpk2dj1aZqpumcPD4=; fh=fQ+/VrkWe4z8y7xbwtkgzLrdKvh28T4DgaUt22Pngo8=; b=hBZhUn785lPFUbKt7qM49qYqPEZUJ3mw8RZgCVAJBM766Adh6AJoh08bTE56oH/TMV nvE3foppZGTDWtP6/ENrS9z81hKHvHHsIOypIFJHiS8cOQl06JvdO6ZmVgytWOqEUCHW sKkXgBaSz/FZeOHs/VZ7aINwfmvth3Gx3KpyBbeUxWSdcxoa/fBjWBU5UCDDKZ74Ixki Juq5IcE8UqKO0G1mlWcco1LAJ7RrlUlkgAkdDoVWdq+wJNlj1nTg+vBA5bEpIWXEu60k CIV1NyS8HasaRlHfkykBB/ak9K18G8cOagQ4Eg03V7ODw1O8Wiu2V9xKwWys3oXVKOk5 zbSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id a19-20020a17090ad81300b00286f67f01b4si831232pjv.184.2023.12.06.05.14.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 05:14:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 7808A80C6EB8; Wed, 6 Dec 2023 05:13:56 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378416AbjLFNNr (ORCPT + 99 others); Wed, 6 Dec 2023 08:13:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378432AbjLFNNq (ORCPT ); Wed, 6 Dec 2023 08:13:46 -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 CB6E6D47 for ; Wed, 6 Dec 2023 05:13:51 -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 1rArii-0001DV-2f; Wed, 06 Dec 2023 14:13:44 +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 1rArig-00DyO1-MO; Wed, 06 Dec 2023 14:13:42 +0100 Received: from rcz by dude05.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rArig-00D0Qc-20; Wed, 06 Dec 2023 14:13:42 +0100 From: Rouven Czerwinski To: Josua Mayer , Johannes Berg , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: kernel@pengutronix.de, Rouven Czerwinski , stable@vger.kernel.org, Johannes Berg , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH] net: rfkill: gpio: set GPIO direction Date: Wed, 6 Dec 2023 14:13:35 +0100 Message-Id: <20231206131336.3099727-1-r.czerwinski@pengutronix.de> X-Mailer: git-send-email 2.39.2 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-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 groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 06 Dec 2023 05:13:56 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784538405744681608 X-GMAIL-MSGID: 1784538405744681608 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 --- net/rfkill/rfkill-gpio.c | 10 ++++++++++ 1 file changed, 10 insertions(+) base-commit: 994d5c58e50e91bb02c7be4a91d5186292a895c8 diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c index 5a81505fba9ac..3d9ae696397cf 100644 --- a/net/rfkill/rfkill-gpio.c +++ b/net/rfkill/rfkill-gpio.c @@ -126,6 +126,16 @@ static int rfkill_gpio_probe(struct platform_device *pdev) return -EINVAL; } + if (rfkill->reset_gpio) + ret = gpiod_direction_output(rfkill->reset_gpio, true); + if (ret) + return ret; + + if (rfkill->shutdown_gpio) + 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);