Commit 3672effd authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

staging: comedi: pass subdevice to comedi_buf_put()

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

The function puts a sample value in 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 53030b13
......@@ -416,8 +416,9 @@ unsigned int comedi_buf_read_free(struct comedi_async *async,
}
EXPORT_SYMBOL_GPL(comedi_buf_read_free);
int comedi_buf_put(struct comedi_async *async, unsigned short x)
int comedi_buf_put(struct comedi_subdevice *s, unsigned short x)
{
struct comedi_async *async = s->async;
unsigned int n = __comedi_buf_write_alloc(async, sizeof(short), 1);
if (n < sizeof(short)) {
......
......@@ -343,7 +343,7 @@ unsigned int comedi_buf_read_n_available(struct comedi_async *);
unsigned int comedi_buf_read_alloc(struct comedi_async *, unsigned int);
unsigned int comedi_buf_read_free(struct comedi_async *, unsigned int);
int comedi_buf_put(struct comedi_async *, unsigned short);
int comedi_buf_put(struct comedi_subdevice *s, unsigned short x);
int comedi_buf_get(struct comedi_async *, unsigned short *);
void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset,
......
......@@ -117,7 +117,7 @@ void subdev_8255_interrupt(struct comedi_device *dev,
d = spriv->io(0, _8255_DATA, 0, iobase);
d |= (spriv->io(0, _8255_DATA + 1, 0, iobase) << 8);
comedi_buf_put(s->async, d);
comedi_buf_put(s, d);
s->async->events |= COMEDI_CB_EOS;
comedi_event(dev, s);
......
......@@ -1520,7 +1520,7 @@ static int apci3120_interrupt_handle_eos(struct comedi_device *dev)
n_chan = devpriv->ui_AiNbrofChannels;
for (i = 0; i < n_chan; i++)
err &= comedi_buf_put(s->async, inw(dev->iobase + 0));
err &= comedi_buf_put(s, inw(dev->iobase + 0));
s->async->events |= COMEDI_CB_EOS;
......
......@@ -262,7 +262,7 @@ static irqreturn_t apci1032_interrupt(int irq, void *d)
outl(ctrl & ~APCI1032_CTRL_INT_ENA, dev->iobase + APCI1032_CTRL_REG);
s->state = inl(dev->iobase + APCI1032_STATUS_REG) & 0xffff;
comedi_buf_put(s->async, s->state);
comedi_buf_put(s, s->state);
s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
comedi_event(dev, s);
......
......@@ -234,7 +234,7 @@ static irqreturn_t apci2032_interrupt(int irq, void *d)
bits |= (1 << i);
}
if (comedi_buf_put(s->async, bits)) {
if (comedi_buf_put(s, bits)) {
s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
if (cmd->stop_src == TRIG_COUNT &&
subpriv->stop_count > 0) {
......
......@@ -373,7 +373,7 @@ static irqreturn_t apci3xxx_irq_handler(int irq, void *d)
writel(status, devpriv->mmio + 16);
val = readl(devpriv->mmio + 28);
comedi_buf_put(s->async, val);
comedi_buf_put(s, val);
s->async->events |= COMEDI_CB_EOA;
comedi_event(dev, s);
......
......@@ -770,7 +770,7 @@ static void pci1710_handle_every_sample(struct comedi_device *dev,
break;
}
comedi_buf_put(s->async, val & s->maxdata);
comedi_buf_put(s, val & s->maxdata);
s->async->cur_chan++;
if (s->async->cur_chan >= cmd->chanlist_len)
......@@ -814,7 +814,7 @@ static int move_block_from_fifo(struct comedi_device *dev,
return ret;
}
comedi_buf_put(s->async, val & s->maxdata);
comedi_buf_put(s, val & s->maxdata);
s->async->cur_chan++;
if (s->async->cur_chan >= cmd->chanlist_len) {
......
......@@ -322,7 +322,7 @@ static void dio200_read_scan_intr(struct comedi_device *dev,
val |= (1U << n);
}
/* Write the scan to the buffer. */
if (comedi_buf_put(s->async, val)) {
if (comedi_buf_put(s, val)) {
s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS);
} else {
/* Error! Stop acquisition. */
......
......@@ -361,7 +361,7 @@ static irqreturn_t pc236_interrupt(int irq, void *d)
handled = pc236_intr_check(dev);
if (dev->attached && handled) {
comedi_buf_put(s->async, 0);
comedi_buf_put(s, 0);
s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
comedi_event(dev, s);
}
......
......@@ -2209,7 +2209,7 @@ static void pci230_handle_ai(struct comedi_device *dev,
}
}
/* Read sample and store in Comedi's circular buffer. */
if (comedi_buf_put(async, pci230_ai_read(dev)) == 0) {
if (comedi_buf_put(s, pci230_ai_read(dev)) == 0) {
events |= COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW;
comedi_error(dev, "AI buffer overflow");
break;
......
......@@ -229,7 +229,7 @@ static irqreturn_t parport_interrupt(int irq, void *d)
if (!(ctrl & PARPORT_CTRL_IRQ_ENA))
return IRQ_NONE;
comedi_buf_put(s->async, 0);
comedi_buf_put(s, 0);
s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
comedi_event(dev, s);
......
......@@ -473,12 +473,6 @@ static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
outb(0xff, dev->iobase + DMM32AT_CONV);
}
/* for(i=0;i<cmd->chanlist_len;i++) */
/* comedi_buf_put(s->async,i*100); */
/* s->async->events |= COMEDI_CB_EOA; */
/* comedi_event(dev, s); */
return 0;
}
......@@ -519,7 +513,7 @@ static irqreturn_t dmm32at_isr(int irq, void *d)
/* invert sign bit to make range unsigned */
samp = ((msb ^ 0x0080) << 8) + lsb;
comedi_buf_put(s->async, samp);
comedi_buf_put(s, samp);
}
if (devpriv->ai_scans_left != 0xffffffff) { /* TRIG_COUNT */
......
......@@ -466,7 +466,7 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
if (devpriv->ad_2scomp)
data ^= 1 << (board->adbits - 1);
ret = comedi_buf_put(s->async, data);
ret = comedi_buf_put(s, data);
if (ret == 0)
s->async->events |= COMEDI_CB_OVERFLOW;
......
......@@ -322,7 +322,7 @@ static void dt3k_ai_empty_fifo(struct comedi_device *dev,
for (i = 0; i < count; i++) {
data = readw(devpriv->io_addr + DPR_ADC_buffer + rear);
comedi_buf_put(s->async, data);
comedi_buf_put(s, data);
rear++;
if (rear >= AI_FIFO_DEPTH)
rear = 0;
......
......@@ -1124,7 +1124,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
lval = inl(dev->iobase + ME4000_AI_DATA_REG) & 0xFFFF;
lval ^= 0x8000;
if (!comedi_buf_put(s->async, lval)) {
if (!comedi_buf_put(s, lval)) {
/*
* Buffer overflow, so stop conversion
* and disable all interrupts
......@@ -1169,7 +1169,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
lval = inl(dev->iobase + ME4000_AI_DATA_REG) & 0xFFFF;
lval ^= 0x8000;
if (!comedi_buf_put(s->async, lval)) {
if (!comedi_buf_put(s, lval)) {
dev_err(dev->class_dev, "Buffer overflow\n");
s->async->events |= COMEDI_CB_OVERFLOW;
break;
......
......@@ -215,7 +215,7 @@ static irqreturn_t ni6527_interrupt(int irq, void *d)
return IRQ_NONE;
if (status & NI6527_STATUS_EDGE) {
comedi_buf_put(s->async, 0);
comedi_buf_put(s, 0);
s->async->events |= COMEDI_CB_EOS;
comedi_event(dev, s);
}
......
......@@ -439,7 +439,7 @@ static irqreturn_t ni_65xx_interrupt(int irq, void *d)
writeb(ClrEdge | ClrOverflow,
devpriv->mite->daq_io_addr + Clear_Register);
comedi_buf_put(s->async, 0);
comedi_buf_put(s, 0);
s->async->events |= COMEDI_CB_EOS;
comedi_event(dev, s);
return IRQ_HANDLED;
......
......@@ -221,7 +221,7 @@ static irqreturn_t atmio16d_interrupt(int irq, void *d)
struct comedi_device *dev = d;
struct comedi_subdevice *s = dev->read_subdev;
comedi_buf_put(s->async, inw(dev->iobase + AD_FIFO_REG));
comedi_buf_put(s, inw(dev->iobase + AD_FIFO_REG));
comedi_event(dev, s);
return IRQ_HANDLED;
......
......@@ -447,8 +447,8 @@ static irqreturn_t nidio_interrupt(int irq, void *d)
Group_1_FIFO);
data1 = auxdata & 0xffff;
data2 = (auxdata & 0xffff0000) >> 16;
comedi_buf_put(async, data1);
comedi_buf_put(async, data2);
comedi_buf_put(s, data1);
comedi_buf_put(s, data2);
flags = readb(devpriv->mite->daq_io_addr +
Group_1_Flags);
}
......
......@@ -213,7 +213,7 @@ static irqreturn_t pcl711_interrupt(int irq, void *d)
outb(PCL711_INT_STAT_CLR, dev->iobase + PCL711_INT_STAT_REG);
if (comedi_buf_put(s->async, data) == 0) {
if (comedi_buf_put(s, data) == 0) {
s->async->events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
} else {
s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
......
......@@ -240,7 +240,7 @@ static irqreturn_t pcl726_interrupt(int irq, void *d)
if (devpriv->cmd_running) {
pcl726_intr_cancel(dev, s);
comedi_buf_put(s->async, 0);
comedi_buf_put(s, 0);
s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS);
comedi_event(dev, s);
}
......
......@@ -882,7 +882,7 @@ static void pcl812_handle_eoc(struct comedi_device *dev,
return;
}
comedi_buf_put(s->async, pcl812_ai_get_sample(dev, s));
comedi_buf_put(s, pcl812_ai_get_sample(dev, s));
/* Set up next channel. Added by abbotti 2010-01-20, but untested. */
next_chan = s->async->cur_chan + 1;
......@@ -902,7 +902,7 @@ static void transfer_from_dma_buf(struct comedi_device *dev,
unsigned int i;
for (i = len; i; i--) {
comedi_buf_put(s->async, ptr[bufptr++]);
comedi_buf_put(s, ptr[bufptr++]);
if (!pcl812_ai_next_chan(dev, s))
break;
......
......@@ -322,7 +322,7 @@ static void transfer_from_dma_buf(struct comedi_device *dev,
int i;
for (i = 0; i < len; i++) {
comedi_buf_put(s->async, ptr[bufptr++]);
comedi_buf_put(s, ptr[bufptr++]);
if (!pcl816_ai_next_chan(dev, s))
return;
......
......@@ -561,7 +561,7 @@ static void pcl818_handle_eoc(struct comedi_device *dev,
if (pcl818_ai_dropout(dev, s, chan))
return;
comedi_buf_put(s->async, val);
comedi_buf_put(s, val);
pcl818_ai_next_chan(dev, s);
}
......@@ -590,7 +590,7 @@ static void pcl818_handle_dma(struct comedi_device *dev,
if (pcl818_ai_dropout(dev, s, chan))
break;
comedi_buf_put(s->async, val);
comedi_buf_put(s, val);
if (!pcl818_ai_next_chan(dev, s))
break;
......@@ -630,7 +630,7 @@ static void pcl818_handle_fifo(struct comedi_device *dev,
if (pcl818_ai_dropout(dev, s, chan))
break;
comedi_buf_put(s->async, val);
comedi_buf_put(s, val);
if (!pcl818_ai_next_chan(dev, s))
break;
......
......@@ -361,8 +361,8 @@ static void pcmmio_handle_dio_intr(struct comedi_device *dev,
}
/* Write the scan to the buffer. */
if (comedi_buf_put(s->async, val) &&
comedi_buf_put(s->async, val >> 16)) {
if (comedi_buf_put(s, val) &&
comedi_buf_put(s, val >> 16)) {
s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS);
} else {
/* Overflow! Stop acquisition!! */
......
......@@ -338,8 +338,8 @@ static void pcmuio_handle_intr_subdev(struct comedi_device *dev,
}
/* Write the scan to the buffer. */
if (comedi_buf_put(s->async, val) &&
comedi_buf_put(s->async, val >> 16)) {
if (comedi_buf_put(s, val) &&
comedi_buf_put(s, val >> 16)) {
s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS);
} else {
/* Overflow! Stop acquisition!! */
......
......@@ -221,7 +221,7 @@ static enum irqreturn daqp_interrupt(int irq, void *dev_id)
data |= inb(dev->iobase + DAQP_FIFO) << 8;
data ^= 0x8000;
comedi_buf_put(s->async, data);
comedi_buf_put(s, data);
/* If there's a limit, decrement it
* and stop conversion if zero
......
......@@ -629,7 +629,7 @@ static int ai_read_n(struct comedi_device *dev, struct comedi_subdevice *s,
d = comedi_offset_munge(s, d);
d &= s->maxdata;
if (!comedi_buf_put(s->async, d))
if (!comedi_buf_put(s, d))
return -1;
if (devpriv->ai_count > 0) /* < 0, means read forever */
......@@ -658,7 +658,7 @@ static int ai_read_dregs(struct comedi_device *dev, struct comedi_subdevice *s)
d = comedi_offset_munge(s, d);
d &= s->maxdata;
if (!comedi_buf_put(s->async, d))
if (!comedi_buf_put(s, d))
return -1;
if (devpriv->ai_count > 0) /* < 0, means read forever */
......
......@@ -1628,7 +1628,6 @@ static bool s626_handle_eos_interrupt(struct comedi_device *dev)
readaddr++;
/* put data into read buffer */
/* comedi_buf_put(async, tempdata); */
cfc_write_to_buffer(s, tempdata);
}
......
......@@ -373,7 +373,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb)
val ^= ((s->maxdata + 1) >> 1);
/* transfer data */
err = comedi_buf_put(s->async, val);
err = comedi_buf_put(s, val);
if (unlikely(err == 0)) {
/* buffer overflow */
usbdux_ai_stop(dev, 0);
......
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