staging: comedi: adv_pci1710: use sample manipulation helpers
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Fri, 31 Oct 2014 19:04:32 +0000 (12:04 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 4 Nov 2014 00:34:17 +0000 (16:34 -0800)
Use the recently added sample manipulation helpers to remove the hardcoded
assumption of the sample size.

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/adv_pci1710.c

index 420554f79b02e26f09f0cb8c6bf387efa20a42e0..107a0f137eaf303628c4a4c0d8c88dcab023dffc 100644 (file)
@@ -823,7 +823,8 @@ static void pci1710_handle_fifo(struct comedi_device *dev,
        const struct boardtype *this_board = dev->board_ptr;
        struct pci1710_private *devpriv = dev->private;
        struct comedi_cmd *cmd = &s->async->cmd;
-       int m, samplesinbuf;
+       unsigned int nsamples;
+       unsigned int m;
 
        m = inw(dev->iobase + PCI171x_STATUS);
        if (!(m & Status_FH)) {
@@ -840,16 +841,16 @@ static void pci1710_handle_fifo(struct comedi_device *dev,
                return;
        }
 
-       samplesinbuf = this_board->fifo_half_size;
-       if (samplesinbuf * sizeof(short) >= s->async->prealloc_bufsz) {
-               m = s->async->prealloc_bufsz / sizeof(short);
+       nsamples = this_board->fifo_half_size;
+       if (comedi_samples_to_bytes(s, nsamples) >= s->async->prealloc_bufsz) {
+               m = comedi_bytes_to_samples(s, s->async->prealloc_bufsz);
                if (move_block_from_fifo(dev, s, m, 0))
                        return;
-               samplesinbuf -= m;
+               nsamples -= m;
        }
 
-       if (samplesinbuf) {
-               if (move_block_from_fifo(dev, s, samplesinbuf, 1))
+       if (nsamples) {
+               if (move_block_from_fifo(dev, s, nsamples, 1))
                        return;
        }