提交 61072dbc 编写于 作者: L Lars-Peter Clausen 提交者: Jonathan Cameron

iio: buffer: Use roundup() instead of open-coding it

Makes the code slightly shorter and a bit easier to understand.
Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: NJonathan Cameron <jic23@kernel.org>
上级 7ddebf54
...@@ -979,9 +979,7 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev, ...@@ -979,9 +979,7 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev,
else else
length = ch->scan_type.storagebits / 8; length = ch->scan_type.storagebits / 8;
/* Make sure we are aligned */ /* Make sure we are aligned */
in_loc += length; in_loc = roundup(in_loc, length) + length;
if (in_loc % length)
in_loc += length - in_loc % length;
} }
p = kmalloc(sizeof(*p), GFP_KERNEL); p = kmalloc(sizeof(*p), GFP_KERNEL);
if (p == NULL) { if (p == NULL) {
...@@ -994,10 +992,8 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev, ...@@ -994,10 +992,8 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev,
ch->scan_type.repeat; ch->scan_type.repeat;
else else
length = ch->scan_type.storagebits / 8; length = ch->scan_type.storagebits / 8;
if (out_loc % length) out_loc = roundup(out_loc, length);
out_loc += length - out_loc % length; in_loc = roundup(in_loc, length);
if (in_loc % length)
in_loc += length - in_loc % length;
p->from = in_loc; p->from = in_loc;
p->to = out_loc; p->to = out_loc;
p->length = length; p->length = length;
...@@ -1019,10 +1015,8 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev, ...@@ -1019,10 +1015,8 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev,
ch->scan_type.repeat; ch->scan_type.repeat;
else else
length = ch->scan_type.storagebits / 8; length = ch->scan_type.storagebits / 8;
if (out_loc % length) out_loc = roundup(out_loc, length);
out_loc += length - out_loc % length; in_loc = roundup(in_loc, length);
if (in_loc % length)
in_loc += length - in_loc % length;
p->from = in_loc; p->from = in_loc;
p->to = out_loc; p->to = out_loc;
p->length = length; p->length = length;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册