Skip to content

Commit f35f06b

Browse files
brglLee Jones
authored andcommitted
backlight: gpio: Simplify the platform data handling
Now that the last user of platform data (sh ecovec24) defines a proper GPIO lookup and sets the 'default-on' device property, we can drop the platform_data-specific GPIO handling and unify a big chunk of code. The only field used from the platform data is now the fbdev pointer. Signed-off-by: Bartosz Golaszewski <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Reviewed-by: Daniel Thompson <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Lee Jones <[email protected]>
1 parent d9e2b6e commit f35f06b

File tree

1 file changed

+11
-51
lines changed

1 file changed

+11
-51
lines changed

drivers/video/backlight/gpio_backlight.c

Lines changed: 11 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <linux/backlight.h>
77
#include <linux/err.h>
88
#include <linux/fb.h>
9-
#include <linux/gpio.h> /* Only for legacy support */
109
#include <linux/gpio/consumer.h>
1110
#include <linux/init.h>
1211
#include <linux/kernel.h>
@@ -61,28 +60,6 @@ static const struct backlight_ops gpio_backlight_ops = {
6160
.check_fb = gpio_backlight_check_fb,
6261
};
6362

64-
static int gpio_backlight_probe_dt(struct platform_device *pdev,
65-
struct gpio_backlight *gbl)
66-
{
67-
struct device *dev = &pdev->dev;
68-
int ret;
69-
70-
gbl->def_value = device_property_read_bool(dev, "default-on");
71-
72-
gbl->gpiod = devm_gpiod_get(dev, NULL, GPIOD_ASIS);
73-
if (IS_ERR(gbl->gpiod)) {
74-
ret = PTR_ERR(gbl->gpiod);
75-
76-
if (ret != -EPROBE_DEFER) {
77-
dev_err(dev,
78-
"Error: The gpios parameter is missing or invalid.\n");
79-
}
80-
return ret;
81-
}
82-
83-
return 0;
84-
}
85-
8663
static int gpio_backlight_initial_power_state(struct gpio_backlight *gbl)
8764
{
8865
struct device_node *node = gbl->dev->of_node;
@@ -114,35 +91,18 @@ static int gpio_backlight_probe(struct platform_device *pdev)
11491

11592
gbl->dev = &pdev->dev;
11693

117-
if (pdev->dev.fwnode) {
118-
ret = gpio_backlight_probe_dt(pdev, gbl);
119-
if (ret)
120-
return ret;
121-
} else if (pdata) {
122-
/*
123-
* Legacy platform data GPIO retrieveal. Do not expand
124-
* the use of this code path, currently only used by one
125-
* SH board.
126-
*/
127-
unsigned long flags = GPIOF_DIR_OUT;
128-
94+
if (pdata)
12995
gbl->fbdev = pdata->fbdev;
130-
gbl->def_value = pdata->def_value;
131-
flags |= gbl->def_value ? GPIOF_INIT_HIGH : GPIOF_INIT_LOW;
132-
133-
ret = devm_gpio_request_one(gbl->dev, pdata->gpio, flags,
134-
pdata ? pdata->name : "backlight");
135-
if (ret < 0) {
136-
dev_err(&pdev->dev, "unable to request GPIO\n");
137-
return ret;
138-
}
139-
gbl->gpiod = gpio_to_desc(pdata->gpio);
140-
if (!gbl->gpiod)
141-
return -EINVAL;
142-
} else {
143-
dev_err(&pdev->dev,
144-
"failed to find platform data or device tree node.\n");
145-
return -ENODEV;
96+
97+
gbl->def_value = device_property_read_bool(&pdev->dev, "default-on");
98+
99+
gbl->gpiod = devm_gpiod_get(&pdev->dev, NULL, GPIOD_ASIS);
100+
if (IS_ERR(gbl->gpiod)) {
101+
ret = PTR_ERR(gbl->gpiod);
102+
if (ret != -EPROBE_DEFER)
103+
dev_err(&pdev->dev,
104+
"Error: The gpios parameter is missing or invalid.\n");
105+
return ret;
146106
}
147107

148108
memset(&props, 0, sizeof(props));

0 commit comments

Comments
 (0)