staging:iio:lis3l02dq allow buffer implementation selection

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Jonathan Cameron 2011-02-11 13:09:11 +00:00 committed by Greg Kroah-Hartman
parent b174baf4b7
commit b949793b2c
3 changed files with 37 additions and 5 deletions

View File

@ -66,12 +66,33 @@ config LIS3L02DQ
tristate "ST Microelectronics LIS3L02DQ Accelerometer Driver" tristate "ST Microelectronics LIS3L02DQ Accelerometer Driver"
depends on SPI depends on SPI
select IIO_TRIGGER if IIO_RING_BUFFER select IIO_TRIGGER if IIO_RING_BUFFER
select IIO_SW_RING if IIO_RING_BUFFER depends on !IIO_RING_BUFFER || IIO_KFIFO_BUF || IIO_SW_RING
help help
Say yes here to build SPI support for the ST microelectronics Say yes here to build SPI support for the ST microelectronics
accelerometer. The driver supplies direct access via sysfs files accelerometer. The driver supplies direct access via sysfs files
and an event interface via a character device. and an event interface via a character device.
choice
prompt "Buffer type"
depends on LIS3L02DQ && IIO_RING_BUFFER
config LIS3L02DQ_BUF_KFIFO
depends on IIO_KFIFO_BUF
bool "Simple FIFO"
help
Kfifo based FIFO. Does not provide any events so it is up
to userspace to ensure it reads often enough that data is not
lost.
config LIS3L02DQ_BUF_RING_SW
depends on IIO_SW_RING
bool "IIO Software Ring"
help
Original IIO ring buffer implementation. Provides simple
buffer events, half full etc.
endchoice
config SCA3000 config SCA3000
depends on IIO_RING_BUFFER depends on IIO_RING_BUFFER
depends on SPI depends on SPI

View File

@ -196,6 +196,16 @@ ssize_t lis3l02dq_read_accel_from_ring(struct device *dev,
int lis3l02dq_configure_ring(struct iio_dev *indio_dev); int lis3l02dq_configure_ring(struct iio_dev *indio_dev);
void lis3l02dq_unconfigure_ring(struct iio_dev *indio_dev); void lis3l02dq_unconfigure_ring(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_register_buf_funcs iio_ring_sw_register_funcs
#endif
#ifdef CONFIG_LIS3L02DQ_BUF_KFIFO
#define lis3l02dq_free_buf iio_kfifo_free
#define lis3l02dq_alloc_buf iio_kfifo_allocate
#define lis3l02dq_register_buf_funcs iio_kfifo_register_funcs
#endif
#else /* CONFIG_IIO_RING_BUFFER */ #else /* CONFIG_IIO_RING_BUFFER */
static inline void lis3l02dq_remove_trigger(struct iio_dev *indio_dev) static inline void lis3l02dq_remove_trigger(struct iio_dev *indio_dev)

View File

@ -13,6 +13,7 @@
#include "../iio.h" #include "../iio.h"
#include "../sysfs.h" #include "../sysfs.h"
#include "../ring_sw.h" #include "../ring_sw.h"
#include "../kfifo_buf.h"
#include "accel.h" #include "accel.h"
#include "../trigger.h" #include "../trigger.h"
#include "lis3l02dq.h" #include "lis3l02dq.h"
@ -484,7 +485,7 @@ void lis3l02dq_remove_trigger(struct iio_dev *indio_dev)
void lis3l02dq_unconfigure_ring(struct iio_dev *indio_dev) void lis3l02dq_unconfigure_ring(struct iio_dev *indio_dev)
{ {
kfree(indio_dev->pollfunc); kfree(indio_dev->pollfunc);
iio_sw_rb_free(indio_dev->ring); lis3l02dq_free_buf(indio_dev->ring);
} }
int lis3l02dq_configure_ring(struct iio_dev *indio_dev) int lis3l02dq_configure_ring(struct iio_dev *indio_dev)
@ -495,13 +496,13 @@ int lis3l02dq_configure_ring(struct iio_dev *indio_dev)
INIT_WORK(&h->work_trigger_to_ring, lis3l02dq_trigger_bh_to_ring); INIT_WORK(&h->work_trigger_to_ring, lis3l02dq_trigger_bh_to_ring);
h->get_ring_element = &lis3l02dq_get_ring_element; h->get_ring_element = &lis3l02dq_get_ring_element;
ring = iio_sw_rb_allocate(indio_dev); ring = lis3l02dq_alloc_buf(indio_dev);
if (!ring) if (!ring)
return -ENOMEM; return -ENOMEM;
indio_dev->ring = ring; indio_dev->ring = ring;
/* Effectively select the ring buffer implementation */ /* Effectively select the ring buffer implementation */
iio_ring_sw_register_funcs(&ring->access); lis3l02dq_register_buf_funcs(&ring->access);
ring->bpe = 2; ring->bpe = 2;
ring->scan_el_attrs = &lis3l02dq_scan_el_group; ring->scan_el_attrs = &lis3l02dq_scan_el_group;
ring->scan_timestamp = true; ring->scan_timestamp = true;
@ -522,6 +523,6 @@ int lis3l02dq_configure_ring(struct iio_dev *indio_dev)
return 0; return 0;
error_iio_sw_rb_free: error_iio_sw_rb_free:
iio_sw_rb_free(indio_dev->ring); lis3l02dq_free_buf(indio_dev->ring);
return ret; return ret;
} }