Skip to content

Commit 57ac7ff

Browse files
committed
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
2 parents 65d6e95 + a446409 commit 57ac7ff

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

drivers/video/backlight/gpio_backlight.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ static int gpio_backlight_probe(struct platform_device *pdev)
8787
/* Not booted with device tree or no phandle link to the node */
8888
bl->props.power = def_value ? FB_BLANK_UNBLANK
8989
: 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)
9291
bl->props.power = FB_BLANK_POWERDOWN;
9392
else
9493
bl->props.power = FB_BLANK_UNBLANK;

drivers/video/backlight/led_bl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ MODULE_DEVICE_TABLE(of, led_bl_of_match);
243243
static struct platform_driver led_bl_driver = {
244244
.driver = {
245245
.name = "led-backlight",
246-
.of_match_table = of_match_ptr(led_bl_of_match),
246+
.of_match_table = led_bl_of_match,
247247
},
248248
.probe = led_bl_probe,
249249
.remove_new = led_bl_remove,

drivers/video/backlight/lp855x_bl.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ struct lp855x {
7171
struct device *dev;
7272
struct lp855x_platform_data *pdata;
7373
struct pwm_device *pwm;
74+
bool needs_pwm_init;
7475
struct regulator *supply; /* regulator for VDD input */
7576
struct regulator *enable; /* regulator for EN/VDDIO input */
7677
};
@@ -216,16 +217,24 @@ static int lp855x_configure(struct lp855x *lp)
216217
return ret;
217218
}
218219

219-
static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
220+
static int lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
220221
{
221222
struct pwm_state state;
222223

223-
pwm_get_state(lp->pwm, &state);
224+
if (lp->needs_pwm_init) {
225+
pwm_init_state(lp->pwm, &state);
226+
/* Legacy platform data compatibility */
227+
if (lp->pdata->period_ns > 0)
228+
state.period = lp->pdata->period_ns;
229+
lp->needs_pwm_init = false;
230+
} else {
231+
pwm_get_state(lp->pwm, &state);
232+
}
224233

225234
state.duty_cycle = div_u64(br * state.period, max_br);
226235
state.enabled = state.duty_cycle;
227236

228-
pwm_apply_state(lp->pwm, &state);
237+
return pwm_apply_state(lp->pwm, &state);
229238
}
230239

231240
static int lp855x_bl_update_status(struct backlight_device *bl)
@@ -237,11 +246,12 @@ static int lp855x_bl_update_status(struct backlight_device *bl)
237246
brightness = 0;
238247

239248
if (lp->mode == PWM_BASED)
240-
lp855x_pwm_ctrl(lp, brightness, bl->props.max_brightness);
249+
return lp855x_pwm_ctrl(lp, brightness,
250+
bl->props.max_brightness);
241251
else if (lp->mode == REGISTER_BASED)
242-
lp855x_write_byte(lp, lp->cfg->reg_brightness, (u8)brightness);
243-
244-
return 0;
252+
return lp855x_write_byte(lp, lp->cfg->reg_brightness,
253+
(u8)brightness);
254+
return -EINVAL;
245255
}
246256

247257
static const struct backlight_ops lp855x_bl_ops = {
@@ -387,7 +397,6 @@ static int lp855x_probe(struct i2c_client *cl)
387397
const struct i2c_device_id *id = i2c_client_get_device_id(cl);
388398
const struct acpi_device_id *acpi_id = NULL;
389399
struct device *dev = &cl->dev;
390-
struct pwm_state pwmstate;
391400
struct lp855x *lp;
392401
int ret;
393402

@@ -470,15 +479,11 @@ static int lp855x_probe(struct i2c_client *cl)
470479
else
471480
return dev_err_probe(dev, ret, "getting PWM\n");
472481

482+
lp->needs_pwm_init = false;
473483
lp->mode = REGISTER_BASED;
474484
dev_dbg(dev, "mode: register based\n");
475485
} else {
476-
pwm_init_state(lp->pwm, &pwmstate);
477-
/* Legacy platform data compatibility */
478-
if (lp->pdata->period_ns > 0)
479-
pwmstate.period = lp->pdata->period_ns;
480-
pwm_apply_state(lp->pwm, &pwmstate);
481-
486+
lp->needs_pwm_init = true;
482487
lp->mode = PWM_BASED;
483488
dev_dbg(dev, "mode: PWM based\n");
484489
}

drivers/video/backlight/qcom-wled.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#include <linux/backlight.h>
1010
#include <linux/module.h>
1111
#include <linux/of.h>
12-
#include <linux/of_device.h>
1312
#include <linux/of_address.h>
13+
#include <linux/platform_device.h>
1414
#include <linux/regmap.h>
1515

1616
/* From DT binding */

0 commit comments

Comments
 (0)