diff options
author | Jonathan Cameron <jic23@cam.ac.uk> | 2011-05-18 14:42:24 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-05-19 16:15:03 -0700 |
commit | 5565a450248d827afa949aab157873d4b9be329e (patch) | |
tree | ef63d8173f83e685b00cdf41435575cfd34d84f2 /drivers/staging/iio/kfifo_buf.c | |
parent | 38d15f06f942306050a063abd111467d39c5cc37 (diff) | |
download | op-kernel-dev-5565a450248d827afa949aab157873d4b9be329e.zip op-kernel-dev-5565a450248d827afa949aab157873d4b9be329e.tar.gz |
staging:iio: rationalization of different buffer implementation hooks.
1) move a generic helper function out of ring_sw. It applies to other buffers as well.
2) Get rid of a lot of left over function definitions.
3) Move all the access functions into static structures.
4) Introduce and use a static structure for the setup functions, preenable etc.
Some driver conversions thanks to Michael Hennerich (pulled out of patches
that would otherwise sit after this).
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/iio/kfifo_buf.c')
-rw-r--r-- | drivers/staging/iio/kfifo_buf.c | 58 |
1 files changed, 34 insertions, 24 deletions
diff --git a/drivers/staging/iio/kfifo_buf.c b/drivers/staging/iio/kfifo_buf.c index fdd5d9e..cc14b96 100644 --- a/drivers/staging/iio/kfifo_buf.c +++ b/drivers/staging/iio/kfifo_buf.c @@ -8,6 +8,8 @@ #include "kfifo_buf.h" +#define iio_to_kfifo(r) container_of(r, struct iio_kfifo, ring) + static inline int __iio_allocate_kfifo(struct iio_kfifo *buf, int bytes_per_datum, int length) { @@ -18,7 +20,7 @@ static inline int __iio_allocate_kfifo(struct iio_kfifo *buf, return kfifo_alloc(&buf->kf, bytes_per_datum*length, GFP_KERNEL); } -int iio_request_update_kfifo(struct iio_ring_buffer *r) +static int iio_request_update_kfifo(struct iio_ring_buffer *r) { int ret = 0; struct iio_kfifo *buf = iio_to_kfifo(r); @@ -37,31 +39,27 @@ error_ret: mutex_unlock(&buf->use_lock); return ret; } -EXPORT_SYMBOL(iio_request_update_kfifo); -void iio_mark_kfifo_in_use(struct iio_ring_buffer *r) +static void iio_mark_kfifo_in_use(struct iio_ring_buffer *r) { struct iio_kfifo *buf = iio_to_kfifo(r); mutex_lock(&buf->use_lock); buf->use_count++; mutex_unlock(&buf->use_lock); } -EXPORT_SYMBOL(iio_mark_kfifo_in_use); -void iio_unmark_kfifo_in_use(struct iio_ring_buffer *r) +static void iio_unmark_kfifo_in_use(struct iio_ring_buffer *r) { struct iio_kfifo *buf = iio_to_kfifo(r); mutex_lock(&buf->use_lock); buf->use_count--; mutex_unlock(&buf->use_lock); } -EXPORT_SYMBOL(iio_unmark_kfifo_in_use); -int iio_get_length_kfifo(struct iio_ring_buffer *r) +static int iio_get_length_kfifo(struct iio_ring_buffer *r) { return r->length; } -EXPORT_SYMBOL(iio_get_length_kfifo); static inline void __iio_init_kfifo(struct iio_kfifo *kf) { @@ -108,6 +106,7 @@ struct iio_ring_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev) kf = kzalloc(sizeof *kf, GFP_KERNEL); if (!kf) return NULL; + kf->update_needed = true; iio_ring_buffer_init(&kf->ring, indio_dev); __iio_init_kfifo(kf); kf->ring.dev.type = &iio_kfifo_type; @@ -120,41 +119,37 @@ struct iio_ring_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev) } EXPORT_SYMBOL(iio_kfifo_allocate); -int iio_get_bytes_per_datum_kfifo(struct iio_ring_buffer *r) +static int iio_get_bytes_per_datum_kfifo(struct iio_ring_buffer *r) { return r->bytes_per_datum; } -EXPORT_SYMBOL(iio_get_bytes_per_datum_kfifo); -int iio_set_bytes_per_datum_kfifo(struct iio_ring_buffer *r, size_t bpd) +static int iio_set_bytes_per_datum_kfifo(struct iio_ring_buffer *r, size_t bpd) { if (r->bytes_per_datum != bpd) { r->bytes_per_datum = bpd; - if (r->access.mark_param_change) - r->access.mark_param_change(r); + if (r->access->mark_param_change) + r->access->mark_param_change(r); } return 0; } -EXPORT_SYMBOL(iio_set_bytes_per_datum_kfifo); -int iio_mark_update_needed_kfifo(struct iio_ring_buffer *r) +static int iio_mark_update_needed_kfifo(struct iio_ring_buffer *r) { struct iio_kfifo *kf = iio_to_kfifo(r); kf->update_needed = true; return 0; } -EXPORT_SYMBOL(iio_mark_update_needed_kfifo); -int iio_set_length_kfifo(struct iio_ring_buffer *r, int length) +static int iio_set_length_kfifo(struct iio_ring_buffer *r, int length) { if (r->length != length) { r->length = length; - if (r->access.mark_param_change) - r->access.mark_param_change(r); + if (r->access->mark_param_change) + r->access->mark_param_change(r); } return 0; } -EXPORT_SYMBOL(iio_set_length_kfifo); void iio_kfifo_free(struct iio_ring_buffer *r) { @@ -163,7 +158,9 @@ void iio_kfifo_free(struct iio_ring_buffer *r) } EXPORT_SYMBOL(iio_kfifo_free); -int iio_store_to_kfifo(struct iio_ring_buffer *r, u8 *data, s64 timestamp) +static int iio_store_to_kfifo(struct iio_ring_buffer *r, + u8 *data, + s64 timestamp) { int ret; struct iio_kfifo *kf = iio_to_kfifo(r); @@ -179,9 +176,8 @@ int iio_store_to_kfifo(struct iio_ring_buffer *r, u8 *data, s64 timestamp) kfree(datal); return 0; } -EXPORT_SYMBOL(iio_store_to_kfifo); -int iio_read_first_n_kfifo(struct iio_ring_buffer *r, +static int iio_read_first_n_kfifo(struct iio_ring_buffer *r, size_t n, char __user *buf) { int ret, copied; @@ -191,5 +187,19 @@ int iio_read_first_n_kfifo(struct iio_ring_buffer *r, return copied; } -EXPORT_SYMBOL(iio_read_first_n_kfifo); + +const struct iio_ring_access_funcs kfifo_access_funcs = { + .mark_in_use = &iio_mark_kfifo_in_use, + .unmark_in_use = &iio_unmark_kfifo_in_use, + .store_to = &iio_store_to_kfifo, + .read_first_n = &iio_read_first_n_kfifo, + .mark_param_change = &iio_mark_update_needed_kfifo, + .request_update = &iio_request_update_kfifo, + .get_bytes_per_datum = &iio_get_bytes_per_datum_kfifo, + .set_bytes_per_datum = &iio_set_bytes_per_datum_kfifo, + .get_length = &iio_get_length_kfifo, + .set_length = &iio_set_length_kfifo, +}; +EXPORT_SYMBOL(kfifo_access_funcs); + MODULE_LICENSE("GPL"); |