mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] iio: imu: bmi323: remove unnecessary cast in watermark limit
@ 2026-06-08 12:15 Hungyu Lin
  2026-06-08 20:20 ` Nuno Sá
  2026-06-09 13:28 ` Andy Shevchenko
  0 siblings, 2 replies; 4+ messages in thread
From: Hungyu Lin @ 2026-06-08 12:15 UTC (permalink / raw)
  To: jagathjog1996, jic23
  Cc: dlechner, nuno.sa, andy, linux-iio, linux-kernel, 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.

Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
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(-)

diff --git a/drivers/iio/imu/bmi323/bmi323_core.c b/drivers/iio/imu/bmi323/bmi323_core.c
index f3d499423399..72955a697a93 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(val, BMI323_FIFO_FULL_IN_FRAMES);
 
 	guard(mutex)(&data->mutex);
 	data->watermark = val;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] iio: imu: bmi323: remove unnecessary cast in watermark limit
  2026-06-08 12:15 [PATCH v2] iio: imu: bmi323: remove unnecessary cast in watermark limit Hungyu Lin
@ 2026-06-08 20:20 ` Nuno Sá
  2026-06-09 13:28 ` Andy Shevchenko
  1 sibling, 0 replies; 4+ messages in thread
From: Nuno Sá @ 2026-06-08 20:20 UTC (permalink / raw)
  To: Hungyu Lin, jagathjog1996, jic23
  Cc: dlechner, nuno.sa, andy, linux-iio, linux-kernel

On Mon, 2026-06-08 at 12:15 +0000, Hungyu Lin wrote:
> 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.
> 
> Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
> ---

Reviewed-by: Nuno Sá <nuno.sa@analog.com>

> 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(-)
> 
> diff --git a/drivers/iio/imu/bmi323/bmi323_core.c
> b/drivers/iio/imu/bmi323/bmi323_core.c
> index f3d499423399..72955a697a93 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(val, BMI323_FIFO_FULL_IN_FRAMES);
>  
>  	guard(mutex)(&data->mutex);
>  	data->watermark = val;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] iio: imu: bmi323: remove unnecessary cast in watermark limit
  2026-06-08 12:15 [PATCH v2] iio: imu: bmi323: remove unnecessary cast in watermark limit Hungyu Lin
  2026-06-08 20:20 ` Nuno Sá
@ 2026-06-09 13:28 ` Andy Shevchenko
  2026-06-10 15:36   ` Jonathan Cameron
  1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2026-06-09 13:28 UTC (permalink / raw)
  To: Hungyu Lin
  Cc: jagathjog1996, jic23, dlechner, nuno.sa, andy, linux-iio, linux-kernel

On Mon, Jun 08, 2026 at 12:15:58PM +0000, Hungyu Lin wrote:
> 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.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] iio: imu: bmi323: remove unnecessary cast in watermark limit
  2026-06-09 13:28 ` Andy Shevchenko
@ 2026-06-10 15:36   ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2026-06-10 15:36 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Hungyu Lin, jagathjog1996, dlechner, nuno.sa, andy, linux-iio,
	linux-kernel

On Tue, 9 Jun 2026 16:28:31 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Mon, Jun 08, 2026 at 12:15:58PM +0000, Hungyu Lin wrote:
> > 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.
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> 


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-06-10 15:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-08 12:15 [PATCH v2] iio: imu: bmi323: remove unnecessary cast in watermark limit Hungyu Lin
2026-06-08 20:20 ` Nuno Sá
2026-06-09 13:28 ` Andy Shevchenko
2026-06-10 15:36   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®