From: Jonathan Cameron <jic23@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH 3/4] iio: buffer: Use roundup() instead of open-coding it
Date: Sun, 27 Jul 2014 19:13:30 +0100 [thread overview]
Message-ID: <53D5414A.6080007@kernel.org> (raw)
In-Reply-To: <1405612789-27964-3-git-send-email-lars@metafoo.de>
On 17/07/14 16:59, Lars-Peter Clausen wrote:
> Makes the code slightly shorter and a bit easier to understand.
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Indeed, a sensible cleanup.
Applied to the togreg branch of iio.git
Thanks,
J
> ---
> drivers/iio/industrialio-buffer.c | 16 +++++-----------
> 1 file changed, 5 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
> index 6da5272..5063703 100644
> --- a/drivers/iio/industrialio-buffer.c
> +++ b/drivers/iio/industrialio-buffer.c
> @@ -979,9 +979,7 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev,
> else
> length = ch->scan_type.storagebits / 8;
> /* Make sure we are aligned */
> - in_loc += length;
> - if (in_loc % length)
> - in_loc += length - in_loc % length;
> + in_loc = roundup(in_loc, length) + length;
> }
> p = kmalloc(sizeof(*p), GFP_KERNEL);
> if (p == NULL) {
> @@ -994,10 +992,8 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev,
> ch->scan_type.repeat;
> else
> length = ch->scan_type.storagebits / 8;
> - if (out_loc % length)
> - out_loc += length - out_loc % length;
> - if (in_loc % length)
> - in_loc += length - in_loc % length;
> + out_loc = roundup(out_loc, length);
> + in_loc = roundup(in_loc, length);
> p->from = in_loc;
> p->to = out_loc;
> p->length = length;
> @@ -1019,10 +1015,8 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev,
> ch->scan_type.repeat;
> else
> length = ch->scan_type.storagebits / 8;
> - if (out_loc % length)
> - out_loc += length - out_loc % length;
> - if (in_loc % length)
> - in_loc += length - in_loc % length;
> + out_loc = roundup(out_loc, length);
> + in_loc = roundup(in_loc, length);
> p->from = in_loc;
> p->to = out_loc;
> p->length = length;
>
next prev parent reply other threads:[~2014-07-27 18:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-17 15:59 [PATCH 1/4] iio: buffer: Fix demux table creation Lars-Peter Clausen
2014-07-17 15:59 ` [PATCH 2/4] iio: buffer: Use roundup() instead of ALIGN() Lars-Peter Clausen
2014-07-20 15:08 ` Jonathan Cameron
2014-07-21 8:46 ` Lars-Peter Clausen
2014-07-27 16:45 ` Jonathan Cameron
2014-07-17 15:59 ` [PATCH 3/4] iio: buffer: Use roundup() instead of open-coding it Lars-Peter Clausen
2014-07-27 18:13 ` Jonathan Cameron [this message]
2014-07-17 15:59 ` [PATCH 4/4] iio: buffer: Coalesce adjacent demux table entries Lars-Peter Clausen
2014-07-20 15:14 ` Jonathan Cameron
2014-08-01 17:28 ` Jonathan Cameron
2014-07-20 14:57 ` [PATCH 1/4] iio: buffer: Fix demux table creation 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=53D5414A.6080007@kernel.org \
--to=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@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 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.