Skip to content

Commit 9ccec4f

Browse files
pH5gregkh
authored andcommitted
net: rfkill: gpio: add DT support
[ Upstream commit d64c732 ] 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> Stable-dep-of: b6f56a4 ("net: rfkill: gpio: Fix crash due to dereferencering uninitialized pointer") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ff16050 commit 9ccec4f

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
@@ -79,15 +79,24 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
7979
{
8080
struct rfkill_gpio_data *rfkill;
8181
struct gpio_desc *gpio;
82+
const char *name_property;
83+
const char *type_property;
8284
const char *type_name;
8385
int ret;
8486

8587
rfkill = devm_kzalloc(&pdev->dev, sizeof(*rfkill), GFP_KERNEL);
8688
if (!rfkill)
8789
return -ENOMEM;
8890

89-
device_property_read_string(&pdev->dev, "name", &rfkill->name);
90-
device_property_read_string(&pdev->dev, "type", &type_name);
91+
if (dev_of_node(&pdev->dev)) {
92+
name_property = "label";
93+
type_property = "radio-type";
94+
} else {
95+
name_property = "name";
96+
type_property = "type";
97+
}
98+
device_property_read_string(&pdev->dev, name_property, &rfkill->name);
99+
device_property_read_string(&pdev->dev, type_property, &type_name);
91100

92101
if (!rfkill->name)
93102
rfkill->name = dev_name(&pdev->dev);
@@ -169,12 +178,19 @@ static const struct acpi_device_id rfkill_acpi_match[] = {
169178
MODULE_DEVICE_TABLE(acpi, rfkill_acpi_match);
170179
#endif
171180

181+
static const struct of_device_id rfkill_of_match[] __maybe_unused = {
182+
{ .compatible = "rfkill-gpio", },
183+
{ },
184+
};
185+
MODULE_DEVICE_TABLE(of, rfkill_of_match);
186+
172187
static struct platform_driver rfkill_gpio_driver = {
173188
.probe = rfkill_gpio_probe,
174189
.remove = rfkill_gpio_remove,
175190
.driver = {
176191
.name = "rfkill_gpio",
177192
.acpi_match_table = ACPI_PTR(rfkill_acpi_match),
193+
.of_match_table = of_match_ptr(rfkill_of_match),
178194
},
179195
};
180196

0 commit comments

Comments
 (0)