These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / video / backlight / pwm_bl.c
index 6897f1c..ae3c6b6 100644 (file)
@@ -241,7 +241,8 @@ static int pwm_backlight_probe(struct platform_device *pdev)
        pb->dev = &pdev->dev;
        pb->enabled = false;
 
-       pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable");
+       pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
+                                                 GPIOD_OUT_HIGH);
        if (IS_ERR(pb->enable_gpio)) {
                ret = PTR_ERR(pb->enable_gpio);
                goto err_alloc;
@@ -263,9 +264,6 @@ static int pwm_backlight_probe(struct platform_device *pdev)
                pb->enable_gpio = gpio_to_desc(data->enable_gpio);
        }
 
-       if (pb->enable_gpio)
-               gpiod_direction_output(pb->enable_gpio, 1);
-
        pb->power_supply = devm_regulator_get(&pdev->dev, "power");
        if (IS_ERR(pb->power_supply)) {
                ret = PTR_ERR(pb->power_supply);
@@ -273,19 +271,18 @@ static int pwm_backlight_probe(struct platform_device *pdev)
        }
 
        pb->pwm = devm_pwm_get(&pdev->dev, NULL);
-       if (IS_ERR(pb->pwm)) {
-               ret = PTR_ERR(pb->pwm);
-               if (ret == -EPROBE_DEFER)
-                       goto err_alloc;
-
+       if (IS_ERR(pb->pwm) && PTR_ERR(pb->pwm) != -EPROBE_DEFER
+           && !pdev->dev.of_node) {
                dev_err(&pdev->dev, "unable to request PWM, trying legacy API\n");
                pb->legacy = true;
                pb->pwm = pwm_request(data->pwm_id, "pwm-backlight");
-               if (IS_ERR(pb->pwm)) {
-                       dev_err(&pdev->dev, "unable to request legacy PWM\n");
-                       ret = PTR_ERR(pb->pwm);
-                       goto err_alloc;
-               }
+       }
+
+       if (IS_ERR(pb->pwm)) {
+               ret = PTR_ERR(pb->pwm);
+               if (ret != -EPROBE_DEFER)
+                       dev_err(&pdev->dev, "unable to request PWM\n");
+               goto err_alloc;
        }
 
        dev_dbg(&pdev->dev, "got pwm for backlight\n");