Re: [PATCH] spi: spi-fsl-lpspi: fix watermark truncation caused by type cast
From: Daniel Baluta
Date: Fri Nov 21 2025 - 04:28:34 EST
On Mon, Nov 17, 2025 at 5:06 AM <carlos.song@xxxxxxx> wrote:
>
> From: Carlos Song <carlos.song@xxxxxxx>
>
> 't->len' is an unsigned integer, while 'watermark' and 'txfifosize' are
> u8. Using min_t with typeof(watermark) forces both values to be cast to
> u8, which truncates len when it exceeds 255. For example, len = 4096
> becomes 0 after casting, resulting in an incorrect watermark value.
>
> Use a wider type in min_t to avoid truncation and ensure the correct
> minimum value is applied.
>
> Fixes: a750050349ea ("spi: spi-fsl-lpspi: use min_t() to improve code")
> Signed-off-by: Carlos Song <carlos.song@xxxxxxx>
LGTM,
Reviewed-by: Daniel Baluta <daniel.baluta@xxxxxxx>