/* This function relies on all ring buffer implementations having an iio_ring _bufer as their first element.  */
ssize_t iio_ring_rip_outer(struct file *filp, char *buf, size_t count, loff_t *f_ps)
/* This function relies on all ring buffer implementations having an iio_ring _bufer as their first element.  */
ssize_t iio_ring_rip_outer(struct file *filp, char *buf, size_t count, loff_t *f_ps)
{
	struct iio_ring_buffer *rb = filp->private_data;
	int ret, dead_offset, copied;
	u8 *data;
	if (!rb->access.rip_lots)
		return -EINVAL;
	copied = rb->access.rip_lots(rb, count, &data, &dead_offset);
	if (copied < 0) {
		ret = copied;
		goto error_ret;
	}
	if (copy_to_user(buf, data + dead_offset, copied))  {
		ret =  -EFAULT;
		goto error_free_data_cpy;
	}
	kfree(data);
	return copied;
error_free_data_cpy:
	kfree(data);
error_ret:
	return ret;
}