linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@jic23.retrosnub.co.uk>
To: Martin Kelly <mkelly@xevo.com>
Cc: linux-iio@vger.kernel.org,
	Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Subject: Re: [PATCH 2/2] iio: imu: inv_mpu6050: make loop a do-while
Date: Sun, 6 May 2018 18:08:16 +0100	[thread overview]
Message-ID: <20180506180816.4c15b826@archlinux> (raw)
In-Reply-To: <20180501175642.8551-3-mkelly@xevo.com>

On Tue,  1 May 2018 10:56:42 -0700
Martin Kelly <mkelly@xevo.com> wrote:

> Prior to this loop, we check if fifo_count < bytes_per_datum and bail if
> so. This means that when we hit the loop, we know that fifo_count >=
> bytes_per_datum, so the check is unneeded and we can turn the loop into
> a do-while for a slight performance improvement.
> 
> Signed-off-by: Martin Kelly <mkelly@xevo.com>
Seems logical to me, but I'd like to give Jean-Baptiste a chance
to comment on this one.

If it looks like we have forgotten about it in a week or so do
give me a poke!

Thanks,

Jonathan

> ---
>  drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
> index 0cb7c20100ca..11593deaaebd 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
> @@ -174,7 +174,7 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)
>  	if (kfifo_len(&st->timestamps) >
>  	    fifo_count / bytes_per_datum + INV_MPU6050_TIME_STAMP_TOR)
>  		goto flush_fifo;
> -	while (fifo_count >= bytes_per_datum) {
> +	do {
>  		result = regmap_bulk_read(st->map, st->reg->fifo_r_w,
>  					  data, bytes_per_datum);
>  		if (result)
> @@ -188,7 +188,7 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)
>  		iio_push_to_buffers_with_timestamp(indio_dev, data, timestamp);
>  
>  		fifo_count -= bytes_per_datum;
> -	}
> +	} while (fifo_count >= bytes_per_datum);
>  
>  end_session:
>  	mutex_unlock(&st->lock);


  reply	other threads:[~2018-05-06 17:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-01 17:56 [PATCH 0/2] inv_mpu6050 minor cleanup Martin Kelly
2018-05-01 17:56 ` [PATCH 1/2] iio: imu: inv_mpu6050: minor wording fixes Martin Kelly
2018-05-06 17:06   ` Jonathan Cameron
2018-05-01 17:56 ` [PATCH 2/2] iio: imu: inv_mpu6050: make loop a do-while Martin Kelly
2018-05-06 17:08   ` Jonathan Cameron [this message]
2018-05-08 14:34     ` Jean-Baptiste Maneyrol
2018-05-12  9:04       ` Jonathan Cameron
2018-05-14  7:36         ` Jean-Baptiste Maneyrol
2018-05-14 18:38           ` Jonathan Cameron

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=20180506180816.4c15b826@archlinux \
    --to=jic23@jic23.retrosnub.co.uk \
    --cc=jmaneyrol@invensense.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=mkelly@xevo.com \
    /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;
as well as URLs for NNTP newsgroup(s).