aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2019-06-19 11:21:27 -0400
committerLee Jones <lee.jones@linaro.org>2019-06-27 02:09:05 -0400
commit98b7404eb7d64e55f8fdd419cb3965a8abf0e217 (patch)
tree563598f5cf24beb26085da993ef35cd16ad36cb7 /drivers/video
parent5076fbed57f7f58c839e7ea5a2495c1d083417ae (diff)
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: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Daniel Thompson <daniel.thompson@linaro.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/backlight/gpio_backlight.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c
index e470da95d806..05c12df62b27 100644
--- a/drivers/video/backlight/gpio_backlight.c
+++ b/drivers/video/backlight/gpio_backlight.c
@@ -18,6 +18,7 @@
18#include <linux/of_gpio.h> 18#include <linux/of_gpio.h>
19#include <linux/platform_data/gpio_backlight.h> 19#include <linux/platform_data/gpio_backlight.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/property.h>
21#include <linux/slab.h> 22#include <linux/slab.h>
22 23
23struct gpio_backlight { 24struct gpio_backlight {
@@ -61,11 +62,10 @@ static int gpio_backlight_probe_dt(struct platform_device *pdev,
61 struct gpio_backlight *gbl) 62 struct gpio_backlight *gbl)
62{ 63{
63 struct device *dev = &pdev->dev; 64 struct device *dev = &pdev->dev;
64 struct device_node *np = dev->of_node;
65 enum gpiod_flags flags; 65 enum gpiod_flags flags;
66 int ret; 66 int ret;
67 67
68 gbl->def_value = of_property_read_bool(np, "default-on"); 68 gbl->def_value = device_property_read_bool(dev, "default-on");
69 flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; 69 flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
70 70
71 gbl->gpiod = devm_gpiod_get(dev, NULL, flags); 71 gbl->gpiod = devm_gpiod_get(dev, NULL, flags);
@@ -89,26 +89,19 @@ static int gpio_backlight_probe(struct platform_device *pdev)
89 struct backlight_properties props; 89 struct backlight_properties props;
90 struct backlight_device *bl; 90 struct backlight_device *bl;
91 struct gpio_backlight *gbl; 91 struct gpio_backlight *gbl;
92 struct device_node *np = pdev->dev.of_node;
93 int ret; 92 int ret;
94 93
95 if (!pdata && !np) {
96 dev_err(&pdev->dev,
97 "failed to find platform data or device tree node.\n");
98 return -ENODEV;
99 }
100
101 gbl = devm_kzalloc(&pdev->dev, sizeof(*gbl), GFP_KERNEL); 94 gbl = devm_kzalloc(&pdev->dev, sizeof(*gbl), GFP_KERNEL);
102 if (gbl == NULL) 95 if (gbl == NULL)
103 return -ENOMEM; 96 return -ENOMEM;
104 97
105 gbl->dev = &pdev->dev; 98 gbl->dev = &pdev->dev;
106 99
107 if (np) { 100 if (pdev->dev.fwnode) {
108 ret = gpio_backlight_probe_dt(pdev, gbl); 101 ret = gpio_backlight_probe_dt(pdev, gbl);
109 if (ret) 102 if (ret)
110 return ret; 103 return ret;
111 } else { 104 } else if (pdata) {
112 /* 105 /*
113 * Legacy platform data GPIO retrieveal. Do not expand 106 * Legacy platform data GPIO retrieveal. Do not expand
114 * the use of this code path, currently only used by one 107 * 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 gbl->gpiod = gpio_to_desc(pdata->gpio); 122 gbl->gpiod = gpio_to_desc(pdata->gpio);
130 if (!gbl->gpiod) 123 if (!gbl->gpiod)
131 return -EINVAL; 124 return -EINVAL;
125 } else {
126 dev_err(&pdev->dev,
127 "failed to find platform data or device tree node.\n");
128 return -ENODEV;
132 } 129 }
133 130
134 memset(&props, 0, sizeof(props)); 131 memset(&props, 0, sizeof(props));
@@ -149,19 +146,17 @@ static int gpio_backlight_probe(struct platform_device *pdev)
149 return 0; 146 return 0;
150} 147}
151 148
152#ifdef CONFIG_OF
153static struct of_device_id gpio_backlight_of_match[] = { 149static struct of_device_id gpio_backlight_of_match[] = {
154 { .compatible = "gpio-backlight" }, 150 { .compatible = "gpio-backlight" },
155 { /* sentinel */ } 151 { /* sentinel */ }
156}; 152};
157 153
158MODULE_DEVICE_TABLE(of, gpio_backlight_of_match); 154MODULE_DEVICE_TABLE(of, gpio_backlight_of_match);
159#endif
160 155
161static struct platform_driver gpio_backlight_driver = { 156static struct platform_driver gpio_backlight_driver = {
162 .driver = { 157 .driver = {
163 .name = "gpio-backlight", 158 .name = "gpio-backlight",
164 .of_match_table = of_match_ptr(gpio_backlight_of_match), 159 .of_match_table = gpio_backlight_of_match,
165 }, 160 },
166 .probe = gpio_backlight_probe, 161 .probe = gpio_backlight_probe,
167}; 162};