[PATCH] video: backlight: fix the value of 'brightness_max'

Sascha Hauer s.hauer at pengutronix.de
Mon Aug 29 08:36:55 PDT 2016


Fixes: 87c6a88 video/backlight-pwm: fix the value of 'brightness_max'.

brightness_max should really contain the number of brightness steps, so
the number of elements in the brightness array.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/video/backlight-pwm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/video/backlight-pwm.c b/drivers/video/backlight-pwm.c
index 7f1715d..2915dba 100644
--- a/drivers/video/backlight-pwm.c
+++ b/drivers/video/backlight-pwm.c
@@ -156,6 +156,8 @@ static int pwm_backlight_parse_dt(struct device_d *dev,
 		if (ret < 0)
 			return ret;
 
+		pwm_backlight->backlight.brightness_max = length - 1;
+
 		for (i = 0; i < length; i++)
 			if (pwm_backlight->levels[i] > pwm_backlight->scale)
 				pwm_backlight->scale = pwm_backlight->levels[i];
@@ -165,8 +167,8 @@ static int pwm_backlight_parse_dt(struct device_d *dev,
 	} else {
 		/* We implicitly assume here a linear levels array { 0, 1, 2, ... 100 } */
 		pwm_backlight->scale = 100;
+		pwm_backlight->backlight.brightness_max = pwm_backlight->scale;
 	}
-	pwm_backlight->backlight.brightness_max = pwm_backlight->scale;
 
 	pwm_backlight->enable_gpio = of_get_named_gpio_flags(node, "enable-gpios", 0, &flags);
 
-- 
2.8.1




More information about the barebox mailing list