Re: [PATCH v2] leds: rgb: leds-qcom-lpg: Fix LED color balancing in HW pattern mode

From: Konrad Dybcio

Date: Thu Jun 25 2026 - 05:10:25 EST


On 6/24/26 9:37 AM, Fenglin Wu wrote:
> Currently, when the LED is configured as a RGB LED or a multi-color
> LED device, the same pattern is programmed for all LED channels
> regardless of the sub-led intensities when triggered by HW pattern.
> It results that the LED device is always working in a white-balanced
> mode regardless of the intensity settings.
>
> To fix this, scale the pattern data according to the sub-led intensity
> and program the HW pattern separately for each LPG channel.
>
> Fixes: 24e2d05d1b68 ("leds: Add driver for Qualcomm LPG")
> Fixes: 6ab1f766a80a ("leds: rgb: leds-qcom-lpg: Add support for PPG through single SDAM")
> Fixes: 5e9ff626861a ("leds: rgb: leds-qcom-lpg: Include support for PPG with dedicated LUT SDAM")
> Assisted-by: Claude:claude-4-6-sonnet
> Signed-off-by: Fenglin Wu <fenglin.wu@xxxxxxxxxxxxxxxx>
> ---

[...]

> +out_free:
> + kfree(pattern);

We can use __free() from cleanup.h to get rid of the gotos

[...]

> out_unlock:
> mutex_unlock(&lpg->lock);
> -out_free_pattern:
> - kfree(pattern);
> + kfree(pattern.data);

likewise here, also with guard(mutex)(foo)

and same below

Konrad