Skip to contentSkip to conversation

iio: imu: bmi323: use min_t() for watermark limit

PATCH In review Hungyu Lin 3 participants 3 messages Jun 7 – Jun 8

Subsystems (2)
lore
Share & tools
lore

Hungyu Lin

author
#0 lore raw

PATCH 1/1 iio: imu: bmi323: use min_t() for watermark limit

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.

---
 drivers/iio/imu/bmi323/bmi323_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/imu/bmi323/bmi323_core.c +1 -1
index f3d499423399..38ad05f9ef58 100644
@@ -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;
Signature · 1 line
2.34.1
#1 lore raw
Quoted 4 lines · On Sun, 7 Jun 2026 13:22:00 +0000 Hungyu Lin <[email protected]> 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...

Quoted 11 lines
---
 drivers/iio/imu/bmi323/bmi323_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/imu/bmi323/bmi323_core.c +0 -0
index f3d499423399..38ad05f9ef58 100644

drivers/iio/imu/bmi323/bmi323_core.c static int bmi323_set_watermark(struct iio_dev *indio_dev, unsigned int val) · line 1131

Quoted 5 lines
drivers/iio/imu/bmi323/bmi323_core.c +1 -1
@@ -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

Quoted 3 lines
drivers/iio/imu/bmi323/bmi323_core.c +0 -0
 	guard(mutex)(&data->mutex);
 	data->watermark = val;
#2 lore raw
In reply to Hungyu Lin
Quoted 4 lines · 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.

NAK. min_t() has not to be used. Find a better alternative (see what David said, for example).

Signature · 2 lines
With Best Regards,
Andy Shevchenko