Re: [PATCH] staging: comedi: db_pcidas64: invert conditional

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

 



On Mon, Feb 27, 2017 at 10:46:34AM +0000, Ian Abbott wrote:
> On 27/02/17 06:36, Tobin C. Harding wrote:
> >Checkpatch emits WARNING: Avoid multiple line dereference. It is
> >possible to reduce the level of indentation by inverting a conditional
> >and continuing loop if new conditional evaluates to true.
> >
> >Invert conditional. Continue loop if new conditional evaluates to
> >true. Reduce subsequent code indentation level by 1. Move multi-line
> >dereference onto single line.
> >
> >Signed-off-by: Tobin C. Harding <me@xxxxxxxx>
> >---
> > drivers/staging/comedi/drivers/cb_pcidas64.c | 18 ++++++++----------
> > 1 file changed, 8 insertions(+), 10 deletions(-)
> >
> >diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c
> >index efbf277..b0ca5c8 100644
> >--- a/drivers/staging/comedi/drivers/cb_pcidas64.c
> >+++ b/drivers/staging/comedi/drivers/cb_pcidas64.c
> >@@ -1497,16 +1497,14 @@ static int alloc_and_init_dma_members(struct comedi_device *dev)
> > 			return -ENOMEM;
> > 	}
> > 	for (i = 0; i < AO_DMA_RING_COUNT; i++) {
> >-		if (ao_cmd_is_supported(board)) {
> >-			devpriv->ao_buffer[i] =
> >-				dma_alloc_coherent(&pcidev->dev,
> >-						   DMA_BUFFER_SIZE,
> >-						   &devpriv->
> >-						   ao_buffer_bus_addr[i],
> >-						   GFP_KERNEL);
> >-			if (!devpriv->ao_buffer[i])
> >-				return -ENOMEM;
> >-		}
> >+		if (!ao_cmd_is_supported(board))
> >+			continue;
> >+		devpriv->ao_buffer[i] =
> >+			dma_alloc_coherent(&pcidev->dev, DMA_BUFFER_SIZE,
> >+					&devpriv->ao_buffer_bus_addr[i],
> >+					GFP_KERNEL);
> >+		if (!devpriv->ao_buffer[i])
> >+			return -ENOMEM;
> > 	}
> > 	/* allocate dma descriptors */
> > 	devpriv->ai_dma_desc =
> >
> 
> There is a typo on the patch subject line.  Apart from that, the patch seems
> okay.  Ideally, the function should be rearranged and/or refactored into
> smaller functions, since the 'if (ao_cmd_is_supported(board))' test is
> loop-invariant, but that can be done with other patches.

Oh nice, thanks for the tip. V2 to follow, with the correct driver
name.

thanks,
Tobin.
_______________________________________________
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