]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: comedi: das1800: separate AI FIFO bounce buffer from DMA buffer
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 12 Jan 2015 17:55:41 +0000 (10:55 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 17 Jan 2015 22:25:18 +0000 (14:25 -0800)
This driver can use DMA or the hardware FIFO to read analog input samples.
When DMA is enabled it's also possible for some async commands to cause
DMA to be disabled and the FIFO is used instead.

Currently the first DMA channels buffer is used for the bounce buffer
when using the FIFO. For aesthetics, add a new member to the private
data and use that for the FIFO bounce buffer.

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

index c415b578f5fbb5fb6e9c0a0e9609a0d6fab049bc..2e087b1b8ce1be6ff1d387bd1e6e4e5d3206bf46 100644 (file)
@@ -433,6 +433,7 @@ struct das1800_private {
        uint16_t *ai_buf0;      /* pointers to dma buffers */
        uint16_t *ai_buf1;
        uint16_t *dma_current_buf;      /* pointer to dma buffer currently being used */
+       uint16_t *fifo_buf;     /* bounce buffer for analog input FIFO */
        unsigned int dma_transfer_size; /* size of transfer currently used, in bytes */
        unsigned long iobase2;  /* secondary io address used for analog out on 'ao' boards */
        unsigned short ao_update_bits;  /* remembers the last write to the
@@ -480,9 +481,9 @@ static void das1800_handle_fifo_half_full(struct comedi_device *dev,
        struct das1800_private *devpriv = dev->private;
        unsigned int nsamples = comedi_nsamples_left(s, FIFO_SIZE / 2);
 
-       insw(dev->iobase + DAS1800_FIFO, devpriv->ai_buf0, nsamples);
-       munge_data(dev, devpriv->ai_buf0, nsamples);
-       comedi_buf_write_samples(s, devpriv->ai_buf0, nsamples);
+       insw(dev->iobase + DAS1800_FIFO, devpriv->fifo_buf, nsamples);
+       munge_data(dev, devpriv->fifo_buf, nsamples);
+       comedi_buf_write_samples(s, devpriv->fifo_buf, nsamples);
 }
 
 static void das1800_handle_fifo_not_empty(struct comedi_device *dev,
@@ -1442,12 +1443,9 @@ static int das1800_attach(struct comedi_device *dev,
                        return ret;
        }
 
-       if (devpriv->ai_buf0 == NULL) {
-               devpriv->ai_buf0 =
-                   kmalloc(FIFO_SIZE * sizeof(uint16_t), GFP_KERNEL);
-               if (devpriv->ai_buf0 == NULL)
-                       return -ENOMEM;
-       }
+       devpriv->fifo_buf = kmalloc(FIFO_SIZE * sizeof(uint16_t), GFP_KERNEL);
+       if (!devpriv->fifo_buf)
+               return -ENOMEM;
 
        ret = comedi_alloc_subdevices(dev, 4);
        if (ret)
@@ -1531,6 +1529,7 @@ static void das1800_detach(struct comedi_device *dev)
                        free_dma(devpriv->dma1);
                kfree(devpriv->ai_buf0);
                kfree(devpriv->ai_buf1);
+               kfree(devpriv->fifo_buf);
                if (devpriv->iobase2)
                        release_region(devpriv->iobase2, DAS1800_SIZE);
        }