Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 24e894bb authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman
Browse files

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: 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 67ab76f0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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);

+3 −3
Original line number Diff line number Diff line
@@ -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)
+1 −1
Original line number Diff line number Diff line
@@ -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 *);
+1 −2
Original line number Diff line number Diff line
@@ -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 */
+1 −1
Original line number Diff line number Diff line
@@ -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;
Loading