staging: comedi: addi_apci_3120: simplify setting of devpriv->us_UseDma
authorIan Abbott <abbotti@mev.co.uk>
Fri, 12 Sep 2014 11:19:57 +0000 (12:19 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 19 Sep 2014 22:39:39 +0000 (15:39 -0700)
`apci3120_auto_attach()` first sets `devpriv->us_UseDma` to 1, then sets
it back to 0 if it fails to allocate the DMA buffer.  Since `*devpriv`
is initially zeroed out by `comedi_alloc_devpriv()`, change it to only
set `devpriv->us_UseDma` to 1 if the allocation succeeds.  Also, don't
bother explicitly initializing `devpriv->b_DmaDoubleBuffer` to 0 as it
is already zeroed out.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/addi_apci_3120.c

index 1025541fb4a3b1a78f08452bdbbb910d5affbb54..ba71e24a56fd1c6671b3720bf8375f1f0eb7f7a7 100644 (file)
@@ -88,10 +88,7 @@ static int apci3120_auto_attach(struct comedi_device *dev,
                        dev->irq = pcidev->irq;
        }
 
-       devpriv->us_UseDma = 1;
-
        /* Allocate DMA buffers */
-       devpriv->b_DmaDoubleBuffer = 0;
        for (i = 0; i < 2; i++) {
                for (order = 2; order >= 0; order--) {
                        devpriv->ul_DmaBufferVirtual[i] =
@@ -106,8 +103,8 @@ static int apci3120_auto_attach(struct comedi_device *dev,
                        break;
                devpriv->ui_DmaBufferSize[i] = PAGE_SIZE << order;
        }
-       if (!devpriv->ul_DmaBufferVirtual[0])
-               devpriv->us_UseDma = 0;
+       if (devpriv->ul_DmaBufferVirtual[0])
+               devpriv->us_UseDma = 1;
 
        if (devpriv->ul_DmaBufferVirtual[1])
                devpriv->b_DmaDoubleBuffer = 1;