iio: staging: sca3000: hide stufftoread logic
authorJosselin Costanzi <josselin.costanzi@mobile-devices.fr>
Fri, 27 Jun 2014 16:20:00 +0000 (17:20 +0100)
committerJonathan Cameron <jic23@kernel.org>
Sun, 29 Jun 2014 13:43:38 +0000 (14:43 +0100)
Change sca3000_ring implementation so that it exports a data_available
function to iio.

Signed-off-by: Josselin Costanzi <josselin.costanzi@mobile-devices.fr>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/industrialio-buffer.c
drivers/staging/iio/accel/sca3000_ring.c

index 36b1ae92e2392b5e8b59032fe9df02a8ee2aebf4..2952ee038477a2322c217ba0fe0a4d625a46367d 100644 (file)
@@ -39,10 +39,7 @@ static bool iio_buffer_is_active(struct iio_buffer *buf)
 
 static bool iio_buffer_data_available(struct iio_buffer *buf)
 {
-       if (buf->access->data_available)
-               return buf->access->data_available(buf);
-
-       return buf->stufftoread;
+       return buf->access->data_available(buf);
 }
 
 /**
index 198710651e0ed3c951c1d5116f438d38615f76b0..33f0e9235be72901cff1fc55e7e7fe50e3df3ced 100644 (file)
@@ -141,6 +141,11 @@ static int sca3000_ring_get_bytes_per_datum(struct iio_buffer *r)
        return 6;
 }
 
+static bool sca3000_ring_buf_data_available(struct iio_buffer *r)
+{
+       return r->stufftoread;
+}
+
 static IIO_BUFFER_ENABLE_ATTR;
 static IIO_BUFFER_LENGTH_ATTR;
 
@@ -274,6 +279,7 @@ static const struct iio_buffer_access_funcs sca3000_ring_access_funcs = {
        .read_first_n = &sca3000_read_first_n_hw_rb,
        .get_length = &sca3000_ring_get_length,
        .get_bytes_per_datum = &sca3000_ring_get_bytes_per_datum,
+       .data_available = sca3000_ring_buf_data_available,
        .release = sca3000_ring_release,
 };