Read buffer until the right number of samples have been read

Using iio_buffer_refill / iio_buffer_foreach_sample does not
guarantee that the maximum size of the buffer will be used.

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>