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 26c610faee3fd3c835b889be2ccf7bea36c3db89..97f9e6b159d9fa66222890817b9021ed64d77552 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 064640d15e41e3197f65a679dad7a7de8b156952..6a8963db4f60a77fdfb0439a2b2eb416bcf96f87 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 4081179dfa5c469f66e6d6bceffa0fd192b41502..5c8ab733886454d1eb3f075a00b98f621356f6f6 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 2a6fd334f5f13dbe11749becc993defc75ed752a..57254b6b38b73ee46fc51dbab2f6d663fbb0f03e 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 e23622d96f9f1e70445983d5fbfeb293e9c857db..43ba84e993ade65cf23bca52f04cd24781a5af94 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 2db383fc2743352da9d97178eef5b125d87b0663..ae5f225b4bb298d49796bb70a173e8fccf100de4 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 98c5c92d3450f304d080fecf66a1cb85f05051a8..ca0a1fe6ff3fab3329b74f5f07bc6fea6c18221a 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 45f4504ed9278ad72440412c14aebe9fb48c4d22..9d251653307ca888be01a083bb071baf5b7908a7 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 d1a12dd015e2ca10b96e81856919aeb08cf5f87d..feeb0eeba59ab279797e69affd83b21716de7503 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 4e298b2a05b2aedc66504672b3dd1f4eac529421..35a8576a22712bd42747c04dee662f6eed34a0fb 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 e8f94a18a9431978efa067a8b7c897b0828bc480..1ef9fbcaf2deff77582b3e2343412b7b1b817c54 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 6a058b19c49ad9df54304ae95b35c62a27034e92..84ecde1ad042221832bbd9bc8bd46c5e0fbd0fd2 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 85076cd962e7d05b06652e7074fceb4c571b05a4..d1809079b63da05ced8c52552ea5e6ac093edcfd 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 5dded9e7820ae96aef6b723ac2cc89a618538587..28e9a4192910a14ba858724d54056d701a3c16d2 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 f730b3fb971afd29b1583326bf2c6b2afbecdc33..d0a60a38293090b71add988f7caaa87de82aff49 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 699a6152c4093a4f3b0377f6943b41fc8c21b3ef..711f15122a08884dce317b454a35ef0eb78aeccf 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 d6a1c0e82a5b0f7d5c5c9004c7ac73f71afc17f8..bb4daf744362aaaede746176f5972497c1e5cfe3 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 9a2ca55625f407317f52364634cd3cd288ca5867..cd82b56d58af6a28bcfad305dcf95e778105f184 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 ac22de573f3e922aa4b3ee4e6ee967e5f1fcb107..8daa038b23e66171870034987b6fe13038437bbc 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 e1e9c06cde4a0de776288f8f9cb345df3c3dc419..9f3bd59c0e72bd3a0919d3b6d49a27b8750e1caa 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 cc2bd9a1ccfe66b2d13934b16c7219a243ffd636..9f7da016af04d6cd75745080ce0b2015b89accc9 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 f29f2b278fe45dad00d0b335f6965dd7166462f9..c5c522bb69ab6a4b7e35a108498a176f9514d344 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 3e24ec4558547fd2dd79530f57b149f46fa39322..eeac0daf47bd12d69042cb6a21f56cc1d002f9da 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 e6a6e2c409600e57b6fc6fe3661b1b4cc26e5a5f..7556e2122367ecbf1f979734882680ff0b576f41 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_ */