* [PATCH] iio: imu: bmi323: use min_t() for watermark limit
@ 2026-06-07 13:22 Hungyu Lin
2026-06-07 17:28 ` David Laight
0 siblings, 1 reply; 2+ messages in thread
From: Hungyu Lin @ 2026-06-07 13:22 UTC (permalink / raw)
To: jagathjog1996, jic23
Cc: dlechner, nuno.sa, andy, linux-iio, linux-kernel, Hungyu Lin
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.
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
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);
guard(mutex)(&data->mutex);
data->watermark = val;
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] iio: imu: bmi323: use min_t() for watermark limit
2026-06-07 13:22 [PATCH] iio: imu: bmi323: use min_t() for watermark limit Hungyu Lin
@ 2026-06-07 17:28 ` David Laight
0 siblings, 0 replies; 2+ messages in thread
From: David Laight @ 2026-06-07 17:28 UTC (permalink / raw)
To: Hungyu Lin
Cc: jagathjog1996, jic23, dlechner, nuno.sa, andy, linux-iio,
linux-kernel
On Sun, 7 Jun 2026 13:22:00 +0000
Hungyu Lin <dennylin0707@gmail.com> 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@gmail.com>
> ---
> 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;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-07 17:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-07 13:22 [PATCH] iio: imu: bmi323: use min_t() for watermark limit Hungyu Lin
2026-06-07 17:28 ` David Laight
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.