iio:trigger: Fix use_count race condition

When using more than one trigger consumer it can happen that multiple threads
access use_count concurrently. This may cause updates to be lost and use_count
can get stuck at a positive value in which case the trigger will stop. To fix
this make use_count an atomic variable. Also set it to the number of consumers
before starting the first consumer, otherwise it might happen that use_count
drops to 0 even though not all consumers have been run yet.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
iio: Add a direction parameter to iio_triggered_buffer_setup

This allows us to use it for output buffers as well.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
iio: Add output buffer support to kfifo_buf

Implement the write and remove_from callbacks for the kfifo buffer, so it can be
used as a output buffer.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
iio: ad7303: Add output buffer support

Add buffered output support to the ad7303 driver.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>