Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Medium] backlight: qcom-wled: wled5_set_brightness() clamps 0 to low_limit 
on restore
--

commit 1866e6688066844d34f7f3f1d2a0c521bb917107
Author: Dmitry Baryshkov <[email protected]>

backlight: qcom-wled: fix string detection brightness on WLED5

This commit updates wled_auto_string_detection() to use the per-version
wled_set_brightness() callback instead of hardcoding wled4_set_brightness(),
and moves the WLED5 module sync toggle into wled5_set_brightness().

> diff --git a/drivers/video/backlight/qcom-wled.c 
> b/drivers/video/backlight/qcom-wled.c
> index ca350f320e177..c5243a6d547e5 100644
> --- a/drivers/video/backlight/qcom-wled.c
> +++ b/drivers/video/backlight/qcom-wled.c

[ ... ]

> @@ -791,7 +783,7 @@ static void wled_auto_string_detection(struct wled *wled)
>       }
>  
>       /* Restore brightness */
> -     rc = wled4_set_brightness(wled, wled->brightness);
> +     rc = wled->wled_set_brightness(wled, wled->brightness);
>       if (rc < 0) {
>               dev_err(wled->dev, "Failed to set brightness after auto 
> detection rc=%d\n",
>                       rc);

[Severity: Medium]
When wled_auto_string_detection() runs during probe via
wled_probe() -> wled5_setup() -> wled_auto_detection_at_init(),
wled_read_brightness() has not run yet, so wled->brightness is still 0.

Previously, wled4_set_brightness() only clamped non-zero brightness values:

        /* WLED4's lower limit of operation is 0.4% */
        if (brightness > 0 && brightness < low_limit)
                brightness = low_limit;

However, wled5_set_brightness() unconditionally clamps brightness == 0 up to
low_limit (0.1% of max_brightness):

        /* WLED5's lower limit is 0.1% */
        if (brightness < low_limit)
                brightness = low_limit;

With this change, restoring wled->brightness (0) at the end of
wled_auto_string_detection() on WLED5 writes and latches low_limit into the
modulator brightness register before enabling WLED3_CTRL_REG_MOD_EN.

When wled_probe() subsequently calls wled_read_brightness():

        rc = wled_read_brightness(wled);
        if (rc < 0)
                return rc;

        wled->brightness = rc;
        ...
        props.brightness = wled->brightness ?: val;

will it read back low_limit instead of 0, leaving ovp_irq enabled in
wled_configure_ovp_irq() and initializing props.brightness to low_limit
instead of default-brightness?

Should wled5_set_brightness() check brightness > 0 && brightness < low_limit
like wled4_set_brightness() does?

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to