Skip to content

Commit

Permalink
backlight: pwm_bl: Fix devicetree parsing with auto-generated brightn…
Browse files Browse the repository at this point in the history
…ess tables

Commit 88ba95b ("backlight: pwm_bl: Compute brightness of LED linearly
to human eye") made the parse-dt function return early when using an auto-
generated brightness-table, but didn't take into account that some more
settings were handled below the brightness handling, like power-on-delays
and also setting the pdata enable-gpio to -EINVAL.

This surfaces for example in the case of a backlight without any
enable-gpio which then tries to use gpio-0 in error.

Fix this by simply moving the trailing settings above the brightness
handling.

Fixes: 88ba95b ("backlight: pwm_bl: Compute brightness of LED linearly to human eye")
Signed-off-by: Heiko Stuebner <heiko.stuebner@bq.com>
Acked-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
  • Loading branch information
Heiko Stuebner authored and Lee Jones committed Nov 27, 2018
1 parent e4c8ae3 commit 61170ee
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions drivers/video/backlight/pwm_bl.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@ static int pwm_backlight_parse_dt(struct device *dev,

memset(data, 0, sizeof(*data));

/*
* These values are optional and set as 0 by default, the out values
* are modified only if a valid u32 value can be decoded.
*/
of_property_read_u32(node, "post-pwm-on-delay-ms",
&data->post_pwm_on_delay);
of_property_read_u32(node, "pwm-off-delay-ms", &data->pwm_off_delay);

data->enable_gpio = -EINVAL;

/*
* Determine the number of brightness levels, if this property is not
* set a default table of brightness levels will be used.
Expand Down Expand Up @@ -384,15 +394,6 @@ static int pwm_backlight_parse_dt(struct device *dev,
data->max_brightness--;
}

/*
* These values are optional and set as 0 by default, the out values
* are modified only if a valid u32 value can be decoded.
*/
of_property_read_u32(node, "post-pwm-on-delay-ms",
&data->post_pwm_on_delay);
of_property_read_u32(node, "pwm-off-delay-ms", &data->pwm_off_delay);

data->enable_gpio = -EINVAL;
return 0;
}

Expand Down

0 comments on commit 61170ee

Please sign in to comment.