Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: buffer-dma: Use ARRAY_SIZE in for loop range

Use the ARRAY_SIZE macro in the for loops that access queue->fileio.blocks.
Macro is already used in a couple of places where this access occurs,
but range was hardcoded in these locations.

Signed-off-by: Phil Reid <preid@electromag.com.au>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Phil Reid and committed by
Jonathan Cameron
29e3e06d c48c7b2e

+2 -2
+2 -2
drivers/iio/buffer/industrialio-buffer-dma.c
··· 305 305 queue->fileio.active_block = NULL; 306 306 307 307 spin_lock_irq(&queue->list_lock); 308 - for (i = 0; i < 2; i++) { 308 + for (i = 0; i < ARRAY_SIZE(queue->fileio.blocks); i++) { 309 309 block = queue->fileio.blocks[i]; 310 310 311 311 /* If we can't re-use it free it */ ··· 323 323 324 324 INIT_LIST_HEAD(&queue->incoming); 325 325 326 - for (i = 0; i < 2; i++) { 326 + for (i = 0; i < ARRAY_SIZE(queue->fileio.blocks); i++) { 327 327 if (queue->fileio.blocks[i]) { 328 328 block = queue->fileio.blocks[i]; 329 329 if (block->state == IIO_BLOCK_STATE_DEAD) {