2023-07-14 12:28:17

by Artur Weber

[permalink] [raw]
Subject: [PATCH 0/2] backlight: lp855x: Fixes after c1ff7da03e16

Two small fixes after commit c1ff7da03e16 ("video: backlight: lp855x:
Get PWM for PWM mode during probe"), stemming from a review[1] by
Uwe Kleine-König.

[1] https://lore.kernel.org/all/[email protected]/

Signed-off-by: Artur Weber <[email protected]>

Artur Weber (2):
backlight: lp855x: Initialize PWM state on first brightness change
backlight: lp855x: Catch errors when changing brightness

drivers/video/backlight/lp855x_bl.c | 33 +++++++++++++++++------------
1 file changed, 20 insertions(+), 13 deletions(-)


base-commit: 7fcd473a6455450428795d20db7afd2691c92336
--
2.41.0



2023-07-14 12:46:18

by Artur Weber

[permalink] [raw]
Subject: [PATCH 2/2] backlight: lp855x: Catch errors when changing brightness

The lp855x_bl_update_status function's return type is int, but
it always returns 0, without checking for the results of the
write_byte/pwm_ctrl functions called within.

Make this function return the return values of the functions it
calls, and modify the lp855x_pwm_ctrl function to return errors.

Signed-off-by: Artur Weber <[email protected]>
---
drivers/video/backlight/lp855x_bl.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
index 349ec324bc1e..61a7f45bfad8 100644
--- a/drivers/video/backlight/lp855x_bl.c
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -217,7 +217,7 @@ 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;

@@ -234,23 +234,26 @@ static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
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)
{
struct lp855x *lp = bl_get_data(bl);
int brightness = bl->props.brightness;
+ int ret;

if (bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
brightness = 0;

if (lp->mode == PWM_BASED)
- lp855x_pwm_ctrl(lp, brightness, bl->props.max_brightness);
+ ret = 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);
+ ret = lp855x_write_byte(lp, lp->cfg->reg_brightness,
+ (u8)brightness);

- return 0;
+ return ret;
}

static const struct backlight_ops lp855x_bl_ops = {
--
2.41.0


2023-07-17 09:36:35

by Daniel Thompson

[permalink] [raw]
Subject: Re: [PATCH 2/2] backlight: lp855x: Catch errors when changing brightness

On Fri, Jul 14, 2023 at 02:14:40PM +0200, Artur Weber wrote:
> The lp855x_bl_update_status function's return type is int, but
> it always returns 0, without checking for the results of the
> write_byte/pwm_ctrl functions called within.
>
> Make this function return the return values of the functions it
> calls, and modify the lp855x_pwm_ctrl function to return errors.
>
> Signed-off-by: Artur Weber <[email protected]>

Reviewed-by: Daniel Thompson <[email protected]>

2023-07-28 09:54:52

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH 0/2] backlight: lp855x: Fixes after c1ff7da03e16

On Fri, 14 Jul 2023 14:14:38 +0200, Artur Weber wrote:
> Two small fixes after commit c1ff7da03e16 ("video: backlight: lp855x:
> Get PWM for PWM mode during probe"), stemming from a review[1] by
> Uwe Kleine-König.
>
> [1] https://lore.kernel.org/all/[email protected]/
>
> Signed-off-by: Artur Weber <[email protected]>
>
> [...]

Applied, thanks!

[1/2] backlight: lp855x: Initialize PWM state on first brightness change
commit: 4c09e20b3c85f60353ace21092e34f35f5e3ab00
[2/2] backlight: lp855x: Catch errors when changing brightness
commit: 5145531be5fbad0e914d1dc1cbd392d7b756abaa

--
Lee Jones [李琼斯]