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/accel/sca3000_ring.c | |
parent | 38d15f06f942306050a063abd111467d39c5cc37 (diff) |
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/accel/sca3000_ring.c')
-rw-r--r-- | drivers/staging/iio/accel/sca3000_ring.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c index d3c37899f387..7c4ff0b1df04 100644 --- a/drivers/staging/iio/accel/sca3000_ring.c +++ b/drivers/staging/iio/accel/sca3000_ring.c @@ -367,6 +367,12 @@ static inline void sca3000_rb_free(struct iio_ring_buffer *r) iio_put_ring_buffer(r); } +static const struct iio_ring_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, +}; + int sca3000_configure_ring(struct iio_dev *indio_dev) { indio_dev->ring = sca3000_rb_allocate(indio_dev); @@ -374,10 +380,7 @@ int sca3000_configure_ring(struct iio_dev *indio_dev) return -ENOMEM; indio_dev->modes |= INDIO_RING_HARDWARE_BUFFER; - indio_dev->ring->access.read_first_n = &sca3000_read_first_n_hw_rb; - indio_dev->ring->access.get_length = &sca3000_ring_get_length; - indio_dev->ring->access.get_bytes_per_datum = - &sca3000_ring_get_bytes_per_datum; + indio_dev->ring->access = &sca3000_ring_access_funcs; iio_scan_mask_set(indio_dev->ring, 0); iio_scan_mask_set(indio_dev->ring, 1); @@ -432,10 +435,14 @@ static int sca3000_hw_ring_postdisable(struct iio_dev *indio_dev) return __sca3000_hw_ring_state_set(indio_dev, 0); } +static const struct iio_ring_setup_ops sca3000_ring_setup_ops = { + .preenable = &sca3000_hw_ring_preenable, + .postdisable = &sca3000_hw_ring_postdisable, +}; + void sca3000_register_ring_funcs(struct iio_dev *indio_dev) { - indio_dev->ring->preenable = &sca3000_hw_ring_preenable; - indio_dev->ring->postdisable = &sca3000_hw_ring_postdisable; + indio_dev->ring->setup_ops = &sca3000_ring_setup_ops; } /** |