From: Jonathan Cameron <jic23@kernel.org>
To: Cosmin Tanislav <demonsingur@gmail.com>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Cosmin Tanislav <cosmin.tanislav@analog.com>
Subject: Re: [PATCH] iio: accel: adxl367: do not update FIFO watermark on scan mode update
Date: Sun, 22 May 2022 12:52:23 +0100 [thread overview]
Message-ID: <20220522125223.1b310ede@jic23-huawei> (raw)
In-Reply-To: <20220514182010.152784-1-cosmin.tanislav@analog.com>
On Sat, 14 May 2022 21:20:10 +0300
Cosmin Tanislav <demonsingur@gmail.com> wrote:
> Currently, the driver updates the FIFO watermark inside both
> update_scan_mode() and hwfifo_set_watermark(). Inside the IIO core,
> hwfifo_set_watermark() is called immediately after update_scan_mode(),
> making the first call to set_fifo_samples() redundant.
>
> Remove the first call to set_fifo_samples(), and merge the
> set_fifo_samples() function into the set_fifo_watermark()
> function. Also, since fifo_set_size is always set inside of
> update_scan_mode(), and it cannot be set to 0, remove the
> zero check from set_fifo_samples().
>
> Signed-off-by: Cosmin Tanislav <cosmin.tanislav@analog.com>
Applied to the togreg branch of iio.git and pushed out as testing
for 0-day to have it's fun
Thanks,
Jonathan
> ---
> drivers/iio/accel/adxl367.c | 46 ++++++++-----------------------------
> 1 file changed, 9 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/iio/accel/adxl367.c b/drivers/iio/accel/adxl367.c
> index 0289ed8cf2c6..72a8c3fb27b9 100644
> --- a/drivers/iio/accel/adxl367.c
> +++ b/drivers/iio/accel/adxl367.c
> @@ -447,21 +447,17 @@ static int adxl367_set_fifo_format(struct adxl367_state *st,
> fifo_format));
> }
>
> -static int adxl367_set_fifo_samples(struct adxl367_state *st,
> - unsigned int fifo_watermark,
> - unsigned int fifo_set_size)
> +static int adxl367_set_fifo_watermark(struct adxl367_state *st,
> + unsigned int fifo_watermark)
> {
> - unsigned int fifo_samples = fifo_watermark * fifo_set_size;
> + unsigned int fifo_samples = fifo_watermark * st->fifo_set_size;
> unsigned int fifo_samples_h, fifo_samples_l;
> int ret;
>
> if (fifo_samples > ADXL367_FIFO_MAX_WATERMARK)
> fifo_samples = ADXL367_FIFO_MAX_WATERMARK;
>
> - if (fifo_set_size == 0)
> - return 0;
> -
> - fifo_samples /= fifo_set_size;
> + fifo_samples /= st->fifo_set_size;
>
> fifo_samples_h = FIELD_PREP(ADXL367_SAMPLES_H_MASK,
> FIELD_GET(ADXL367_SAMPLES_VAL_H_MASK,
> @@ -475,30 +471,8 @@ static int adxl367_set_fifo_samples(struct adxl367_state *st,
> if (ret)
> return ret;
>
> - return regmap_update_bits(st->regmap, ADXL367_REG_FIFO_SAMPLES,
> - ADXL367_SAMPLES_L_MASK, fifo_samples_l);
> -}
> -
> -static int adxl367_set_fifo_set_size(struct adxl367_state *st,
> - unsigned int fifo_set_size)
> -{
> - int ret;
> -
> - ret = adxl367_set_fifo_samples(st, st->fifo_watermark, fifo_set_size);
> - if (ret)
> - return ret;
> -
> - st->fifo_set_size = fifo_set_size;
> -
> - return 0;
> -}
> -
> -static int adxl367_set_fifo_watermark(struct adxl367_state *st,
> - unsigned int fifo_watermark)
> -{
> - int ret;
> -
> - ret = adxl367_set_fifo_samples(st, fifo_watermark, st->fifo_set_size);
> + ret = regmap_update_bits(st->regmap, ADXL367_REG_FIFO_SAMPLES,
> + ADXL367_SAMPLES_L_MASK, fifo_samples_l);
> if (ret)
> return ret;
>
> @@ -1276,14 +1250,11 @@ static int adxl367_update_scan_mode(struct iio_dev *indio_dev,
> {
> struct adxl367_state *st = iio_priv(indio_dev);
> enum adxl367_fifo_format fifo_format;
> - unsigned int fifo_set_size;
> int ret;
>
> if (!adxl367_find_mask_fifo_format(active_scan_mask, &fifo_format))
> return -EINVAL;
>
> - fifo_set_size = bitmap_weight(active_scan_mask, indio_dev->masklength);
> -
> mutex_lock(&st->lock);
>
> ret = adxl367_set_measure_en(st, false);
> @@ -1294,11 +1265,12 @@ static int adxl367_update_scan_mode(struct iio_dev *indio_dev,
> if (ret)
> goto out;
>
> - ret = adxl367_set_fifo_set_size(st, fifo_set_size);
> + ret = adxl367_set_measure_en(st, true);
> if (ret)
> goto out;
>
> - ret = adxl367_set_measure_en(st, true);
> + st->fifo_set_size = bitmap_weight(active_scan_mask,
> + indio_dev->masklength);
>
> out:
> mutex_unlock(&st->lock);
prev parent reply other threads:[~2022-05-22 11:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-14 18:20 [PATCH] iio: accel: adxl367: do not update FIFO watermark on scan mode update Cosmin Tanislav
2022-05-22 11:52 ` Jonathan Cameron [this message]
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=20220522125223.1b310ede@jic23-huawei \
--to=jic23@kernel.org \
--cc=cosmin.tanislav@analog.com \
--cc=demonsingur@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox