staging: comedi: remove use of 'bytes_per_sample()'
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Fri, 31 Oct 2014 19:04:28 +0000 (12:04 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 4 Nov 2014 00:34:17 +0000 (16:34 -0800)
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>
drivers/staging/comedi/comedi_buf.c
drivers/staging/comedi/comedi_fops.c
drivers/staging/comedi/comedidev.h
drivers/staging/comedi/drivers.c
drivers/staging/comedi/drivers/cb_pcidas.c
drivers/staging/comedi/drivers/cb_pcidas64.c
drivers/staging/comedi/drivers/das16.c
drivers/staging/comedi/drivers/dt282x.c
drivers/staging/comedi/drivers/ni_mio_common.c
drivers/staging/comedi/drivers/usbduxfast.c

index b43424d611ad7ca3154b404b33541155fdee128a..eb3fecf85b6d1cfcc2f9fdc412ddb094f4483d94 100644 (file)
@@ -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);
index 704ae25c5710802404e0d8ff5053f1b69aa265a6..65894fd8b67b724a0637914b8c22a7e84672251d 100644 (file)
@@ -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);
index d18f70203422b2334e8cd6db6e7652d853de9122..90af11aaef7e8cfcf457b11537604dc56692964f 100644 (file)
@@ -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
index 9c55dc759af8cddd4bef0057d8115139f3caa963..9a8c5fc8e8fe3163db42bc551d9a0030e39ec38a 100644 (file)
@@ -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);
 
index 53afae093c4cf2e0438d8353f4a71834668b0c3b..1c38cd5f846c2595a32c16af82836d133846a6c6 100644 (file)
@@ -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;
 
index c8515d7f249bcee6abbcb8290332c8ab25fdc2c3..d7b61ba6b284c89819eac0e8482c9288a540de31 100644 (file)
@@ -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);
index 8e512b2416538988f9e3b0945e07139455746c71..26f54aa9d41c01ed510ecc3bab026fab3525f612 100644 (file)
@@ -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);
 
index 1d9fa371d03c94c5e1be9a74b792d9f1b5f262d1..674e03eb16014474c160ad9f9ecaa64130d3f5e7 100644 (file)
@@ -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,
index 2dfd95126fa38cfe13ab54597df4c5a9c15363db..63312ff42b35ab68b7dfe3d9bd70b62bda81dae0 100644 (file)
@@ -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];
 
index 3bc9013006a0b9c39e555a4bedb8a43cf861bbbf..5de76aba8fd9ae36ef5da050a4a6943015c2f720 100644 (file)
@@ -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;