All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Paul Cercueil <paul@crapouillou.net>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Subject: Re: [PATCH 1/2] iio: imu: st_lsm6dsx: Limit requested watermark value to hwfifo size
Date: Mon, 17 Jan 2022 11:56:07 +0100	[thread overview]
Message-ID: <YeVLRzmUw/U9GRC3@lore-desk> (raw)
In-Reply-To: <20220117102512.31725-1-paul@crapouillou.net>

[-- Attachment #1: Type: text/plain, Size: 1401 bytes --]

> Instead of returning an error if the watermark value is too high, which
> the core will silently ignore anyway, limit the value to the hardware
> FIFO size; a lower-than-requested value is still better than using the
> default, which is usually 1.
> 

Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>

> Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index 727b4b6ac696..5fd46bf1a11b 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -54,6 +54,7 @@
>  #include <linux/iio/sysfs.h>
>  #include <linux/interrupt.h>
>  #include <linux/irq.h>
> +#include <linux/minmax.h>
>  #include <linux/pm.h>
>  #include <linux/property.h>
>  #include <linux/regmap.h>
> @@ -1607,8 +1608,7 @@ int st_lsm6dsx_set_watermark(struct iio_dev *iio_dev, unsigned int val)
>  	struct st_lsm6dsx_hw *hw = sensor->hw;
>  	int err;
>  
> -	if (val < 1 || val > hw->settings->fifo_ops.max_size)
> -		return -EINVAL;
> +	val = clamp_val(val, 1, hw->settings->fifo_ops.max_size);
>  
>  	mutex_lock(&hw->conf_lock);
>  
> -- 
> 2.34.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

WARNING: multiple messages have this Message-ID
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Paul Cercueil <paul@crapouillou.net>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Subject: Re: [PATCH 1/2] iio: imu: st_lsm6dsx: Limit requested watermark value to hwfifo size
Date: Mon, 17 Jan 2022 11:56:07 +0100	[thread overview]
Message-ID: <YeVLRzmUw/U9GRC3@lore-desk> (raw)
In-Reply-To: <20220117102512.31725-1-paul@crapouillou.net>


[-- Attachment #1.1: Type: text/plain, Size: 1401 bytes --]

> Instead of returning an error if the watermark value is too high, which
> the core will silently ignore anyway, limit the value to the hardware
> FIFO size; a lower-than-requested value is still better than using the
> default, which is usually 1.
> 

Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>

> Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index 727b4b6ac696..5fd46bf1a11b 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -54,6 +54,7 @@
>  #include <linux/iio/sysfs.h>
>  #include <linux/interrupt.h>
>  #include <linux/irq.h>
> +#include <linux/minmax.h>
>  #include <linux/pm.h>
>  #include <linux/property.h>
>  #include <linux/regmap.h>
> @@ -1607,8 +1608,7 @@ int st_lsm6dsx_set_watermark(struct iio_dev *iio_dev, unsigned int val)
>  	struct st_lsm6dsx_hw *hw = sensor->hw;
>  	int err;
>  
> -	if (val < 1 || val > hw->settings->fifo_ops.max_size)
> -		return -EINVAL;
> +	val = clamp_val(val, 1, hw->settings->fifo_ops.max_size);
>  
>  	mutex_lock(&hw->conf_lock);
>  
> -- 
> 2.34.1
> 

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2022-01-17 10:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-17 10:25 Paul Cercueil
2022-01-17 10:25 ` Paul Cercueil
2022-01-17 10:25 ` [PATCH 2/2] iio: at91-sama5d2: " Paul Cercueil
2022-01-17 10:25   ` Paul Cercueil
2022-01-22 17:04   ` Jonathan Cameron
2022-01-22 17:04     ` Jonathan Cameron
2022-06-04 15:05     ` Jonathan Cameron
2022-06-04 15:05       ` Jonathan Cameron
2022-06-04 22:41       ` Paul Cercueil
2022-06-04 22:41         ` Paul Cercueil
2022-06-12  8:49         ` Jonathan Cameron
2022-06-12  8:49           ` Jonathan Cameron
2022-01-17 10:56 ` Lorenzo Bianconi [this message]
2022-01-17 10:56   ` [PATCH 1/2] iio: imu: st_lsm6dsx: " Lorenzo Bianconi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YeVLRzmUw/U9GRC3@lore-desk \
    --to=lorenzo@kernel.org \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo.bianconi83@gmail.com \
    --cc=paul@crapouillou.net \
    --subject='Re: [PATCH 1/2] iio: imu: st_lsm6dsx: Limit requested watermark value to hwfifo size' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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.