Skip to contentSkip to conversation

iio: imu: bmi323: remove unnecessary cast in watermark limit

PATCH In review Hungyu Lin 4 participants 4 messages Jun 8 – Jun 10

Subsystems (2)
lore
Share & tools
lore

Hungyu Lin

author
#0 lore raw

PATCH v2 1/1 iio: imu: bmi323: remove unnecessary cast in watermark limit

Remove the explicit u32 cast in the watermark limit calculation.

The BMI323_FIFO_FULL_IN_FRAMES macro can be used directly with min() without triggering type issues.

---
Changes in v2:
- Drop the unnecessary cast instead of using min_t().
- Follow reviewer feedback from David Laight and Andy Shevchenko.

 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..72955a697a93 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(val, BMI323_FIFO_FULL_IN_FRAMES);
 
 	guard(mutex)(&data->mutex);
 	data->watermark = val;
Signature · 1 line
2.34.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Hungyu Lin

Remove the explicit u32 cast in the watermark limit calculation.

The BMI323_FIFO_FULL_IN_FRAMES macro can be used directly with min() without triggering type issues.

---

Quoted 22 lines

Changes in v2:
- Drop the unnecessary cast instead of using min_t().
- Follow reviewer feedback from David Laight and Andy Shevchenko.

 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..72955a697a93 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);

drivers/iio/imu/bmi323/bmi323_core.c +1 -1
-	val = min(val, (u32)BMI323_FIFO_FULL_IN_FRAMES);
+	val = min(val, BMI323_FIFO_FULL_IN_FRAMES);


  guard(mutex)(&data->mutex);
  data->watermark = val;

Reviewed-by on v2 1/1
#2 lore raw
In reply to Hungyu Lin
Quoted 4 lines · Hungyu Lin

Remove the explicit u32 cast in the watermark limit calculation.

The BMI323_FIFO_FULL_IN_FRAMES macro can be used directly with min() without triggering type issues.

Right, now it looks much better.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#3 lore raw
Quoted 9 lines · On Tue, 9 Jun 2026 16:28:31 +0300 Andy Shevchenko…
Quoted 4 lines · Hungyu Lin

Remove the explicit u32 cast in the watermark limit calculation.

The BMI323_FIFO_FULL_IN_FRAMES macro can be used directly with min() without triggering type issues.

Right, now it looks much better.

Agreed. Easy to check these min conditions as there is good documentation in minmax.h Entry that is relevant here I think is this one.

* - Unsigned arguments can be compared against non-negative signed constants.

Applied to the testing branch of iio.git.

Thanks,

Jonathan