staging: comedi: pass subdevice to comedi_buf_put()
authorIan Abbott <abbotti@mev.co.uk>
Tue, 6 May 2014 12:11:59 +0000 (13:11 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 May 2014 12:25:47 +0000 (21:25 +0900)
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: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
31 files changed:
drivers/staging/comedi/comedi_buf.c
drivers/staging/comedi/comedidev.h
drivers/staging/comedi/drivers/8255.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
drivers/staging/comedi/drivers/addi_apci_1032.c
drivers/staging/comedi/drivers/addi_apci_2032.c
drivers/staging/comedi/drivers/addi_apci_3xxx.c
drivers/staging/comedi/drivers/adv_pci1710.c
drivers/staging/comedi/drivers/amplc_dio200_common.c
drivers/staging/comedi/drivers/amplc_pc236.c
drivers/staging/comedi/drivers/amplc_pci230.c
drivers/staging/comedi/drivers/comedi_parport.c
drivers/staging/comedi/drivers/dmm32at.c
drivers/staging/comedi/drivers/dt282x.c
drivers/staging/comedi/drivers/dt3000.c
drivers/staging/comedi/drivers/me4000.c
drivers/staging/comedi/drivers/ni_6527.c
drivers/staging/comedi/drivers/ni_65xx.c
drivers/staging/comedi/drivers/ni_atmio16d.c
drivers/staging/comedi/drivers/ni_pcidio.c
drivers/staging/comedi/drivers/pcl711.c
drivers/staging/comedi/drivers/pcl726.c
drivers/staging/comedi/drivers/pcl812.c
drivers/staging/comedi/drivers/pcl816.c
drivers/staging/comedi/drivers/pcl818.c
drivers/staging/comedi/drivers/pcmmio.c
drivers/staging/comedi/drivers/pcmuio.c
drivers/staging/comedi/drivers/quatech_daqp_cs.c
drivers/staging/comedi/drivers/rtd520.c
drivers/staging/comedi/drivers/s626.c
drivers/staging/comedi/drivers/usbdux.c

index 257595016161ccb90552ca8a7d67d4c1e9e99559..f127bf9bd421f61585f6585b7a82bc9c9cabdc2a 100644 (file)
@@ -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)) {
index d46123a975820868ef3d2fd3ac9d61c75ed21a15..a874c1c43a322643a788884969fbf475e6066237 100644 (file)
@@ -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,
index 1d53e241e84d94bfd873d44c3de10a06ed83ec31..46113a37413324540e1843c3a85bebe13b0f47e4 100644 (file)
@@ -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);
index e3aa89780c2c7964393027ab7cfbe00f9b10069b..764c8f17f8faf962a877d22e0314ade153bba28d 100644 (file)
@@ -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;
 
index c242afc9134d6978660ad724c7fdb7b685576d01..1b2e7c040c9f9dc4b8e1606573596276974ea810 100644 (file)
@@ -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);
 
index 2fd14553e57c730bccc2e87f6cdaf77c3550be86..be0a8a7bd3b2aebb6c1fb347b0e1f5c887ecc9fc 100644 (file)
@@ -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) {
index f290be8188453b8eb74bf20771eb7bd055d0ccce..df3b63ac4a0ebf745ffe65946679ddc8cfc487f8 100644 (file)
@@ -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);
index 0dc946eaa74357c461337848d5202ca002fcb96f..a459bdf7e35255127043fe2f2e04e182e49d86ac 100644 (file)
@@ -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) {
index 5125bf0ecb727d3c169dd9ddf3d6e17464108357..1a580c374ca81c3c71d9ec8eca2b3822e84901f1 100644 (file)
@@ -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.  */
index 2834d0a9342afe866e079f02808c3394868ae0f4..c9a96ad005596847ea9f40dcebcfab99c2a5017e 100644 (file)
@@ -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);
        }
index ff927c6417487ec9e893d7c540eaefbed1683732..9541e240925ef771143dd9aec42ad143b2403dbf 100644 (file)
@@ -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;
index 50723b9406305c2a12ffb2c69fd44af37cc03172..a427486923577b40b2f02fd6dc0bd9fa72344854 100644 (file)
@@ -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);
index 68260e6658e425f7ab631b8c447e35a5c4eb6e24..931150150e1089b08dee6f9a6766d06cc32d5669 100644 (file)
@@ -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 */
index 474f52dac15de990fe59cbe8a5fed3986b9ce68d..15d5145166e013451387660c06f319308e2cacb4 100644 (file)
@@ -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;
index 436e451cadf5e1a72d6994fbed30f93a1e6d8e16..abd999f95f70e54568b9b5595718ad69aa1e7fbf 100644 (file)
@@ -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;
index a08bc6ffad306ebb57f10e63fa152b7502ddd04e..25ce2f78db8154ac96fea55e64bff27b937c10e7 100644 (file)
@@ -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;
index 2b2dafe29c05f1b04e4e93f1d2de5219c75af701..c8b1fa793a3794324fdf80f2f143440f405e0d3b 100644 (file)
@@ -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);
        }
index 2051a7c5de109d4222e3646a22a4d28db717c474..a74fd1e60c28c5ebe60f7d6b87493e4b6697874c 100644 (file)
@@ -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;
index 4262385e4f46a15ca5e7c1321c8265a8de094e5a..6ad27f50c6ecb28561aae9845a7343eaa97e2c45 100644 (file)
@@ -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;
index 962c2353a79ff11aede8c47ed941de797f7a5556..6dd10044a02338c7453444ecd6a2c916dd424cc6 100644 (file)
@@ -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);
                        }
index 2da6fec6ab4ca9de735e9b9a901126b849a7885e..ef3ebeef7a4d69194c2f3337324d0606743e9aaf 100644 (file)
@@ -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;
index 07ff1e22e61ca67e8bbb7768924c2dcbc19b81ae..74f6489bd1242f4095ed888080bf51dcd500f1f4 100644 (file)
@@ -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);
        }
index 0cf115e54308b3670ebf708174f535cecb1064da..542178bba2d4f55654a545f7a227746a73ae177f 100644 (file)
@@ -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;
index 6f276f23fabe284e934bfa32e36b81805ca646f6..1260122ee7abae8e2079fe70f7398361c338d789 100644 (file)
@@ -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;
index 6463476ce45adbdb928b7ce310da2117325c12db..b960b66bc9a80e44b10dc9747855336aa0024499 100644 (file)
@@ -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;
index bb29ecfcfef4badb94d4f0ca8cc93da1d33d5ec9..2d185136db785ea8fcdecb1a744d6f401c2ea1f8 100644 (file)
@@ -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!! */
index ea45424e841078191a1a1100279b342d5b243b58..182b48a3e88b0b0b4645922baa00c88cb602a7cb 100644 (file)
@@ -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!! */
index 298dba03f9026b60cd37b8a144e727461b8292aa..0a8edb8cc190429210315722db0d12290e9581cc 100644 (file)
@@ -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
index e7c2e34624d905a2111f40a7f84965a446c09377..28402d2f92a2e9efc94212349baf66e57ac17b29 100644 (file)
@@ -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 */
index 647b9e50bd74d69469b1ceae097ff88929295182..33b4d027a5cb571e2826d6cbb3513e87b4f38e42 100644 (file)
@@ -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);
        }
 
index 4002f49f0082add9288950b5fed1a2f781aec82d..011fede33a001a23dcc6e0f00aec6281b32ac335 100644 (file)
@@ -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);