Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp10872916rwl; Mon, 2 Jan 2023 09:31:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXv9oH/b6T1LRdyHc7HVX0H8YR9BwQsBdqjUEWtTDxkB45g23c06cfi2d9ZHUCoCi/5tL/c5 X-Received: by 2002:a17:902:e809:b0:189:890c:4f6f with SMTP id u9-20020a170902e80900b00189890c4f6fmr47958552plg.64.1672680678675; Mon, 02 Jan 2023 09:31:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672680678; cv=none; d=google.com; s=arc-20160816; b=HtFaOb7e+UP81a+YH1gNQmEK0WNk4EizpvwCCNIdLs9VOPDy50wgXt51/97E23F4Yl Pt5eUvK1N7N9V+ksKRWAl5P0HPPVy9Okv1Pa4upYGcnNY8vUVZQeZ+ran3YRlCz8kDzp S6oJOnsHx2xqzyMjS44GaaRW2+ymuzfcva4EbEOdQKgbjfLCTscmzbQMRzKHJOF9kAZK P6/ge9Rctv9lJmkc3ILJgeMmSXMqSmhoh92qTLGSZ/bS0xQ1Iq9xg6+S9yUM7W37eGav yJkJJtkvCFKY1JfjVNkRZJiq/S2VlO8ijqMrANrC0sjMKJ8PbdLWBQeij52nXCLdqWxj nKvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=A0OxgbpPz8DRyzrfjP7Khn3GKPIyZ9+12+t1auZta1k=; b=d4d6oXF50ynfmScC+S1UipQ3JALNZ1g8pO8dgjlpS4xfWrnQpvzaWE2GXmHpVPj8dM 5XeXqLlJMsWrHKY+8NnA+X6ahsPIIHM/kRec0uGJ9Opz4W/iluF73ut2bh6SpM/OxO/D XfDCljLqkEb/itN8r4Y2PZGoYpt3icKWpvx/Ezyr9BL/haDeGbOZqy3oiisR64RYjd08 LX1vynfjKeWZOHqb8siKo22J2ElwSBH6AM8VXukDZPyc4dYP1msnDVB/EV5f/wKGVqHd 4dynuvP+n4OcSupdxm6zKQFxzHR4IUhAs+/Npqj+7Kkeoe8nwMr8AcWNjN8wv5VEm/IC BpJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w7-20020a170902904700b00189812f489asi28256658plz.155.2023.01.02.09.31.04; Mon, 02 Jan 2023 09:31:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231653AbjABRad (ORCPT + 66 others); Mon, 2 Jan 2023 12:30:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236022AbjABRaL (ORCPT ); Mon, 2 Jan 2023 12:30:11 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1E6CAE7C for ; Mon, 2 Jan 2023 09:30:10 -0800 (PST) Received: from dude05.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::54]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1pCOdK-0003fo-3G; Mon, 02 Jan 2023 18:29:58 +0100 From: Philipp Zabel Date: Mon, 02 Jan 2023 18:29:34 +0100 Subject: [PATCH v2 2/2] net: rfkill: gpio: add DT support MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230102-rfkill-gpio-dt-v2-2-d1b83758c16d@pengutronix.de> References: <20230102-rfkill-gpio-dt-v2-0-d1b83758c16d@pengutronix.de> In-Reply-To: <20230102-rfkill-gpio-dt-v2-0-d1b83758c16d@pengutronix.de> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Johannes Berg Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, kernel@pengutronix.de, Philipp Zabel X-Mailer: b4 0.11.0-dev-e429b X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::54 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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-wireless@vger.kernel.org Allow probing rfkill-gpio via device tree. This hooks up the already existing support that was started in commit 262c91ee5e52 ("net: rfkill: gpio: prepare for DT and ACPI support") via the "rfkill-gpio" compatible, with the "name" and "type" properties renamed to "label" and "radio-type", respectively, in the device tree case. Signed-off-by: Philipp Zabel --- Changes since v1: - Use __maybe_unused instead of #ifdef CONFIG_OF (Krzysztof) - Support renamed "label" and "radio-type" property names --- net/rfkill/rfkill-gpio.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c index f5afc9bcdee6..786dbfdad772 100644 --- a/net/rfkill/rfkill-gpio.c +++ b/net/rfkill/rfkill-gpio.c @@ -75,6 +75,8 @@ static int rfkill_gpio_probe(struct platform_device *pdev) { struct rfkill_gpio_data *rfkill; struct gpio_desc *gpio; + const char *name_property; + const char *type_property; const char *type_name; int ret; @@ -82,8 +84,15 @@ static int rfkill_gpio_probe(struct platform_device *pdev) if (!rfkill) return -ENOMEM; - device_property_read_string(&pdev->dev, "name", &rfkill->name); - device_property_read_string(&pdev->dev, "type", &type_name); + if (dev_of_node(&pdev->dev)) { + name_property = "label"; + type_property = "radio-type"; + } else { + name_property = "name"; + type_property = "type"; + } + device_property_read_string(&pdev->dev, name_property, &rfkill->name); + device_property_read_string(&pdev->dev, type_property, &type_name); if (!rfkill->name) rfkill->name = dev_name(&pdev->dev); @@ -157,12 +166,19 @@ static const struct acpi_device_id rfkill_acpi_match[] = { MODULE_DEVICE_TABLE(acpi, rfkill_acpi_match); #endif +static const struct of_device_id rfkill_of_match[] __maybe_unused = { + { .compatible = "rfkill-gpio", }, + { }, +}; +MODULE_DEVICE_TABLE(of, rfkill_of_match); + static struct platform_driver rfkill_gpio_driver = { .probe = rfkill_gpio_probe, .remove = rfkill_gpio_remove, .driver = { .name = "rfkill_gpio", .acpi_match_table = ACPI_PTR(rfkill_acpi_match), + .of_match_table = of_match_ptr(rfkill_of_match), }, }; -- 2.30.2