- New Functionality

- Ensure correct includes are present and remove some that are not required
    - Drop redundant of_match_ptr() call to cast pointer to NULL
 
  - Bug Fixes
    - Revert to old (expected) behaviour of initialising PWM state on first brightness change
    - Correctly handle / propagate errors
    - Fix 'sometimes-uninitialised' issues
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEdrbJNaO+IJqU8IdIUa+KL4f8d2EFAmT15P0ACgkQUa+KL4f8
 d2FKXA/+LL5nsswN5Vv7MALU87C9Lk068S4LCA8XVSRmB3jBAGwtz1kHj320nv16
 PH3FFgCxIg4A0CVNXlPujatmwZpEGJNneGortYYNV+OaWOv3rnZigXtcOshU8pIW
 by8flfHyzdBiXn/RRQuxsWWws8Fg12x8ZtYUeuXuNC7W9mvDxArxHkawhinCfp7i
 duITp8qTDkcCLRyxZ1oIQEoBuGrlYDZDodofEW1LyE98iy/RMtX8UoOREcF8XgZF
 LfA5m/inJSF06uzYR4Z60MIJ2b7L5O7tD+auqssNW3/XHTyCHOKGR/wrcwk7BzEn
 cpN6i0jjWR4wEGQVCtpghWKnd11X3IW8uF7M7vXO2a+M5iz5u98s7PAjNL8MHSEB
 N8Ekqd1nzkeIdjXqopLEGm0RI8ixaVY7jJiSGSp83kEEjdcybRWxgmHslTgBP++O
 6YLRHyh2gGDxJcBEoBtMhYFeMDki58i426iqTE9NeWye7T43/jCojZ0FR1XgdMHB
 Mqu/4NsZTTA41evzAI1GR9P5nxogjq3w9ZzWRcq996YodklzNJOhff3Tlb7aT7bo
 /MgnnqwvwRB4VWn6t2QQYq6UN+5wfh0VeNCCO+jFT13IfNrjc51Qnev3i7jKr0Fg
 H6DgKGxUyzfx4VOVJdtQ9DtQ3el1dXBJ69TdGyTk3YME6R3ZtxQ=
 =5vB4
 -----END PGP SIGNATURE-----

Merge tag 'backlight-next-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight

Pull backlight updates from Lee Jones:
 "New Functionality:

   - Ensure correct includes are present and remove some that are not
     required

   - Drop redundant of_match_ptr() call to cast pointer to NULL

  Bug Fixes:

   - Revert to old (expected) behaviour of initialising PWM state on
     first brightness change

   - Correctly handle / propagate errors

   - Fix 'sometimes-uninitialised' issues"

* tag 'backlight-next-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight:
  backlight: led_bl: Remove redundant of_match_ptr()
  backlight: lp855x: Drop ret variable in brightness change function
  backlight: gpio_backlight: Drop output GPIO direction check for initial power state
  backlight: lp855x: Catch errors when changing brightness
  backlight: lp855x: Initialize PWM state on first brightness change
  backlight: qcom-wled: Explicitly include correct DT includes
This commit is contained in:
Linus Torvalds 2023-09-06 09:00:37 -07:00
commit 57ac7ff8cb
4 changed files with 22 additions and 18 deletions

View file

@ -87,8 +87,7 @@ static int gpio_backlight_probe(struct platform_device *pdev)
/* Not booted with device tree or no phandle link to the node */
bl->props.power = def_value ? FB_BLANK_UNBLANK
: FB_BLANK_POWERDOWN;
else if (gpiod_get_direction(gbl->gpiod) == 0 &&
gpiod_get_value_cansleep(gbl->gpiod) == 0)
else if (gpiod_get_value_cansleep(gbl->gpiod) == 0)
bl->props.power = FB_BLANK_POWERDOWN;
else
bl->props.power = FB_BLANK_UNBLANK;

View file

@ -243,7 +243,7 @@ MODULE_DEVICE_TABLE(of, led_bl_of_match);
static struct platform_driver led_bl_driver = {
.driver = {
.name = "led-backlight",
.of_match_table = of_match_ptr(led_bl_of_match),
.of_match_table = led_bl_of_match,
},
.probe = led_bl_probe,
.remove_new = led_bl_remove,

View file

@ -71,6 +71,7 @@ struct lp855x {
struct device *dev;
struct lp855x_platform_data *pdata;
struct pwm_device *pwm;
bool needs_pwm_init;
struct regulator *supply; /* regulator for VDD input */
struct regulator *enable; /* regulator for EN/VDDIO input */
};
@ -216,16 +217,24 @@ static int lp855x_configure(struct lp855x *lp)
return ret;
}
static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
static int lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
{
struct pwm_state state;
pwm_get_state(lp->pwm, &state);
if (lp->needs_pwm_init) {
pwm_init_state(lp->pwm, &state);
/* Legacy platform data compatibility */
if (lp->pdata->period_ns > 0)
state.period = lp->pdata->period_ns;
lp->needs_pwm_init = false;
} else {
pwm_get_state(lp->pwm, &state);
}
state.duty_cycle = div_u64(br * state.period, max_br);
state.enabled = state.duty_cycle;
pwm_apply_state(lp->pwm, &state);
return pwm_apply_state(lp->pwm, &state);
}
static int lp855x_bl_update_status(struct backlight_device *bl)
@ -237,11 +246,12 @@ static int lp855x_bl_update_status(struct backlight_device *bl)
brightness = 0;
if (lp->mode == PWM_BASED)
lp855x_pwm_ctrl(lp, brightness, bl->props.max_brightness);
return lp855x_pwm_ctrl(lp, brightness,
bl->props.max_brightness);
else if (lp->mode == REGISTER_BASED)
lp855x_write_byte(lp, lp->cfg->reg_brightness, (u8)brightness);
return 0;
return lp855x_write_byte(lp, lp->cfg->reg_brightness,
(u8)brightness);
return -EINVAL;
}
static const struct backlight_ops lp855x_bl_ops = {
@ -387,7 +397,6 @@ static int lp855x_probe(struct i2c_client *cl)
const struct i2c_device_id *id = i2c_client_get_device_id(cl);
const struct acpi_device_id *acpi_id = NULL;
struct device *dev = &cl->dev;
struct pwm_state pwmstate;
struct lp855x *lp;
int ret;
@ -470,15 +479,11 @@ static int lp855x_probe(struct i2c_client *cl)
else
return dev_err_probe(dev, ret, "getting PWM\n");
lp->needs_pwm_init = false;
lp->mode = REGISTER_BASED;
dev_dbg(dev, "mode: register based\n");
} else {
pwm_init_state(lp->pwm, &pwmstate);
/* Legacy platform data compatibility */
if (lp->pdata->period_ns > 0)
pwmstate.period = lp->pdata->period_ns;
pwm_apply_state(lp->pwm, &pwmstate);
lp->needs_pwm_init = true;
lp->mode = PWM_BASED;
dev_dbg(dev, "mode: PWM based\n");
}

View file

@ -9,8 +9,8 @@
#include <linux/backlight.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
/* From DT binding */