Use the helper function to calculate the number of samples in the DMA
buffer. For aesthetics, tidy up the local variables.

Signed-off-by: H Hartley Sweeten <hswee...@visionengravers.com>
Cc: Ian Abbott <abbo...@mev.co.uk>
Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index f18622c..c600871 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -12,20 +12,21 @@ static void apci3120_interrupt_dma(int irq, void *d)
        struct comedi_async *async = s->async;
        struct comedi_cmd *cmd = &async->cmd;
        struct apci3120_dmabuf *dmabuf;
-       unsigned int samplesinbuf;
+       unsigned int nbytes;
+       unsigned int nsamples;
 
        dmabuf = &devpriv->dmabuf[devpriv->cur_dmabuf];
 
-       samplesinbuf = dmabuf->use_size - inl(devpriv->amcc + AMCC_OP_REG_MWTC);
+       nbytes = dmabuf->use_size - inl(devpriv->amcc + AMCC_OP_REG_MWTC);
 
-       if (samplesinbuf < dmabuf->use_size)
+       if (nbytes < dmabuf->use_size)
                dev_err(dev->class_dev, "Interrupted DMA transfer!\n");
-       if (samplesinbuf & 1) {
+       if (nbytes & 1) {
                dev_err(dev->class_dev, "Odd count of bytes in DMA ring!\n");
                async->events |= COMEDI_CB_ERROR;
                return;
        }
-       samplesinbuf = samplesinbuf >> 1;       /*  number of received samples 
*/
+       nsamples = comedi_bytes_to_samples(s, nbytes);
 
        if (devpriv->use_double_buffer) {
                struct apci3120_dmabuf *next_dmabuf;
@@ -36,8 +37,8 @@ static void apci3120_interrupt_dma(int irq, void *d)
                apci3120_init_dma(dev, next_dmabuf);
        }
 
-       if (samplesinbuf) {
-               comedi_buf_write_samples(s, dmabuf->virt, samplesinbuf);
+       if (nsamples) {
+               comedi_buf_write_samples(s, dmabuf->virt, nsamples);
 
                if (!(cmd->flags & CMDF_WAKE_EOS))
                        async->events |= COMEDI_CB_EOS;
-- 
2.0.3

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

Reply via email to