Merge tag 'for-3.9-rc1' of git://gitorious.org/linux-pwm/linux-pwm
[~shefty/rdma-dev.git] / drivers / video / backlight / pwm_bl.c
index f2f4c43..fa00304 100644 (file)
@@ -41,10 +41,9 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
        int brightness = bl->props.brightness;
        int max = bl->props.max_brightness;
 
-       if (bl->props.power != FB_BLANK_UNBLANK)
-               brightness = 0;
-
-       if (bl->props.fb_blank != FB_BLANK_UNBLANK)
+       if (bl->props.power != FB_BLANK_UNBLANK ||
+           bl->props.fb_blank != FB_BLANK_UNBLANK ||
+           bl->props.state & BL_CORE_FBBLANK)
                brightness = 0;
 
        if (pb->notify)
@@ -135,12 +134,6 @@ static int pwm_backlight_parse_dt(struct device *dev,
                if (ret < 0)
                        return ret;
 
-               if (value >= data->max_brightness) {
-                       dev_warn(dev, "invalid default brightness level: %u, using %u\n",
-                                value, data->max_brightness - 1);
-                       value = data->max_brightness - 1;
-               }
-
                data->dft_brightness = value;
                data->max_brightness--;
        }
@@ -249,6 +242,13 @@ static int pwm_backlight_probe(struct platform_device *pdev)
                goto err_alloc;
        }
 
+       if (data->dft_brightness > data->max_brightness) {
+               dev_warn(&pdev->dev,
+                        "invalid default brightness level: %u, using %u\n",
+                        data->dft_brightness, data->max_brightness);
+               data->dft_brightness = data->max_brightness;
+       }
+
        bl->props.brightness = data->dft_brightness;
        backlight_update_status(bl);