Introduce use of DECLARE_BACKLIGHT_INIT_RAW when registering the
backlight. This makes the device registration a little simpler.

Use get/set operations for power thus avoid the use of the
rather confusion power states.

Signed-off-by: Sam Ravnborg <s...@ravnborg.org>
Cc: Lee Jones <lee.jo...@linaro.org>
Cc: Daniel Thompson <daniel.thomp...@linaro.org>
Cc: Jingoo Han <jingooh...@gmail.com>
---
 drivers/video/backlight/gpio_backlight.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/video/backlight/gpio_backlight.c 
b/drivers/video/backlight/gpio_backlight.c
index 6f78d928f054..c94fbfa755c4 100644
--- a/drivers/video/backlight/gpio_backlight.c
+++ b/drivers/video/backlight/gpio_backlight.c
@@ -49,7 +49,7 @@ static int gpio_backlight_probe(struct platform_device *pdev)
        struct device *dev = &pdev->dev;
        struct gpio_backlight_platform_data *pdata = dev_get_platdata(dev);
        struct device_node *of_node = dev->of_node;
-       struct backlight_properties props;
+       DECLARE_BACKLIGHT_INIT_RAW(props, 1, 1);
        struct backlight_device *bl;
        struct gpio_backlight *gbl;
        int ret, init_brightness, def_value;
@@ -72,9 +72,6 @@ static int gpio_backlight_probe(struct platform_device *pdev)
                return ret;
        }
 
-       memset(&props, 0, sizeof(props));
-       props.type = BACKLIGHT_RAW;
-       props.max_brightness = 1;
        bl = devm_backlight_device_register(dev, dev_name(dev), dev, gbl,
                                            &gpio_backlight_ops, &props);
        if (IS_ERR(bl)) {
@@ -85,15 +82,15 @@ static int gpio_backlight_probe(struct platform_device 
*pdev)
        /* Set the initial power state */
        if (!of_node || !of_node->phandle)
                /* Not booted with device tree or no phandle link to the node */
-               bl->props.power = def_value ? FB_BLANK_UNBLANK
-                                           : FB_BLANK_POWERDOWN;
+               if (def_value)
+                       backlight_set_power_on(bl);
+               else
+                       backlight_set_power_off(bl);
        else if (gpiod_get_direction(gbl->gpiod) == 0 &&
                 gpiod_get_value_cansleep(gbl->gpiod) == 0)
-               bl->props.power = FB_BLANK_POWERDOWN;
+               backlight_set_power_off(bl);
        else
-               bl->props.power = FB_BLANK_UNBLANK;
-
-       bl->props.brightness = 1;
+               backlight_set_power_on(bl);
 
        init_brightness = backlight_get_brightness(bl);
        ret = gpiod_direction_output(gbl->gpiod, init_brightness);
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to