]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: comedi: pass subdevice to comedi_buf_read_alloc()
authorIan Abbott <abbotti@mev.co.uk>
Tue, 6 May 2014 12:12:07 +0000 (13:12 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 May 2014 12:25:49 +0000 (21:25 +0900)
Change the parameters of `comedi_buf_read_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 <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/comedi_buf.c
drivers/staging/comedi/comedi_fops.c
drivers/staging/comedi/comedidev.h
drivers/staging/comedi/drivers/comedi_fc.c
drivers/staging/comedi/drivers/mite.c
drivers/staging/comedi/drivers/ni_mio_common.c

index ac498e0b486554dc4db096b9425b8c3053e322fb..07e0b3a518280cb6b16cbc279211af70e9125b8b 100644 (file)
@@ -370,9 +370,10 @@ unsigned int comedi_buf_read_n_available(struct comedi_async *async)
 EXPORT_SYMBOL_GPL(comedi_buf_read_n_available);
 
 /* allocates a chunk for the reader from filled (and munged) buffer space */
-unsigned int comedi_buf_read_alloc(struct comedi_async *async,
+unsigned int comedi_buf_read_alloc(struct comedi_subdevice *s,
                                   unsigned int nbytes)
 {
+       struct comedi_async *async = s->async;
        unsigned int available;
 
        available = async->munge_count - async->buf_read_alloc_count;
@@ -441,7 +442,7 @@ int comedi_buf_get(struct comedi_subdevice *s, unsigned short *x)
 
        if (n < sizeof(short))
                return 0;
-       comedi_buf_read_alloc(async, sizeof(short));
+       comedi_buf_read_alloc(s, sizeof(short));
        *x = *(unsigned short *)(async->prealloc_buf + async->buf_read_ptr);
        comedi_buf_read_free(async, sizeof(short));
        return 1;
index bc9386350b76fef203019c00cf19214092bd35e5..5164374f5ab2016408a48f7661741547bcc97ea3 100644 (file)
@@ -993,7 +993,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
                return -EACCES;
 
        if (bi.bytes_read && (s->subdev_flags & SDF_CMD_READ)) {
-               bi.bytes_read = comedi_buf_read_alloc(async, bi.bytes_read);
+               bi.bytes_read = comedi_buf_read_alloc(s, bi.bytes_read);
                comedi_buf_read_free(async, bi.bytes_read);
 
                if (comedi_is_subdevice_idle(s) &&
@@ -2272,7 +2272,7 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
                        retval = -EFAULT;
                }
 
-               comedi_buf_read_alloc(async, n);
+               comedi_buf_read_alloc(s, n);
                comedi_buf_read_free(async, n);
 
                count += n;
index 4a795e06d9996242c104780f996660d19e079934..d2131f26de53559c132cb420f2f82ab516739d23 100644 (file)
@@ -340,7 +340,7 @@ unsigned int comedi_buf_write_alloc(struct comedi_subdevice *s, unsigned int n);
 unsigned int comedi_buf_write_free(struct comedi_subdevice *s, unsigned int n);
 
 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_alloc(struct comedi_subdevice *s, unsigned int n);
 unsigned int comedi_buf_read_free(struct comedi_async *, unsigned int);
 
 int comedi_buf_put(struct comedi_subdevice *s, unsigned short x);
index a7860a41fe323e0356beb4283553f907bd5f8e65..836eb1a37380b3a02954a69a0a1bfa7f01f5b4b4 100644 (file)
@@ -91,7 +91,7 @@ unsigned int cfc_read_array_from_buffer(struct comedi_subdevice *s,
        if (num_bytes == 0)
                return 0;
 
-       num_bytes = comedi_buf_read_alloc(async, num_bytes);
+       num_bytes = comedi_buf_read_alloc(s, num_bytes);
        comedi_buf_memcpy_from(s, 0, data, num_bytes);
        comedi_buf_read_free(async, num_bytes);
        cfc_inc_scan_progress(s, num_bytes);
index e33c03dc556b0bcc8a4c04040278a03215dc9690..d1423caecf7ad631d15d601b1c3e60de5834db56 100644 (file)
@@ -560,15 +560,15 @@ EXPORT_SYMBOL_GPL(mite_sync_input_dma);
 int mite_sync_output_dma(struct mite_channel *mite_chan,
                         struct comedi_async *async)
 {
+       struct comedi_subdevice *s = async->subdevice;
        int count;
        u32 nbytes_ub, nbytes_lb;
        unsigned int old_alloc_count;
-       u32 stop_count =
-           async->cmd.stop_arg * cfc_bytes_per_scan(async->subdevice);
+       u32 stop_count = async->cmd.stop_arg * cfc_bytes_per_scan(s);
 
        old_alloc_count = async->buf_read_alloc_count;
        /*  read alloc as much as we can */
-       comedi_buf_read_alloc(async, async->prealloc_bufsz);
+       comedi_buf_read_alloc(s, async->prealloc_bufsz);
        nbytes_lb = mite_bytes_read_from_memory_lb(mite_chan);
        if (async->cmd.stop_src == TRIG_COUNT &&
            (int)(nbytes_lb - stop_count) > 0)
index d8415fe2188b8b44e572377428fea50d08ff90e3..950b223440d446a916ad0eeaeab90f20e222cafb 100644 (file)
@@ -1545,7 +1545,7 @@ static int ni_ao_setup_MITE_dma(struct comedi_device *dev)
                return retval;
 
        /* read alloc the entire buffer */
-       comedi_buf_read_alloc(s->async, s->async->prealloc_bufsz);
+       comedi_buf_read_alloc(s, s->async->prealloc_bufsz);
 
        spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
        if (devpriv->ao_mite_chan) {
@@ -3565,7 +3565,7 @@ static int ni_cdo_inttrig(struct comedi_device *dev,
        s->async->inttrig = NULL;
 
        /* read alloc the entire buffer */
-       comedi_buf_read_alloc(s->async, s->async->prealloc_bufsz);
+       comedi_buf_read_alloc(s, s->async->prealloc_bufsz);
 
 #ifdef PCIDMA
        spin_lock_irqsave(&devpriv->mite_channel_lock, flags);