mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
iio: buffer: ensure repeat alignment is a power of two
Use roundup_pow_of_two() in the calculation of iio_storage_bytes_for_si() when scan_type->repeat > 1 to ensure that the size is a power of two. storagebits is always going to be a power of two bytes, so we only need to apply this to the repeat factor. The storage size is also used for alignment, and we want to ensure that all alignments are a power of two. The only repeat in use in the kernel currently is for quaternions, which have a repeat of 4, so this does not change the result for existing users. Signed-off-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
cb27d8c18f
commit
9957725014
|
|
@ -750,7 +750,7 @@ static int iio_storage_bytes_for_si(struct iio_dev *indio_dev,
|
|||
bytes = scan_type->storagebits / 8;
|
||||
|
||||
if (scan_type->repeat > 1)
|
||||
bytes *= scan_type->repeat;
|
||||
bytes *= roundup_pow_of_two(scan_type->repeat);
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user