[PATCH] staging: comedi: cb_pcidas64: move loop invariant

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Loop invariant is inside the loop so code checks invariant on each
iteration of the loop. Invariant can be moved outside of the loop so
it is only checked once.

Move loop invariant outside of for loop.

Signed-off-by: Tobin C. Harding <me@xxxxxxxx>
---
 drivers/staging/comedi/drivers/cb_pcidas64.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c
index 3b98193..dff0648 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas64.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas64.c
@@ -1496,8 +1496,8 @@ static int alloc_and_init_dma_members(struct comedi_device *dev)
 		if (!devpriv->ai_buffer[i])
 			return -ENOMEM;
 	}
-	for (i = 0; i < AO_DMA_RING_COUNT; i++) {
-		if (ao_cmd_is_supported(board)) {
+	if (ao_cmd_is_supported(board)) {
+		for (i = 0; i < AO_DMA_RING_COUNT; i++) {
 			devpriv->ao_buffer[i] =
 				dma_alloc_coherent(&pcidev->dev,
 						   DMA_BUFFER_SIZE,
-- 
2.7.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux