Merge 5.5-rc7 into staging-next
[linux-2.6-microblaze.git] / drivers / iio / industrialio-buffer.c
index dbbf0cf..4ada559 100644 (file)
@@ -566,7 +566,7 @@ static int iio_compute_scan_bytes(struct iio_dev *indio_dev,
                                const unsigned long *mask, bool timestamp)
 {
        unsigned bytes = 0;
-       int length, i;
+       int length, i, largest = 0;
 
        /* How much space will the demuxed element take? */
        for_each_set_bit(i, mask,
@@ -574,13 +574,17 @@ static int iio_compute_scan_bytes(struct iio_dev *indio_dev,
                length = iio_storage_bytes_for_si(indio_dev, i);
                bytes = ALIGN(bytes, length);
                bytes += length;
+               largest = max(largest, length);
        }
 
        if (timestamp) {
                length = iio_storage_bytes_for_timestamp(indio_dev);
                bytes = ALIGN(bytes, length);
                bytes += length;
+               largest = max(largest, length);
        }
+
+       bytes = ALIGN(bytes, largest);
        return bytes;
 }