Commit 458c13e9 authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

staging: comedi: pass subdevice to comedi_buf_get()

Change the parameters of `comedi_buf_get()` to pass a pointer to the
comedi subdevice instead of a pointer to the "async" structure belonging
to the subdevice.

The function gets a sample value from the comedi buffer, but currently
only deals with 16-bit sample types.  A future version could deal with
16 or 32-bit sample types depending on the value of the SDF_LSAMPL
subdevice flag.

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: default avatarIan Abbott <abbotti@mev.co.uk>
Reviewed-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3672effd
...@@ -431,8 +431,9 @@ int comedi_buf_put(struct comedi_subdevice *s, unsigned short x) ...@@ -431,8 +431,9 @@ int comedi_buf_put(struct comedi_subdevice *s, unsigned short x)
} }
EXPORT_SYMBOL_GPL(comedi_buf_put); EXPORT_SYMBOL_GPL(comedi_buf_put);
int comedi_buf_get(struct comedi_async *async, unsigned short *x) int comedi_buf_get(struct comedi_subdevice *s, unsigned short *x)
{ {
struct comedi_async *async = s->async;
unsigned int n = comedi_buf_read_n_available(async); unsigned int n = comedi_buf_read_n_available(async);
if (n < sizeof(short)) if (n < sizeof(short))
......
...@@ -344,7 +344,7 @@ unsigned int comedi_buf_read_alloc(struct comedi_async *, unsigned int); ...@@ -344,7 +344,7 @@ unsigned int comedi_buf_read_alloc(struct comedi_async *, unsigned int);
unsigned int comedi_buf_read_free(struct comedi_async *, unsigned int); unsigned int comedi_buf_read_free(struct comedi_async *, unsigned int);
int comedi_buf_put(struct comedi_subdevice *s, unsigned short x); int comedi_buf_put(struct comedi_subdevice *s, unsigned short x);
int comedi_buf_get(struct comedi_async *, unsigned short *); int comedi_buf_get(struct comedi_subdevice *s, unsigned short *x);
void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset, void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset,
const void *source, unsigned int num_bytes); const void *source, unsigned int num_bytes);
......
...@@ -1164,7 +1164,7 @@ static void pci230_handle_ao_nofifo(struct comedi_device *dev, ...@@ -1164,7 +1164,7 @@ static void pci230_handle_ao_nofifo(struct comedi_device *dev,
return; return;
for (i = 0; i < cmd->chanlist_len; i++) { for (i = 0; i < cmd->chanlist_len; i++) {
/* Read sample from Comedi's circular buffer. */ /* Read sample from Comedi's circular buffer. */
ret = comedi_buf_get(s->async, &data); ret = comedi_buf_get(s, &data);
if (ret == 0) { if (ret == 0) {
s->async->events |= COMEDI_CB_OVERFLOW; s->async->events |= COMEDI_CB_OVERFLOW;
pci230_ao_stop(dev, s); pci230_ao_stop(dev, s);
...@@ -1250,7 +1250,7 @@ static int pci230_handle_ao_fifo(struct comedi_device *dev, ...@@ -1250,7 +1250,7 @@ static int pci230_handle_ao_fifo(struct comedi_device *dev,
for (i = 0; i < cmd->chanlist_len; i++) { for (i = 0; i < cmd->chanlist_len; i++) {
unsigned short datum; unsigned short datum;
comedi_buf_get(async, &datum); comedi_buf_get(s, &datum);
pci230_ao_write_fifo(dev, datum, pci230_ao_write_fifo(dev, datum,
CR_CHAN(cmd->chanlist[i])); CR_CHAN(cmd->chanlist[i]));
} }
......
...@@ -1149,7 +1149,7 @@ static void ni_ao_fifo_load(struct comedi_device *dev, ...@@ -1149,7 +1149,7 @@ static void ni_ao_fifo_load(struct comedi_device *dev,
chan = async->cur_chan; chan = async->cur_chan;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
err &= comedi_buf_get(async, &d); err &= comedi_buf_get(s, &d);
if (err == 0) if (err == 0)
break; break;
...@@ -1159,7 +1159,7 @@ static void ni_ao_fifo_load(struct comedi_device *dev, ...@@ -1159,7 +1159,7 @@ static void ni_ao_fifo_load(struct comedi_device *dev,
packed_data = d & 0xffff; packed_data = d & 0xffff;
/* 6711 only has 16 bit wide ao fifo */ /* 6711 only has 16 bit wide ao fifo */
if (board->reg_type != ni_reg_6711) { if (board->reg_type != ni_reg_6711) {
err &= comedi_buf_get(async, &d); err &= comedi_buf_get(s, &d);
if (err == 0) if (err == 0)
break; break;
chan++; chan++;
......
...@@ -484,7 +484,7 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) ...@@ -484,7 +484,7 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb)
unsigned int chan = devpriv->ao_chanlist[i]; unsigned int chan = devpriv->ao_chanlist[i];
unsigned short val; unsigned short val;
ret = comedi_buf_get(s->async, &val); ret = comedi_buf_get(s, &val);
if (ret < 0) { if (ret < 0) {
dev_err(dev->class_dev, "buffer underflow\n"); dev_err(dev->class_dev, "buffer underflow\n");
s->async->events |= (COMEDI_CB_EOA | s->async->events |= (COMEDI_CB_EOA |
......
...@@ -423,7 +423,7 @@ static void usbduxsigma_ao_urb_complete(struct urb *urb) ...@@ -423,7 +423,7 @@ static void usbduxsigma_ao_urb_complete(struct urb *urb)
unsigned int chan = devpriv->ao_chanlist[i]; unsigned int chan = devpriv->ao_chanlist[i];
unsigned short val; unsigned short val;
ret = comedi_buf_get(s->async, &val); ret = comedi_buf_get(s, &val);
if (ret < 0) { if (ret < 0) {
dev_err(dev->class_dev, "buffer underflow\n"); dev_err(dev->class_dev, "buffer underflow\n");
s->async->events |= (COMEDI_CB_EOA | s->async->events |= (COMEDI_CB_EOA |
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment