Re: [PATCH v3 2/3] backlight: aw99706: Validate all DT property values consistently
From: Daniel Thompson
Date: Mon Aug 10 2026 - 06:32:15 EST
On Tue, Aug 04, 2026 at 11:02:54AM +0800, Junjie Cao wrote:
> From: Junjie Cao <junjie.cao@xxxxxxxxx>
>
> The lookup helpers for dim-mode and ramp-ctl take a shortcut when
> lookup_tbl is NULL: they accept any u32 value without range-checking
> and return success unconditionally. Out-of-range values get silently
> truncated by regmap_update_bits instead of triggering the dev_warn +
> default-fallback path that the other properties use.
>
> Add a field-width check for the NULL-table case so that values
> exceeding the register field maximum are rejected the same way a
> table-lookup miss is.
>
> The switching frequency table has a second hole: reserved slots use 0
> as their marker, so "awinic,sw-freq-hz = <0>" matches slot 0 and
> programs a reserved encoding. Make the reserved marker U32_MAX and
> skip such slots during lookup.
>
> While here, also switch the error returns to -EINVAL for consistency.
>
> Fixes: 147b38a5ad06 ("backlight: aw99706: Add support for Awinic AW99706 backlight")
> Signed-off-by: Junjie Cao <junjie.cao@xxxxxxxxx>
Reviewed-by: Daniel Thompson (RISCstar) <danielt@xxxxxxxxxx>
Daniel.