net: rfkill: gpio: enable devicetree binding for rfkill-gpio

https://patchwork.kernel.org/patch/3989371/Signed-off-by: default avatarAngus Ainslie (Purism) <angus@akkea.ca>
parent ca10d956
Pipeline #35074 passed with stage
in 25 minutes and 9 seconds
......@@ -13,6 +13,7 @@
#include <linux/slab.h>
#include <linux/acpi.h>
#include <linux/gpio/consumer.h>
#include <linux/of_gpio.h>
struct rfkill_gpio_data {
const char *name;
......@@ -71,6 +72,18 @@ static int rfkill_gpio_acpi_probe(struct device *dev,
return devm_acpi_dev_add_driver_gpios(dev, acpi_rfkill_default_gpios);
}
static int rfkill_gpio_dt_probe(struct device *dev,
struct rfkill_gpio_data *rfkill)
{
struct device_node * np = dev->of_node;
rfkill->name = np->name;
of_property_read_string(np, "rfkill-name", &rfkill->name);
of_property_read_u32(np, "rfkill-type", &rfkill->type);
return 0;
}
static int rfkill_gpio_probe(struct platform_device *pdev)
{
struct rfkill_gpio_data *rfkill;
......@@ -94,6 +107,10 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
ret = rfkill_gpio_acpi_probe(&pdev->dev, rfkill);
if (ret)
return ret;
} else if (&pdev->dev.of_node) {
ret = rfkill_gpio_dt_probe(&pdev->dev, rfkill);
if (ret)
return ret;
}
rfkill->clk = devm_clk_get(&pdev->dev, NULL);
......@@ -148,6 +165,11 @@ static int rfkill_gpio_remove(struct platform_device *pdev)
return 0;
}
static const struct of_device_id rfkill_of_match[] = {
{ .compatible = "rfkill-gpio", },
{},
};
#ifdef CONFIG_ACPI
static const struct acpi_device_id rfkill_acpi_match[] = {
{ "BCM4752", RFKILL_TYPE_GPS },
......@@ -163,6 +185,7 @@ static struct platform_driver rfkill_gpio_driver = {
.driver = {
.name = "rfkill_gpio",
.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