From: H Hartley Sweeten Date: Fri, 31 Oct 2014 19:04:32 +0000 (-0700) Subject: staging: comedi: adv_pci1710: use sample manipulation helpers X-Git-Tag: firefly_0821_release~176^2~2665^2~455 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b7f9eb054994dbbceb40d376ad6f5701d9d31b4d;p=firefly-linux-kernel-4.4.55.git staging: comedi: adv_pci1710: use sample manipulation helpers Use the recently added sample manipulation helpers to remove the hardcoded assumption of the sample size. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 420554f79b02..107a0f137eaf 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -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; }