Skip to content

Commit

Permalink
Merge tag 'backlight-next-5.18' 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:
 "New Device Support:
   - Add support for PM6150L to Qualcomm WLED

  Fix-ups"
   - Use kcalloc() to avoid open-coding; pwm_bl
   - Device Tree changes; qcom-wled
   - Cleanup or simplify code; backlight"

* tag 'backlight-next-5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight:
  backlight: backlight: Slighly simplify devm_of_find_backlight()
  backlight: qcom-wled: Add PM6150L compatible
  dt-bindings: backlight: qcom-wled: Add PM6150L compatible
  backlight: pwm_bl: Avoid open coded arithmetic in memory allocation
  • Loading branch information
Linus Torvalds committed Mar 25, 2022
2 parents 8350e83 + 023a883 commit 46f538b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ properties:
- qcom,pmi8994-wled
- qcom,pmi8998-wled
- qcom,pm660l-wled
- qcom,pm6150l-wled
- qcom,pm8150l-wled

reg:
Expand Down
10 changes: 4 additions & 6 deletions drivers/video/backlight/backlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,7 @@ static void devm_backlight_release(void *data)
{
struct backlight_device *bd = data;

if (bd)
put_device(&bd->dev);
put_device(&bd->dev);
}

/**
Expand All @@ -737,11 +736,10 @@ struct backlight_device *devm_of_find_backlight(struct device *dev)
bd = of_find_backlight(dev);
if (IS_ERR_OR_NULL(bd))
return bd;
ret = devm_add_action(dev, devm_backlight_release, bd);
if (ret) {
put_device(&bd->dev);
ret = devm_add_action_or_reset(dev, devm_backlight_release, bd);
if (ret)
return ERR_PTR(ret);
}

return bd;
}
EXPORT_SYMBOL(devm_of_find_backlight);
Expand Down
9 changes: 4 additions & 5 deletions drivers/video/backlight/pwm_bl.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,8 @@ static int pwm_backlight_parse_dt(struct device *dev,

/* read brightness levels from DT property */
if (num_levels > 0) {
size_t size = sizeof(*data->levels) * num_levels;

data->levels = devm_kzalloc(dev, size, GFP_KERNEL);
data->levels = devm_kcalloc(dev, num_levels,
sizeof(*data->levels), GFP_KERNEL);
if (!data->levels)
return -ENOMEM;

Expand Down Expand Up @@ -320,8 +319,8 @@ static int pwm_backlight_parse_dt(struct device *dev,
* Create a new table of brightness levels with all the
* interpolated steps.
*/
size = sizeof(*table) * num_levels;
table = devm_kzalloc(dev, size, GFP_KERNEL);
table = devm_kcalloc(dev, num_levels, sizeof(*table),
GFP_KERNEL);
if (!table)
return -ENOMEM;
/*
Expand Down

0 comments on commit 46f538b

Please sign in to comment.