diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2014-10-31 19:04:28 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-11-04 00:34:17 (GMT) |
commit | c39e050d21d107d26183be0f22b89eccccdbe61c (patch) | |
tree | 968e6e76a074f75380f7e28e7f5306f42740e1ac | |
parent | 272fe8f51fd8b8cd1637c8d2ca868cbff725405e (diff) | |
download | linux-c39e050d21d107d26183be0f22b89eccccdbe61c.tar.xz |
staging: comedi: remove use of 'bytes_per_sample()'
This inline helper function has been replaced with comedi_bytes_per_sample().
The same commit (bf33eb4b4f57) introduced a couple other related helper
functions a manipulate the sample size.
Use the new helper functions to remove the use of 'bytes_per_sample()' and
remove it.
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>
-rw-r--r-- | drivers/staging/comedi/comedi_buf.c | 14 | ||||
-rw-r--r-- | drivers/staging/comedi/comedi_fops.c | 2 | ||||
-rw-r--r-- | drivers/staging/comedi/comedidev.h | 6 | ||||
-rw-r--r-- | drivers/staging/comedi/drivers.c | 4 | ||||
-rw-r--r-- | drivers/staging/comedi/drivers/cb_pcidas.c | 2 | ||||
-rw-r--r-- | drivers/staging/comedi/drivers/cb_pcidas64.c | 6 | ||||
-rw-r--r-- | drivers/staging/comedi/drivers/das16.c | 2 | ||||
-rw-r--r-- | drivers/staging/comedi/drivers/dt282x.c | 4 | ||||
-rw-r--r-- | drivers/staging/comedi/drivers/ni_mio_common.c | 8 | ||||
-rw-r--r-- | drivers/staging/comedi/drivers/usbduxfast.c | 4 |
10 files changed, 25 insertions, 27 deletions
diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index b43424d..eb3fecf 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -283,7 +283,7 @@ static unsigned int comedi_buf_munge(struct comedi_subdevice *s, { struct comedi_async *async = s->async; unsigned int count = 0; - const unsigned num_sample_bytes = bytes_per_sample(s); + const unsigned num_sample_bytes = comedi_bytes_per_sample(s); if (!s->munge || (async->cmd.flags & CMDF_RAWDATA)) { async->munge_count += num_bytes; @@ -489,7 +489,8 @@ unsigned int comedi_buf_write_samples(struct comedi_subdevice *s, * If not, clamp the nsamples to the number that will fit, flag the * buffer overrun and add the samples that fit. */ - max_samples = comedi_buf_write_n_available(s) / bytes_per_sample(s); + max_samples = comedi_bytes_to_samples(s, + comedi_buf_write_n_available(s)); if (nsamples > max_samples) { dev_warn(s->device->class_dev, "buffer overrun\n"); s->async->events |= COMEDI_CB_OVERFLOW; @@ -499,7 +500,8 @@ unsigned int comedi_buf_write_samples(struct comedi_subdevice *s, if (nsamples == 0) return 0; - nbytes = comedi_buf_write_alloc(s, nsamples * bytes_per_sample(s)); + nbytes = comedi_buf_write_alloc(s, + comedi_samples_to_bytes(s, nsamples)); comedi_buf_memcpy_to(s, data, nbytes); comedi_buf_write_free(s, nbytes); comedi_inc_scan_progress(s, nbytes); @@ -527,14 +529,16 @@ unsigned int comedi_buf_read_samples(struct comedi_subdevice *s, unsigned int nbytes; /* clamp nsamples to the number of full samples available */ - max_samples = comedi_buf_read_n_available(s) / bytes_per_sample(s); + max_samples = comedi_bytes_to_samples(s, + comedi_buf_read_n_available(s)); if (nsamples > max_samples) nsamples = max_samples; if (nsamples == 0) return 0; - nbytes = comedi_buf_read_alloc(s, nsamples * bytes_per_sample(s)); + nbytes = comedi_buf_read_alloc(s, + comedi_samples_to_bytes(s, nsamples)); comedi_buf_memcpy_from(s, data, nbytes); comedi_buf_read_free(s, nbytes); comedi_inc_scan_progress(s, nbytes); diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 704ae25..65894fd 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2024,7 +2024,7 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait) s = comedi_write_subdevice(dev, minor); if (s && s->async) { - unsigned int bps = bytes_per_sample(s); + unsigned int bps = comedi_bytes_per_sample(s); poll_wait(file, &s->async->wait_head, wait); comedi_buf_write_alloc(s, s->async->prealloc_bufsz); diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index d18f702..90af11a 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -427,12 +427,6 @@ static inline unsigned int comedi_bytes_per_sample(struct comedi_subdevice *s) return s->subdev_flags & SDF_LSAMPL ? sizeof(int) : sizeof(short); } -/* to be removed */ -static inline unsigned int bytes_per_sample(struct comedi_subdevice *s) -{ - return comedi_bytes_per_sample(s); -} - /** * comedi_sample_shift - determine log2 of subdevice sample size * @s: comedi_subdevice struct diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 9c55dc7..9a8c5fc 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -316,14 +316,14 @@ unsigned int comedi_bytes_per_scan(struct comedi_subdevice *s) case COMEDI_SUBD_DI: case COMEDI_SUBD_DO: case COMEDI_SUBD_DIO: - bits_per_sample = 8 * bytes_per_sample(s); + bits_per_sample = 8 * comedi_bytes_per_sample(s); num_samples = DIV_ROUND_UP(cmd->chanlist_len, bits_per_sample); break; default: num_samples = cmd->chanlist_len; break; } - return num_samples * bytes_per_sample(s); + return comedi_samples_to_bytes(s, num_samples); } EXPORT_SYMBOL_GPL(comedi_bytes_per_scan); diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 53afae093..1c38cd5 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -1146,7 +1146,7 @@ static void cb_pcidas_ao_load_fifo(struct comedi_device *dev, nsamples = devpriv->ao_count; nbytes = comedi_buf_read_samples(s, devpriv->ao_buffer, nsamples); - nsamples = nbytes / bytes_per_sample(s); + nsamples = comedi_bytes_to_samples(s, nbytes); if (cmd->stop_src == TRIG_COUNT) devpriv->ao_count -= nsamples; diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index c8515d7..d7b61ba 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -2923,14 +2923,14 @@ static unsigned int cb_pcidas64_ao_fill_buffer(struct comedi_device *dev, { struct pcidas64_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - unsigned int nsamples = max_bytes / bytes_per_sample(s); + unsigned int nsamples = comedi_bytes_to_samples(s, max_bytes); unsigned int actual_bytes; if (cmd->stop_src == TRIG_COUNT && devpriv->ao_count < nsamples) nsamples = devpriv->ao_count; actual_bytes = comedi_buf_read_samples(s, dest, nsamples); - nsamples = actual_bytes / bytes_per_sample(s); + nsamples = comedi_bytes_to_samples(s, actual_bytes); if (cmd->stop_src == TRIG_COUNT) devpriv->ao_count -= nsamples; @@ -2954,7 +2954,7 @@ static unsigned int load_ao_dma_buffer(struct comedi_device *dev, if (nsamples == 0) return 0; - nbytes = nsamples * bytes_per_sample(s); + nbytes = comedi_samples_to_bytes(s, nsamples); devpriv->ao_dma_desc[buffer_index].transfer_size = cpu_to_le32(nbytes); /* set end of chain bit so we catch underruns */ next_bits = le32_to_cpu(devpriv->ao_dma_desc[buffer_index].next); diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 8e512b2..26f54aa 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -584,7 +584,7 @@ static void das16_interrupt(struct comedi_device *dev) spin_unlock_irqrestore(&dev->spinlock, spin_flags); - nsamples = num_bytes / bytes_per_sample(s); + nsamples = comedi_bytes_to_samples(s, num_bytes); comedi_buf_write_samples(s, devpriv->dma_buffer[buffer_index], nsamples); diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 1d9fa37..674e03e 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -455,7 +455,7 @@ static unsigned int dt282x_ao_setup_dma(struct comedi_device *dev, { struct dt282x_private *devpriv = dev->private; void *ptr = devpriv->dma[cur_dma].buf; - unsigned int nsamples = devpriv->dma_maxsize / bytes_per_sample(s); + unsigned int nsamples = comedi_bytes_to_samples(s, devpriv->dma_maxsize); unsigned int nbytes; nbytes = comedi_buf_read_samples(s, ptr, nsamples); @@ -491,7 +491,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev, int cur_dma = devpriv->current_dma_index; void *ptr = devpriv->dma[cur_dma].buf; int size = devpriv->dma[cur_dma].size; - unsigned int nsamples = size / bytes_per_sample(s); + unsigned int nsamples = comedi_bytes_to_samples(s, size); int ret; outw(devpriv->supcsr | DT2821_SUPCSR_CLRDMADNE, diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 2dfd951..63312ff 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1618,12 +1618,12 @@ static void ni_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s, struct ni_private *devpriv = dev->private; struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; - unsigned int length = num_bytes / bytes_per_sample(s); + unsigned int nsamples = comedi_bytes_to_samples(s, num_bytes); unsigned short *array = data; unsigned int *larray = data; unsigned int i; - for (i = 0; i < length; i++) { + for (i = 0; i < nsamples; i++) { #ifdef PCIDMA if (s->subdev_flags & SDF_LSAMPL) larray[i] = le32_to_cpu(larray[i]); @@ -2732,11 +2732,11 @@ static void ni_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int chan_index) { struct comedi_cmd *cmd = &s->async->cmd; - unsigned int length = num_bytes / bytes_per_sample(s); + unsigned int nsamples = comedi_bytes_to_samples(s, num_bytes); unsigned short *array = data; unsigned int i; - for (i = 0; i < length; i++) { + for (i = 0; i < nsamples; i++) { unsigned int range = CR_RANGE(cmd->chanlist[chan_index]); unsigned short val = array[i]; diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c index 3bc9013..5de76ab 100644 --- a/drivers/staging/comedi/drivers/usbduxfast.c +++ b/drivers/staging/comedi/drivers/usbduxfast.c @@ -248,9 +248,9 @@ static void usbduxfast_ai_handle_urb(struct comedi_device *dev, if (devpriv->ignore) { devpriv->ignore--; } else { - unsigned int nbytes = urb->actual_length; - unsigned int nsamples = nbytes / bytes_per_sample(s); + unsigned int nsamples; + nsamples = comedi_bytes_to_samples(s, urb->actual_length); if (cmd->stop_src == TRIG_COUNT) { if (devpriv->ai_sample_count < nsamples) { nsamples = devpriv->ai_sample_count; |