Skip to content

Commit d64c732

Browse files
pH5jmberg-intel
authored andcommitted
net: rfkill: gpio: add DT support
Allow probing rfkill-gpio via device tree. This hooks up the already existing support that was started in commit 262c91e ("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 <p.zabel@pengutronix.de> Link: https://lore.kernel.org/r/20230102-rfkill-gpio-dt-v2-2-d1b83758c16d@pengutronix.de Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 50071fd commit d64c732

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

net/rfkill/rfkill-gpio.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,24 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
7575
{
7676
struct rfkill_gpio_data *rfkill;
7777
struct gpio_desc *gpio;
78+
const char *name_property;
79+
const char *type_property;
7880
const char *type_name;
7981
int ret;
8082

8183
rfkill = devm_kzalloc(&pdev->dev, sizeof(*rfkill), GFP_KERNEL);
8284
if (!rfkill)
8385
return -ENOMEM;
8486

85-
device_property_read_string(&pdev->dev, "name", &rfkill->name);
86-
device_property_read_string(&pdev->dev, "type", &type_name);
87+
if (dev_of_node(&pdev->dev)) {
88+
name_property = "label";
89+
type_property = "radio-type";
90+
} else {
91+
name_property = "name";
92+
type_property = "type";
93+
}
94+
device_property_read_string(&pdev->dev, name_property, &rfkill->name);
95+
device_property_read_string(&pdev->dev, type_property, &type_name);
8796

8897
if (!rfkill->name)
8998
rfkill->name = dev_name(&pdev->dev);
@@ -157,12 +166,19 @@ static const struct acpi_device_id rfkill_acpi_match[] = {
157166
MODULE_DEVICE_TABLE(acpi, rfkill_acpi_match);
158167
#endif
159168

169+
static const struct of_device_id rfkill_of_match[] __maybe_unused = {
170+
{ .compatible = "rfkill-gpio", },
171+
{ },
172+
};
173+
MODULE_DEVICE_TABLE(of, rfkill_of_match);
174+
160175
static struct platform_driver rfkill_gpio_driver = {
161176
.probe = rfkill_gpio_probe,
162177
.remove = rfkill_gpio_remove,
163178
.driver = {
164179
.name = "rfkill_gpio",
165180
.acpi_match_table = ACPI_PTR(rfkill_acpi_match),
181+
.of_match_table = of_match_ptr(rfkill_of_match),
166182
},
167183
};
168184

0 commit comments

Comments
 (0)