From 24e894bbf247ecdeed3ed2f77f658da756760f60 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 6 May 2014 13:12:04 +0100 Subject: staging: comedi: pass subdevice to comedi_buf_write_alloc() Change the parameters of `comedi_buf_write_alloc()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 4 ++-- drivers/staging/comedi/comedi_fops.c | 6 +++--- drivers/staging/comedi/comedidev.h | 2 +- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c | 3 +-- drivers/staging/comedi/drivers/comedi_fc.c | 2 +- drivers/staging/comedi/drivers/mite.c | 2 +- drivers/staging/comedi/drivers/ni_mio_common.c | 2 +- drivers/staging/comedi/drivers/ni_pcidio.c | 2 +- drivers/staging/comedi/drivers/ni_tiocmd.c | 2 +- 9 files changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index 199ebb48974c..6a655008655f 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -269,10 +269,10 @@ static unsigned int __comedi_buf_write_alloc(struct comedi_async *async, } /* allocates chunk for the writer from free buffer space */ -unsigned int comedi_buf_write_alloc(struct comedi_async *async, +unsigned int comedi_buf_write_alloc(struct comedi_subdevice *s, unsigned int nbytes) { - return __comedi_buf_write_alloc(async, nbytes, 0); + return __comedi_buf_write_alloc(s->async, nbytes, 0); } EXPORT_SYMBOL_GPL(comedi_buf_write_alloc); diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 0affd1f96660..58c1f6e18d27 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1004,7 +1004,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev, if (bi.bytes_written && (s->subdev_flags & SDF_CMD_WRITE)) { bi.bytes_written = - comedi_buf_write_alloc(async, bi.bytes_written); + comedi_buf_write_alloc(s, bi.bytes_written); comedi_buf_write_free(async, bi.bytes_written); } @@ -2038,7 +2038,7 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait) unsigned int bps = bytes_per_sample(s); poll_wait(file, &s->async->wait_head, wait); - comedi_buf_write_alloc(s->async, s->async->prealloc_bufsz); + comedi_buf_write_alloc(s, s->async->prealloc_bufsz); if (!s->busy || !comedi_is_subdevice_running(s) || comedi_buf_write_n_allocated(s->async) >= bps) mask |= POLLOUT | POLLWRNORM; @@ -2136,7 +2136,7 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, m = n; if (async->buf_write_ptr + m > async->prealloc_bufsz) m = async->prealloc_bufsz - async->buf_write_ptr; - comedi_buf_write_alloc(async, async->prealloc_bufsz); + comedi_buf_write_alloc(s, async->prealloc_bufsz); if (m > comedi_buf_write_n_allocated(async)) m = comedi_buf_write_n_allocated(async); if (m < n) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 0a68006e2c21..b47cc969d5ad 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -336,7 +336,7 @@ static inline unsigned int bytes_per_sample(const struct comedi_subdevice *subd) */ int comedi_set_hw_dev(struct comedi_device *dev, struct device *hw_dev); -unsigned int comedi_buf_write_alloc(struct comedi_async *, unsigned int); +unsigned int comedi_buf_write_alloc(struct comedi_subdevice *s, unsigned int n); unsigned int comedi_buf_write_free(struct comedi_async *, unsigned int); unsigned int comedi_buf_read_n_available(struct comedi_async *); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c index 51095bebc087..246220abf9a9 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c @@ -2702,8 +2702,7 @@ static int i_APCI3200_InterruptHandleEos(struct comedi_device *dev) s->async->events |= COMEDI_CB_EOS; /* Test if enougth memory is available and allocate it for 7 values */ - /* n = comedi_buf_write_alloc(s->async, 7*sizeof(unsigned int)); */ - n = comedi_buf_write_alloc(s->async, + n = comedi_buf_write_alloc(s, (7 + 12) * sizeof(unsigned int)); /* If not enough memory available, event is set to Comedi Buffer Error */ diff --git a/drivers/staging/comedi/drivers/comedi_fc.c b/drivers/staging/comedi/drivers/comedi_fc.c index 5eff9d1cd072..21cf34e7dc78 100644 --- a/drivers/staging/comedi/drivers/comedi_fc.c +++ b/drivers/staging/comedi/drivers/comedi_fc.c @@ -67,7 +67,7 @@ unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *s, if (num_bytes == 0) return 0; - retval = comedi_buf_write_alloc(async, num_bytes); + retval = comedi_buf_write_alloc(s, num_bytes); if (retval != num_bytes) { dev_warn(s->device->class_dev, "buffer overrun\n"); async->events |= COMEDI_CB_OVERFLOW; diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 1a572c83f996..a5999f52ae20 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -533,7 +533,7 @@ int mite_sync_input_dma(struct mite_channel *mite_chan, old_alloc_count = async->buf_write_alloc_count; /* write alloc as much as we can */ - comedi_buf_write_alloc(async, async->prealloc_bufsz); + comedi_buf_write_alloc(s, async->prealloc_bufsz); nbytes = mite_bytes_written_to_memory_lb(mite_chan); if ((int)(mite_bytes_written_to_memory_ub(mite_chan) - diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index d4e99af6de71..d8415fe2188b 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1505,7 +1505,7 @@ static int ni_ai_setup_MITE_dma(struct comedi_device *dev) /* printk("comedi_debug: using mite channel %i for ai.\n", devpriv->ai_mite_chan->channel); */ /* write alloc the entire buffer */ - comedi_buf_write_alloc(s->async, s->async->prealloc_bufsz); + comedi_buf_write_alloc(s, s->async->prealloc_bufsz); spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->ai_mite_chan == NULL) { diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index 6dd10044a023..d0ad82a3b4b9 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -759,7 +759,7 @@ static int setup_mite_dma(struct comedi_device *dev, struct comedi_subdevice *s) return retval; /* write alloc the entire buffer */ - comedi_buf_write_alloc(s->async, s->async->prealloc_bufsz); + comedi_buf_write_alloc(s, s->async->prealloc_bufsz); spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->di_mite_chan) { diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c b/drivers/staging/comedi/drivers/ni_tiocmd.c index 7a163fc31f5d..9cc77c0b2f0f 100644 --- a/drivers/staging/comedi/drivers/ni_tiocmd.c +++ b/drivers/staging/comedi/drivers/ni_tiocmd.c @@ -125,7 +125,7 @@ static int ni_tio_input_cmd(struct comedi_subdevice *s) int retval = 0; /* write alloc the entire buffer */ - comedi_buf_write_alloc(async, async->prealloc_bufsz); + comedi_buf_write_alloc(s, async->prealloc_bufsz); counter->mite_chan->dir = COMEDI_INPUT; switch (counter_dev->variant) { case ni_gpct_variant_m_series: -- cgit v1.2.3-55-g7522