staging: comedi: remove use of 'bytes_per_sample()'
This inline helper function has been replaced with comedi_bytes_per_sample().
The same commit (bf33eb4b4f
) 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>
This commit is contained in:
parent
272fe8f51f
commit
c39e050d21
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue