Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+22 -18
+1 -2
drivers/video/backlight/gpio_backlight.c
··· 87 87 /* Not booted with device tree or no phandle link to the node */ 88 88 bl->props.power = def_value ? FB_BLANK_UNBLANK 89 89 : FB_BLANK_POWERDOWN; 90 - else if (gpiod_get_direction(gbl->gpiod) == 0 && 91 - gpiod_get_value_cansleep(gbl->gpiod) == 0) 90 + else if (gpiod_get_value_cansleep(gbl->gpiod) == 0) 92 91 bl->props.power = FB_BLANK_POWERDOWN; 93 92 else 94 93 bl->props.power = FB_BLANK_UNBLANK;
+1 -1
drivers/video/backlight/led_bl.c
··· 243 243 static struct platform_driver led_bl_driver = { 244 244 .driver = { 245 245 .name = "led-backlight", 246 - .of_match_table = of_match_ptr(led_bl_of_match), 246 + .of_match_table = led_bl_of_match, 247 247 }, 248 248 .probe = led_bl_probe, 249 249 .remove_new = led_bl_remove,
+19 -14
drivers/video/backlight/lp855x_bl.c
··· 71 71 struct device *dev; 72 72 struct lp855x_platform_data *pdata; 73 73 struct pwm_device *pwm; 74 + bool needs_pwm_init; 74 75 struct regulator *supply; /* regulator for VDD input */ 75 76 struct regulator *enable; /* regulator for EN/VDDIO input */ 76 77 }; ··· 217 216 return ret; 218 217 } 219 218 220 - static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br) 219 + static int lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br) 221 220 { 222 221 struct pwm_state state; 223 222 224 - pwm_get_state(lp->pwm, &state); 223 + if (lp->needs_pwm_init) { 224 + pwm_init_state(lp->pwm, &state); 225 + /* Legacy platform data compatibility */ 226 + if (lp->pdata->period_ns > 0) 227 + state.period = lp->pdata->period_ns; 228 + lp->needs_pwm_init = false; 229 + } else { 230 + pwm_get_state(lp->pwm, &state); 231 + } 225 232 226 233 state.duty_cycle = div_u64(br * state.period, max_br); 227 234 state.enabled = state.duty_cycle; 228 235 229 - pwm_apply_state(lp->pwm, &state); 236 + return pwm_apply_state(lp->pwm, &state); 230 237 } 231 238 232 239 static int lp855x_bl_update_status(struct backlight_device *bl) ··· 246 237 brightness = 0; 247 238 248 239 if (lp->mode == PWM_BASED) 249 - lp855x_pwm_ctrl(lp, brightness, bl->props.max_brightness); 240 + return lp855x_pwm_ctrl(lp, brightness, 241 + bl->props.max_brightness); 250 242 else if (lp->mode == REGISTER_BASED) 251 - lp855x_write_byte(lp, lp->cfg->reg_brightness, (u8)brightness); 252 - 253 - return 0; 243 + return lp855x_write_byte(lp, lp->cfg->reg_brightness, 244 + (u8)brightness); 245 + return -EINVAL; 254 246 } 255 247 256 248 static const struct backlight_ops lp855x_bl_ops = { ··· 397 387 const struct i2c_device_id *id = i2c_client_get_device_id(cl); 398 388 const struct acpi_device_id *acpi_id = NULL; 399 389 struct device *dev = &cl->dev; 400 - struct pwm_state pwmstate; 401 390 struct lp855x *lp; 402 391 int ret; 403 392 ··· 479 470 else 480 471 return dev_err_probe(dev, ret, "getting PWM\n"); 481 472 473 + lp->needs_pwm_init = false; 482 474 lp->mode = REGISTER_BASED; 483 475 dev_dbg(dev, "mode: register based\n"); 484 476 } else { 485 - pwm_init_state(lp->pwm, &pwmstate); 486 - /* Legacy platform data compatibility */ 487 - if (lp->pdata->period_ns > 0) 488 - pwmstate.period = lp->pdata->period_ns; 489 - pwm_apply_state(lp->pwm, &pwmstate); 490 - 477 + lp->needs_pwm_init = true; 491 478 lp->mode = PWM_BASED; 492 479 dev_dbg(dev, "mode: PWM based\n"); 493 480 }
+1 -1
drivers/video/backlight/qcom-wled.c
··· 9 9 #include <linux/backlight.h> 10 10 #include <linux/module.h> 11 11 #include <linux/of.h> 12 - #include <linux/of_device.h> 13 12 #include <linux/of_address.h> 13 + #include <linux/platform_device.h> 14 14 #include <linux/regmap.h> 15 15 16 16 /* From DT binding */