Skip to content

Commit

Permalink
Merge tag 'backlight-next-4.21' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/lee/backlight

Pull backlight updates from Lee Jones:
 "Fix-ups:
   - Use new of_node_name_eq() API call

  Bug Fixes:
   - Internally track 'enabled' state in pwm_bl
   - Fix auto-generated pwm_bl brightness tables parsed by DT

* tag 'backlight-next-4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight:
  backlight: 88pm860x_bl: Use of_node_name_eq for node name comparisons
  backlight: pwm_bl: Fix devicetree parsing with auto-generated brightness tables
  backlight: pwm_bl: Re-add driver internal enabled tracking
  • Loading branch information
Linus Torvalds committed Jan 14, 2019
2 parents 1c7fc5c + 3cee7a7 commit 3a73e73
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion drivers/video/backlight/88pm860x_bl.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static int pm860x_backlight_dt_init(struct platform_device *pdev,
return -ENODEV;
}
for_each_child_of_node(nproot, np) {
if (!of_node_cmp(np->name, name)) {
if (of_node_name_eq(np, name)) {
of_property_read_u32(np, "marvell,88pm860x-iset",
&iset);
data->iset = PM8606_WLED_CURRENT(iset);
Expand Down
28 changes: 17 additions & 11 deletions drivers/video/backlight/pwm_bl.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct pwm_bl_data {
struct device *dev;
unsigned int lth_brightness;
unsigned int *levels;
bool enabled;
struct regulator *power_supply;
struct gpio_desc *enable_gpio;
unsigned int scale;
Expand All @@ -50,7 +51,7 @@ static void pwm_backlight_power_on(struct pwm_bl_data *pb)
int err;

pwm_get_state(pb->pwm, &state);
if (state.enabled)
if (pb->enabled)
return;

err = regulator_enable(pb->power_supply);
Expand All @@ -65,14 +66,16 @@ static void pwm_backlight_power_on(struct pwm_bl_data *pb)

if (pb->enable_gpio)
gpiod_set_value_cansleep(pb->enable_gpio, 1);

pb->enabled = true;
}

static void pwm_backlight_power_off(struct pwm_bl_data *pb)
{
struct pwm_state state;

pwm_get_state(pb->pwm, &state);
if (!state.enabled)
if (!pb->enabled)
return;

if (pb->enable_gpio)
Expand All @@ -86,6 +89,7 @@ static void pwm_backlight_power_off(struct pwm_bl_data *pb)
pwm_apply_state(pb->pwm, &state);

regulator_disable(pb->power_supply);
pb->enabled = false;
}

static int compute_duty_cycle(struct pwm_bl_data *pb, int brightness)
Expand Down Expand Up @@ -268,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 @@ -380,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 Expand Up @@ -483,6 +488,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
pb->check_fb = data->check_fb;
pb->exit = data->exit;
pb->dev = &pdev->dev;
pb->enabled = false;
pb->post_pwm_on_delay = data->post_pwm_on_delay;
pb->pwm_off_delay = data->pwm_off_delay;

Expand Down

0 comments on commit 3a73e73

Please sign in to comment.