staging:iio: Setup buffer access functions when allocating the buffer
authorLars-Peter Clausen <lars@metafoo.de>
Tue, 3 Jan 2012 10:02:51 +0000 (11:02 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Feb 2012 18:03:51 +0000 (10:03 -0800)
Setup the buffer access functions in the buffer allocate function. There is no
need to let each driver handle this on its own.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24 files changed:
drivers/staging/iio/accel/adis16201_ring.c
drivers/staging/iio/accel/adis16203_ring.c
drivers/staging/iio/accel/adis16204_ring.c
drivers/staging/iio/accel/adis16209_ring.c
drivers/staging/iio/accel/adis16240_ring.c
drivers/staging/iio/accel/lis3l02dq.h
drivers/staging/iio/accel/lis3l02dq_ring.c
drivers/staging/iio/adc/ad7192.c
drivers/staging/iio/adc/ad7298_ring.c
drivers/staging/iio/adc/ad7476_ring.c
drivers/staging/iio/adc/ad7606_ring.c
drivers/staging/iio/adc/ad7793.c
drivers/staging/iio/adc/ad7887_ring.c
drivers/staging/iio/adc/ad799x_ring.c
drivers/staging/iio/adc/max1363_ring.c
drivers/staging/iio/gyro/adis16260_ring.c
drivers/staging/iio/iio_simple_dummy_buffer.c
drivers/staging/iio/impedance-analyzer/ad5933.c
drivers/staging/iio/imu/adis16400_ring.c
drivers/staging/iio/kfifo_buf.c
drivers/staging/iio/kfifo_buf.h
drivers/staging/iio/meter/ade7758_ring.c
drivers/staging/iio/ring_sw.c
drivers/staging/iio/ring_sw.h

index 26c610f..97f9e6b 100644 (file)
@@ -115,9 +115,7 @@ int adis16201_configure_ring(struct iio_dev *indio_dev)
                return ret;
        }
        indio_dev->buffer = ring;
-       /* Effectively select the ring buffer implementation */
        ring->scan_timestamp = true;
-       ring->access = &ring_sw_access_funcs;
        indio_dev->setup_ops = &adis16201_ring_setup_ops;
 
        indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
index 064640d..6a8963d 100644 (file)
@@ -117,9 +117,7 @@ int adis16203_configure_ring(struct iio_dev *indio_dev)
                return ret;
        }
        indio_dev->buffer = ring;
-       /* Effectively select the ring buffer implementation */
        ring->scan_timestamp = true;
-       ring->access = &ring_sw_access_funcs;
        indio_dev->setup_ops = &adis16203_ring_setup_ops;
 
        indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
index 4081179..5c8ab73 100644 (file)
@@ -112,8 +112,6 @@ int adis16204_configure_ring(struct iio_dev *indio_dev)
                return ret;
        }
        indio_dev->buffer = ring;
-       /* Effectively select the ring buffer implementation */
-       ring->access = &ring_sw_access_funcs;
        ring->scan_timestamp = true;
        indio_dev->setup_ops = &adis16204_ring_setup_ops;
 
index 2a6fd33..57254b6 100644 (file)
@@ -113,8 +113,6 @@ int adis16209_configure_ring(struct iio_dev *indio_dev)
                return ret;
        }
        indio_dev->buffer = ring;
-       /* Effectively select the ring buffer implementation */
-       ring->access = &ring_sw_access_funcs;
        ring->scan_timestamp = true;
        indio_dev->setup_ops = &adis16209_ring_setup_ops;
 
index e23622d..43ba84e 100644 (file)
@@ -110,8 +110,6 @@ int adis16240_configure_ring(struct iio_dev *indio_dev)
                return ret;
        }
        indio_dev->buffer = ring;
-       /* Effectively select the ring buffer implementation */
-       ring->access = &ring_sw_access_funcs;
        ring->scan_timestamp = true;
        indio_dev->setup_ops = &adis16240_ring_setup_ops;
 
index 2db383f..ae5f225 100644 (file)
@@ -187,12 +187,10 @@ void lis3l02dq_unconfigure_buffer(struct iio_dev *indio_dev);
 #ifdef CONFIG_LIS3L02DQ_BUF_RING_SW
 #define lis3l02dq_free_buf iio_sw_rb_free
 #define lis3l02dq_alloc_buf iio_sw_rb_allocate
-#define lis3l02dq_access_funcs ring_sw_access_funcs
 #endif
 #ifdef CONFIG_LIS3L02DQ_BUF_KFIFO
 #define lis3l02dq_free_buf iio_kfifo_free
 #define lis3l02dq_alloc_buf iio_kfifo_allocate
-#define lis3l02dq_access_funcs kfifo_access_funcs
 #endif
 irqreturn_t lis3l02dq_data_rdy_trig_poll(int irq, void *private);
 #define lis3l02dq_th lis3l02dq_data_rdy_trig_poll
index 98c5c92..ca0a1fe 100644 (file)
@@ -406,8 +406,6 @@ int lis3l02dq_configure_buffer(struct iio_dev *indio_dev)
                return -ENOMEM;
 
        indio_dev->buffer = buffer;
-       /* Effectively select the buffer implementation */
-       indio_dev->buffer->access = &lis3l02dq_access_funcs;
 
        buffer->scan_timestamp = true;
        indio_dev->setup_ops = &lis3l02dq_buffer_setup_ops;
index 45f4504..9d25165 100644 (file)
@@ -561,8 +561,6 @@ static int ad7192_register_ring_funcs_and_init(struct iio_dev *indio_dev)
                ret = -ENOMEM;
                goto error_ret;
        }
-       /* Effectively select the ring buffer implementation */
-       indio_dev->buffer->access = &ring_sw_access_funcs;
        indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
                                                 &ad7192_trigger_handler,
                                                 IRQF_ONESHOT,
index d1a12dd..feeb0ee 100644 (file)
@@ -131,9 +131,6 @@ int ad7298_register_ring_funcs_and_init(struct iio_dev *indio_dev)
                ret = -ENOMEM;
                goto error_ret;
        }
-       /* Effectively select the ring buffer implementation */
-       indio_dev->buffer->access = &ring_sw_access_funcs;
-
        indio_dev->pollfunc = iio_alloc_pollfunc(NULL,
                                                 &ad7298_trigger_handler,
                                                 IRQF_ONESHOT,
index 4e298b2..35a8576 100644 (file)
@@ -98,8 +98,6 @@ int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)
                ret = -ENOMEM;
                goto error_ret;
        }
-       /* Effectively select the ring buffer implementation */
-       indio_dev->buffer->access = &ring_sw_access_funcs;
        indio_dev->pollfunc
                = iio_alloc_pollfunc(NULL,
                                     &ad7476_trigger_handler,
index e8f94a1..1ef9fbc 100644 (file)
@@ -110,8 +110,6 @@ int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev)
                goto error_ret;
        }
 
-       /* Effectively select the ring buffer implementation */
-       indio_dev->buffer->access = &ring_sw_access_funcs;
        indio_dev->pollfunc = iio_alloc_pollfunc(&ad7606_trigger_handler_th_bh,
                                                 &ad7606_trigger_handler_th_bh,
                                                 0,
index 6a058b1..84ecde1 100644 (file)
@@ -427,8 +427,6 @@ static int ad7793_register_ring_funcs_and_init(struct iio_dev *indio_dev)
                ret = -ENOMEM;
                goto error_ret;
        }
-       /* Effectively select the ring buffer implementation */
-       indio_dev->buffer->access = &ring_sw_access_funcs;
        indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
                                                 &ad7793_trigger_handler,
                                                 IRQF_ONESHOT,
index 85076cd..d180907 100644 (file)
@@ -131,8 +131,6 @@ int ad7887_register_ring_funcs_and_init(struct iio_dev *indio_dev)
                ret = -ENOMEM;
                goto error_ret;
        }
-       /* Effectively select the ring buffer implementation */
-       indio_dev->buffer->access = &ring_sw_access_funcs;
        indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
                                                 &ad7887_trigger_handler,
                                                 IRQF_ONESHOT,
index 5dded9e..28e9a41 100644 (file)
@@ -141,8 +141,6 @@ int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev)
                ret = -ENOMEM;
                goto error_ret;
        }
-       /* Effectively select the ring buffer implementation */
-       indio_dev->buffer->access = &ring_sw_access_funcs;
        indio_dev->pollfunc = iio_alloc_pollfunc(NULL,
                                                 &ad799x_trigger_handler,
                                                 IRQF_ONESHOT,
index f730b3f..d0a60a3 100644 (file)
@@ -116,8 +116,6 @@ int max1363_register_ring_funcs_and_init(struct iio_dev *indio_dev)
                ret = -ENOMEM;
                goto error_deallocate_sw_rb;
        }
-       /* Effectively select the ring buffer implementation */
-       indio_dev->buffer->access = &ring_sw_access_funcs;
        /* Ring buffer functions - here trigger setup related */
        indio_dev->setup_ops = &max1363_ring_setup_ops;
 
index 699a615..711f151 100644 (file)
@@ -115,8 +115,6 @@ int adis16260_configure_ring(struct iio_dev *indio_dev)
                return ret;
        }
        indio_dev->buffer = ring;
-       /* Effectively select the ring buffer implementation */
-       ring->access = &ring_sw_access_funcs;
        ring->scan_timestamp = true;
        indio_dev->setup_ops = &adis16260_ring_setup_ops;
 
index d6a1c0e..bb4daf7 100644 (file)
@@ -142,8 +142,6 @@ int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev)
        }
 
        indio_dev->buffer = buffer;
-       /* Tell the core how to access the buffer */
-       buffer->access = &kfifo_access_funcs;
 
        /* Enable timestamps by default */
        buffer->scan_timestamp = true;
index 9a2ca55..cd82b56 100644 (file)
@@ -607,9 +607,6 @@ static int ad5933_register_ring_funcs_and_init(struct iio_dev *indio_dev)
        if (!indio_dev->buffer)
                return -ENOMEM;
 
-       /* Effectively select the ring buffer implementation */
-       indio_dev->buffer->access = &ring_sw_access_funcs;
-
        /* Ring buffer functions - here trigger setup related */
        indio_dev->setup_ops = &ad5933_ring_setup_ops;
 
index ac22de5..8daa038 100644 (file)
@@ -187,8 +187,6 @@ int adis16400_configure_ring(struct iio_dev *indio_dev)
                return ret;
        }
        indio_dev->buffer = ring;
-       /* Effectively select the ring buffer implementation */
-       ring->access = &ring_sw_access_funcs;
        ring->scan_timestamp = true;
        indio_dev->setup_ops = &adis16400_ring_setup_ops;
 
index e1e9c06..9f3bd59 100644 (file)
@@ -59,21 +59,6 @@ static struct attribute_group iio_kfifo_attribute_group = {
        .name = "buffer",
 };
 
-struct iio_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev)
-{
-       struct iio_kfifo *kf;
-
-       kf = kzalloc(sizeof *kf, GFP_KERNEL);
-       if (!kf)
-               return NULL;
-       kf->update_needed = true;
-       iio_buffer_init(&kf->buffer);
-       kf->buffer.attrs = &iio_kfifo_attribute_group;
-
-       return &kf->buffer;
-}
-EXPORT_SYMBOL(iio_kfifo_allocate);
-
 static int iio_get_bytes_per_datum_kfifo(struct iio_buffer *r)
 {
        return r->bytes_per_datum;
@@ -104,12 +89,6 @@ static int iio_set_length_kfifo(struct iio_buffer *r, int length)
        return 0;
 }
 
-void iio_kfifo_free(struct iio_buffer *r)
-{
-       kfree(iio_to_kfifo(r));
-}
-EXPORT_SYMBOL(iio_kfifo_free);
-
 static int iio_store_to_kfifo(struct iio_buffer *r,
                              u8 *data,
                              s64 timestamp)
@@ -137,7 +116,7 @@ static int iio_read_first_n_kfifo(struct iio_buffer *r,
        return copied;
 }
 
-const struct iio_buffer_access_funcs kfifo_access_funcs = {
+static const struct iio_buffer_access_funcs kfifo_access_funcs = {
        .store_to = &iio_store_to_kfifo,
        .read_first_n = &iio_read_first_n_kfifo,
        .request_update = &iio_request_update_kfifo,
@@ -146,6 +125,27 @@ const struct iio_buffer_access_funcs kfifo_access_funcs = {
        .get_length = &iio_get_length_kfifo,
        .set_length = &iio_set_length_kfifo,
 };
-EXPORT_SYMBOL(kfifo_access_funcs);
+
+struct iio_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev)
+{
+       struct iio_kfifo *kf;
+
+       kf = kzalloc(sizeof *kf, GFP_KERNEL);
+       if (!kf)
+               return NULL;
+       kf->update_needed = true;
+       iio_buffer_init(&kf->buffer);
+       kf->buffer.attrs = &iio_kfifo_attribute_group;
+       kf->buffer.access = &kfifo_access_funcs;
+
+       return &kf->buffer;
+}
+EXPORT_SYMBOL(iio_kfifo_allocate);
+
+void iio_kfifo_free(struct iio_buffer *r)
+{
+       kfree(iio_to_kfifo(r));
+}
+EXPORT_SYMBOL(iio_kfifo_free);
 
 MODULE_LICENSE("GPL");
index cc2bd9a..9f7da01 100644 (file)
@@ -3,8 +3,6 @@
 #include "iio.h"
 #include "buffer.h"
 
-extern const struct iio_buffer_access_funcs kfifo_access_funcs;
-
 struct iio_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev);
 void iio_kfifo_free(struct iio_buffer *r);
 
index f29f2b2..c5c522b 100644 (file)
@@ -144,8 +144,6 @@ int ade7758_configure_ring(struct iio_dev *indio_dev)
                return ret;
        }
 
-       /* Effectively select the ring buffer implementation */
-       indio_dev->buffer->access = &ring_sw_access_funcs;
        indio_dev->setup_ops = &ade7758_ring_setup_ops;
 
        indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
index 3e24ec4..eeac0da 100644 (file)
@@ -329,6 +329,16 @@ static struct attribute_group iio_ring_attribute_group = {
        .name = "buffer",
 };
 
+static const struct iio_buffer_access_funcs ring_sw_access_funcs = {
+       .store_to = &iio_store_to_sw_rb,
+       .read_first_n = &iio_read_first_n_sw_rb,
+       .request_update = &iio_request_update_sw_rb,
+       .get_bytes_per_datum = &iio_get_bytes_per_datum_sw_rb,
+       .set_bytes_per_datum = &iio_set_bytes_per_datum_sw_rb,
+       .get_length = &iio_get_length_sw_rb,
+       .set_length = &iio_set_length_sw_rb,
+};
+
 struct iio_buffer *iio_sw_rb_allocate(struct iio_dev *indio_dev)
 {
        struct iio_buffer *buf;
@@ -341,6 +351,7 @@ struct iio_buffer *iio_sw_rb_allocate(struct iio_dev *indio_dev)
        buf = &ring->buf;
        iio_buffer_init(buf);
        buf->attrs = &iio_ring_attribute_group;
+       buf->access = &ring_sw_access_funcs;
 
        return buf;
 }
@@ -352,16 +363,5 @@ void iio_sw_rb_free(struct iio_buffer *r)
 }
 EXPORT_SYMBOL(iio_sw_rb_free);
 
-const struct iio_buffer_access_funcs ring_sw_access_funcs = {
-       .store_to = &iio_store_to_sw_rb,
-       .read_first_n = &iio_read_first_n_sw_rb,
-       .request_update = &iio_request_update_sw_rb,
-       .get_bytes_per_datum = &iio_get_bytes_per_datum_sw_rb,
-       .set_bytes_per_datum = &iio_set_bytes_per_datum_sw_rb,
-       .get_length = &iio_get_length_sw_rb,
-       .set_length = &iio_set_length_sw_rb,
-};
-EXPORT_SYMBOL(ring_sw_access_funcs);
-
 MODULE_DESCRIPTION("Industrialio I/O software ring buffer");
 MODULE_LICENSE("GPL");
index e6a6e2c..7556e21 100644 (file)
 #define _IIO_RING_SW_H_
 #include "buffer.h"
 
-/**
- * ring_sw_access_funcs - access functions for a software ring buffer
- **/
-extern const struct iio_buffer_access_funcs ring_sw_access_funcs;
-
 struct iio_buffer *iio_sw_rb_allocate(struct iio_dev *indio_dev);
 void iio_sw_rb_free(struct iio_buffer *ring);
 #endif /* _IIO_RING_SW_H_ */