aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-07-17 11:59:00 -0400
committerJonathan Cameron <jic23@kernel.org>2014-07-27 14:13:08 -0400
commit61072dbc8a017039059ec0e94548e4ba31602893 (patch)
tree586380c6835dba92acf05ec8273f0143227976b6
parent7ddebf54292052898dd0cf3925d113e3527608a7 (diff)
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>
-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,
979 else 979 else
980 length = ch->scan_type.storagebits / 8; 980 length = ch->scan_type.storagebits / 8;
981 /* Make sure we are aligned */ 981 /* Make sure we are aligned */
982 in_loc += length; 982 in_loc = roundup(in_loc, length) + length;
983 if (in_loc % length)
984 in_loc += length - in_loc % length;
985 } 983 }
986 p = kmalloc(sizeof(*p), GFP_KERNEL); 984 p = kmalloc(sizeof(*p), GFP_KERNEL);
987 if (p == NULL) { 985 if (p == NULL) {
@@ -994,10 +992,8 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev,
994 ch->scan_type.repeat; 992 ch->scan_type.repeat;
995 else 993 else
996 length = ch->scan_type.storagebits / 8; 994 length = ch->scan_type.storagebits / 8;
997 if (out_loc % length) 995 out_loc = roundup(out_loc, length);
998 out_loc += length - out_loc % length; 996 in_loc = roundup(in_loc, length);
999 if (in_loc % length)
1000 in_loc += length - in_loc % length;
1001 p->from = in_loc; 997 p->from = in_loc;
1002 p->to = out_loc; 998 p->to = out_loc;
1003 p->length = length; 999 p->length = length;
@@ -1019,10 +1015,8 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev,
1019 ch->scan_type.repeat; 1015 ch->scan_type.repeat;
1020 else 1016 else
1021 length = ch->scan_type.storagebits / 8; 1017 length = ch->scan_type.storagebits / 8;
1022 if (out_loc % length) 1018 out_loc = roundup(out_loc, length);
1023 out_loc += length - out_loc % length; 1019 in_loc = roundup(in_loc, length);
1024 if (in_loc % length)
1025 in_loc += length - in_loc % length;
1026 p->from = in_loc; 1020 p->from = in_loc;
1027 p->to = out_loc; 1021 p->to = out_loc;
1028 p->length = length; 1022 p->length = length;