Re: [PATCH] iio: imu: bmi323: use min_t() for watermark limit
From: David Laight
Date: Sun Jun 07 2026 - 13:29:13 EST
On Sun, 7 Jun 2026 13:22:00 +0000
Hungyu Lin <dennylin0707@xxxxxxxxx> wrote:
> Use min_t(u32, ...) instead of min() with an explicit cast to
> match the argument types and address a checkpatch.pl warning.
>
> No functional change intended.
Right - provided when you read the code you find the definition of 'val'
and check that it isn't 64bit.
min_t(u32, x, y) is just min((u32)x, (u32)y) so using it adds another cast.
I really don't see why that was ever a good idea...
>
> Signed-off-by: Hungyu Lin <dennylin0707@xxxxxxxxx>
> ---
> drivers/iio/imu/bmi323/bmi323_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/imu/bmi323/bmi323_core.c b/drivers/iio/imu/bmi323/bmi323_core.c
> index f3d499423399..38ad05f9ef58 100644
> --- a/drivers/iio/imu/bmi323/bmi323_core.c
> +++ b/drivers/iio/imu/bmi323/bmi323_core.c
> @@ -1128,7 +1128,7 @@ static int bmi323_set_watermark(struct iio_dev *indio_dev, unsigned int val)
> {
> struct bmi323_data *data = iio_priv(indio_dev);
>
> - val = min(val, (u32)BMI323_FIFO_FULL_IN_FRAMES);
> + val = min_t(u32, val, BMI323_FIFO_FULL_IN_FRAMES);
Ignore checkpatch :-)
Or just remove the original (u32) cast.
I really must rewrite the checkpatch 'stuff' about min_t().
-- David
>
> guard(mutex)(&data->mutex);
> data->watermark = val;