Commit 98b7404e authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Lee Jones

backlight: gpio_backlight: Enable ACPI enumeration

ACPI allows to enumerate specific devices by using compatible strings.
Enable that enumeration for GPIO based backlight devices.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent 5076fbed
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/of_gpio.h> #include <linux/of_gpio.h>
#include <linux/platform_data/gpio_backlight.h> #include <linux/platform_data/gpio_backlight.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/slab.h> #include <linux/slab.h>
struct gpio_backlight { struct gpio_backlight {
...@@ -61,11 +62,10 @@ static int gpio_backlight_probe_dt(struct platform_device *pdev, ...@@ -61,11 +62,10 @@ static int gpio_backlight_probe_dt(struct platform_device *pdev,
struct gpio_backlight *gbl) struct gpio_backlight *gbl)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
enum gpiod_flags flags; enum gpiod_flags flags;
int ret; int ret;
gbl->def_value = of_property_read_bool(np, "default-on"); gbl->def_value = device_property_read_bool(dev, "default-on");
flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
gbl->gpiod = devm_gpiod_get(dev, NULL, flags); gbl->gpiod = devm_gpiod_get(dev, NULL, flags);
...@@ -89,26 +89,19 @@ static int gpio_backlight_probe(struct platform_device *pdev) ...@@ -89,26 +89,19 @@ static int gpio_backlight_probe(struct platform_device *pdev)
struct backlight_properties props; struct backlight_properties props;
struct backlight_device *bl; struct backlight_device *bl;
struct gpio_backlight *gbl; struct gpio_backlight *gbl;
struct device_node *np = pdev->dev.of_node;
int ret; int ret;
if (!pdata && !np) {
dev_err(&pdev->dev,
"failed to find platform data or device tree node.\n");
return -ENODEV;
}
gbl = devm_kzalloc(&pdev->dev, sizeof(*gbl), GFP_KERNEL); gbl = devm_kzalloc(&pdev->dev, sizeof(*gbl), GFP_KERNEL);
if (gbl == NULL) if (gbl == NULL)
return -ENOMEM; return -ENOMEM;
gbl->dev = &pdev->dev; gbl->dev = &pdev->dev;
if (np) { if (pdev->dev.fwnode) {
ret = gpio_backlight_probe_dt(pdev, gbl); ret = gpio_backlight_probe_dt(pdev, gbl);
if (ret) if (ret)
return ret; return ret;
} else { } else if (pdata) {
/* /*
* Legacy platform data GPIO retrieveal. Do not expand * Legacy platform data GPIO retrieveal. Do not expand
* the use of this code path, currently only used by one * the use of this code path, currently only used by one
...@@ -129,6 +122,10 @@ static int gpio_backlight_probe(struct platform_device *pdev) ...@@ -129,6 +122,10 @@ static int gpio_backlight_probe(struct platform_device *pdev)
gbl->gpiod = gpio_to_desc(pdata->gpio); gbl->gpiod = gpio_to_desc(pdata->gpio);
if (!gbl->gpiod) if (!gbl->gpiod)
return -EINVAL; return -EINVAL;
} else {
dev_err(&pdev->dev,
"failed to find platform data or device tree node.\n");
return -ENODEV;
} }
memset(&props, 0, sizeof(props)); memset(&props, 0, sizeof(props));
...@@ -149,19 +146,17 @@ static int gpio_backlight_probe(struct platform_device *pdev) ...@@ -149,19 +146,17 @@ static int gpio_backlight_probe(struct platform_device *pdev)
return 0; return 0;
} }
#ifdef CONFIG_OF
static struct of_device_id gpio_backlight_of_match[] = { static struct of_device_id gpio_backlight_of_match[] = {
{ .compatible = "gpio-backlight" }, { .compatible = "gpio-backlight" },
{ /* sentinel */ } { /* sentinel */ }
}; };
MODULE_DEVICE_TABLE(of, gpio_backlight_of_match); MODULE_DEVICE_TABLE(of, gpio_backlight_of_match);
#endif
static struct platform_driver gpio_backlight_driver = { static struct platform_driver gpio_backlight_driver = {
.driver = { .driver = {
.name = "gpio-backlight", .name = "gpio-backlight",
.of_match_table = of_match_ptr(gpio_backlight_of_match), .of_match_table = gpio_backlight_of_match,
}, },
.probe = gpio_backlight_probe, .probe = gpio_backlight_probe,
}; };
......
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