Commit d64c732d authored by Philipp Zabel's avatar Philipp Zabel Committed by Johannes Berg

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 262c91ee ("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: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Link: https://lore.kernel.org/r/20230102-rfkill-gpio-dt-v2-2-d1b83758c16d@pengutronix.deSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 50071fdf
...@@ -75,6 +75,8 @@ static int rfkill_gpio_probe(struct platform_device *pdev) ...@@ -75,6 +75,8 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
{ {
struct rfkill_gpio_data *rfkill; struct rfkill_gpio_data *rfkill;
struct gpio_desc *gpio; struct gpio_desc *gpio;
const char *name_property;
const char *type_property;
const char *type_name; const char *type_name;
int ret; int ret;
...@@ -82,8 +84,15 @@ static int rfkill_gpio_probe(struct platform_device *pdev) ...@@ -82,8 +84,15 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
if (!rfkill) if (!rfkill)
return -ENOMEM; return -ENOMEM;
device_property_read_string(&pdev->dev, "name", &rfkill->name); if (dev_of_node(&pdev->dev)) {
device_property_read_string(&pdev->dev, "type", &type_name); 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) if (!rfkill->name)
rfkill->name = dev_name(&pdev->dev); rfkill->name = dev_name(&pdev->dev);
...@@ -157,12 +166,19 @@ static const struct acpi_device_id rfkill_acpi_match[] = { ...@@ -157,12 +166,19 @@ static const struct acpi_device_id rfkill_acpi_match[] = {
MODULE_DEVICE_TABLE(acpi, rfkill_acpi_match); MODULE_DEVICE_TABLE(acpi, rfkill_acpi_match);
#endif #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 = { static struct platform_driver rfkill_gpio_driver = {
.probe = rfkill_gpio_probe, .probe = rfkill_gpio_probe,
.remove = rfkill_gpio_remove, .remove = rfkill_gpio_remove,
.driver = { .driver = {
.name = "rfkill_gpio", .name = "rfkill_gpio",
.acpi_match_table = ACPI_PTR(rfkill_acpi_match), .acpi_match_table = ACPI_PTR(rfkill_acpi_match),
.of_match_table = of_match_ptr(rfkill_of_match),
}, },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment