summaryrefslogtreecommitdiffstats
path: root/drivers/iio/industrialio-buffer.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-07-17 17:59:00 +0200
committerJonathan Cameron <jic23@kernel.org>2014-07-27 20:13:08 +0200
commit61072dbc8a017039059ec0e94548e4ba31602893 (patch)
tree586380c6835dba92acf05ec8273f0143227976b6 /drivers/iio/industrialio-buffer.c
parentstaging: iio: ad5933: fix sparse warnings (diff)
downloadlinux-61072dbc8a017039059ec0e94548e4ba31602893.tar.xz
linux-61072dbc8a017039059ec0e94548e4ba31602893.zip
iio: buffer: Use roundup() instead of open-coding it
Makes the code slightly shorter and a bit easier to understand. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/industrialio-buffer.c')
-rw-r--r--drivers/iio/industrialio-buffer.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 2952ee038477..7462f1233974 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;