Skip to content

Commit

Permalink
stream: Simplify iio_stream_get_next_block()
Browse files Browse the repository at this point in the history
The bytes_used field can now be set to 0 to default to the block size.

Note that for RX transfers, iio_block_enqueue() was already called
with bytes_used == 0, which previously meant "transmit 0 bytes and
queue for receive". Because the "bytes_used" field is now handled as
for RX buffers as well, the behaviour is now "queue for receiving a
block size worth of data" which is functionally the same.

Signed-off-by: Paul Cercueil <[email protected]>
  • Loading branch information
pcercuei committed Oct 10, 2023
1 parent c66f1f2 commit a258058
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
struct iio_stream {
struct iio_buffer *buffer;
struct iio_block **blocks;
size_t buf_size, nb_blocks;
size_t nb_blocks;
bool started, buf_enabled, all_enqueued;
unsigned int curr;
};
Expand Down Expand Up @@ -56,7 +56,6 @@ iio_buffer_create_stream(struct iio_buffer *buffer, size_t nb_blocks,

stream->buffer = buffer;
stream->nb_blocks = nb_blocks;
stream->buf_size = buf_size;

return stream;

Expand Down Expand Up @@ -86,7 +85,6 @@ iio_stream_get_next_block(struct iio_stream *stream)
{
const struct iio_device *dev = stream->buffer->dev;
bool is_tx = iio_device_is_tx(dev);
size_t buf_size;
unsigned int i;
int err;

Expand All @@ -107,9 +105,7 @@ iio_stream_get_next_block(struct iio_stream *stream)
stream->all_enqueued = true;
}

buf_size = is_tx ? stream->buf_size : 0;

err = iio_block_enqueue(stream->blocks[stream->curr], buf_size, false);
err = iio_block_enqueue(stream->blocks[stream->curr], 0, false);
if (err < 0) {
dev_perror(dev, err, "Unable to enqueue block");
return iio_ptr(err);
Expand Down

0 comments on commit a258058

Please sign in to comment.