staging:iio:accel:lis3l02dq ring->buffer renames.

This driver already supports kfifo usage, so the term ring is
misleading and hence replaced.

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-09-21 11:15:58 +01:00 committed by Greg Kroah-Hartman
parent 14555b1445
commit 6ddbb08af0
3 changed files with 61 additions and 60 deletions

View File

@ -175,19 +175,19 @@ int lis3l02dq_spi_write_reg_8(struct iio_dev *indio_dev,
int lis3l02dq_disable_all_events(struct iio_dev *indio_dev); int lis3l02dq_disable_all_events(struct iio_dev *indio_dev);
#ifdef CONFIG_IIO_BUFFER #ifdef CONFIG_IIO_BUFFER
/* At the moment triggers are only used for ring buffer /* At the moment triggers are only used for buffer
* filling. This may change! * filling. This may change!
*/ */
void lis3l02dq_remove_trigger(struct iio_dev *indio_dev); void lis3l02dq_remove_trigger(struct iio_dev *indio_dev);
int lis3l02dq_probe_trigger(struct iio_dev *indio_dev); int lis3l02dq_probe_trigger(struct iio_dev *indio_dev);
ssize_t lis3l02dq_read_accel_from_ring(struct iio_buffer *ring, ssize_t lis3l02dq_read_accel_from_buffer(struct iio_buffer *buffer,
int index, int index,
int *val); int *val);
int lis3l02dq_configure_ring(struct iio_dev *indio_dev); int lis3l02dq_configure_buffer(struct iio_dev *indio_dev);
void lis3l02dq_unconfigure_ring(struct iio_dev *indio_dev); void lis3l02dq_unconfigure_buffer(struct iio_dev *indio_dev);
#ifdef CONFIG_LIS3L02DQ_BUF_RING_SW #ifdef CONFIG_LIS3L02DQ_BUF_RING_SW
#define lis3l02dq_free_buf iio_sw_rb_free #define lis3l02dq_free_buf iio_sw_rb_free
@ -203,7 +203,7 @@ irqreturn_t lis3l02dq_data_rdy_trig_poll(int irq, void *private);
#define lis3l02dq_th lis3l02dq_data_rdy_trig_poll #define lis3l02dq_th lis3l02dq_data_rdy_trig_poll
#else /* CONFIG_IIO_BUFFER */ #else /* CONFIG_IIO_BUFFER */
#define lis3l02dq_th lis3l02dq_noring #define lis3l02dq_th lis3l02dq_nobuffer
static inline void lis3l02dq_remove_trigger(struct iio_dev *indio_dev) static inline void lis3l02dq_remove_trigger(struct iio_dev *indio_dev)
{ {
@ -213,18 +213,18 @@ static inline int lis3l02dq_probe_trigger(struct iio_dev *indio_dev)
return 0; return 0;
} }
static inline ssize_t static inline ssize_t
lis3l02dq_read_accel_from_ring(struct iio_buffer *ring, lis3l02dq_read_accel_from_buffer(struct iio_buffer *buffer,
int index, int index,
int *val) int *val)
{ {
return 0; return 0;
} }
static int lis3l02dq_configure_ring(struct iio_dev *indio_dev) static int lis3l02dq_configure_buffer(struct iio_dev *indio_dev)
{ {
return 0; return 0;
} }
static inline void lis3l02dq_unconfigure_ring(struct iio_dev *indio_dev) static inline void lis3l02dq_unconfigure_buffer(struct iio_dev *indio_dev)
{ {
} }
#endif /* CONFIG_IIO_BUFFER */ #endif /* CONFIG_IIO_BUFFER */

View File

@ -35,7 +35,7 @@
*/ */
/* direct copy of the irq_default_primary_handler */ /* direct copy of the irq_default_primary_handler */
#ifndef CONFIG_IIO_BUFFER #ifndef CONFIG_IIO_BUFFER
static irqreturn_t lis3l02dq_noring(int irq, void *private) static irqreturn_t lis3l02dq_nobuffer(int irq, void *private)
{ {
return IRQ_WAKE_THREAD; return IRQ_WAKE_THREAD;
} }
@ -260,9 +260,10 @@ static int lis3l02dq_read_raw(struct iio_dev *indio_dev,
/* Take the iio_dev status lock */ /* Take the iio_dev status lock */
mutex_lock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED)
ret = lis3l02dq_read_accel_from_ring(indio_dev->buffer, ret = lis3l02dq_read_accel_from_buffer(indio_dev->
chan->scan_index, buffer,
val); chan->scan_index,
val);
else { else {
reg = lis3l02dq_axis_map reg = lis3l02dq_axis_map
[LIS3L02DQ_ACCEL][chan->address]; [LIS3L02DQ_ACCEL][chan->address];
@ -686,7 +687,7 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi)
indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->modes = INDIO_DIRECT_MODE;
ret = lis3l02dq_configure_ring(indio_dev); ret = lis3l02dq_configure_buffer(indio_dev);
if (ret) if (ret)
goto error_free_dev; goto error_free_dev;
@ -694,8 +695,8 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi)
lis3l02dq_channels, lis3l02dq_channels,
ARRAY_SIZE(lis3l02dq_channels)); ARRAY_SIZE(lis3l02dq_channels));
if (ret) { if (ret) {
printk(KERN_ERR "failed to initialize the ring\n"); printk(KERN_ERR "failed to initialize the buffer\n");
goto error_unreg_ring_funcs; goto error_unreg_buffer_funcs;
} }
if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) { if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) {
@ -706,7 +707,7 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi)
"lis3l02dq", "lis3l02dq",
indio_dev); indio_dev);
if (ret) if (ret)
goto error_uninitialize_ring; goto error_uninitialize_buffer;
ret = lis3l02dq_probe_trigger(indio_dev); ret = lis3l02dq_probe_trigger(indio_dev);
if (ret) if (ret)
@ -730,10 +731,10 @@ error_remove_trigger:
error_free_interrupt: error_free_interrupt:
if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0)
free_irq(st->us->irq, indio_dev); free_irq(st->us->irq, indio_dev);
error_uninitialize_ring: error_uninitialize_buffer:
iio_buffer_unregister(indio_dev); iio_buffer_unregister(indio_dev);
error_unreg_ring_funcs: error_unreg_buffer_funcs:
lis3l02dq_unconfigure_ring(indio_dev); lis3l02dq_unconfigure_buffer(indio_dev);
error_free_dev: error_free_dev:
iio_free_device(indio_dev); iio_free_device(indio_dev);
error_ret: error_ret:
@ -786,7 +787,7 @@ static int lis3l02dq_remove(struct spi_device *spi)
lis3l02dq_remove_trigger(indio_dev); lis3l02dq_remove_trigger(indio_dev);
iio_buffer_unregister(indio_dev); iio_buffer_unregister(indio_dev);
lis3l02dq_unconfigure_ring(indio_dev); lis3l02dq_unconfigure_buffer(indio_dev);
iio_device_unregister(indio_dev); iio_device_unregister(indio_dev);

View File

@ -38,30 +38,30 @@ irqreturn_t lis3l02dq_data_rdy_trig_poll(int irq, void *private)
} }
/** /**
* lis3l02dq_read_accel_from_ring() individual acceleration read from ring * lis3l02dq_read_accel_from_buffer() individual acceleration read from buffer
**/ **/
ssize_t lis3l02dq_read_accel_from_ring(struct iio_buffer *ring, ssize_t lis3l02dq_read_accel_from_buffer(struct iio_buffer *buffer,
int index, int index,
int *val) int *val)
{ {
int ret; int ret;
s16 *data; s16 *data;
if (!iio_scan_mask_query(ring, index)) if (!iio_scan_mask_query(buffer, index))
return -EINVAL; return -EINVAL;
if (!ring->access->read_last) if (!buffer->access->read_last)
return -EBUSY; return -EBUSY;
data = kmalloc(ring->access->get_bytes_per_datum(ring), data = kmalloc(buffer->access->get_bytes_per_datum(buffer),
GFP_KERNEL); GFP_KERNEL);
if (data == NULL) if (data == NULL)
return -ENOMEM; return -ENOMEM;
ret = ring->access->read_last(ring, (u8 *)data); ret = buffer->access->read_last(buffer, (u8 *)data);
if (ret) if (ret)
goto error_free_data; goto error_free_data;
*val = data[bitmap_weight(ring->scan_mask, index)]; *val = data[bitmap_weight(buffer->scan_mask, index)];
error_free_data: error_free_data:
kfree(data); kfree(data);
@ -86,13 +86,13 @@ static const u8 read_all_tx_array[] = {
**/ **/
static int lis3l02dq_read_all(struct iio_dev *indio_dev, u8 *rx_array) static int lis3l02dq_read_all(struct iio_dev *indio_dev, u8 *rx_array)
{ {
struct iio_buffer *ring = indio_dev->buffer; struct iio_buffer *buffer = indio_dev->buffer;
struct lis3l02dq_state *st = iio_priv(indio_dev); struct lis3l02dq_state *st = iio_priv(indio_dev);
struct spi_transfer *xfers; struct spi_transfer *xfers;
struct spi_message msg; struct spi_message msg;
int ret, i, j = 0; int ret, i, j = 0;
xfers = kzalloc((ring->scan_count) * 2 xfers = kzalloc((buffer->scan_count) * 2
* sizeof(*xfers), GFP_KERNEL); * sizeof(*xfers), GFP_KERNEL);
if (!xfers) if (!xfers)
return -ENOMEM; return -ENOMEM;
@ -100,7 +100,7 @@ static int lis3l02dq_read_all(struct iio_dev *indio_dev, u8 *rx_array)
mutex_lock(&st->buf_lock); mutex_lock(&st->buf_lock);
for (i = 0; i < ARRAY_SIZE(read_all_tx_array)/4; i++) for (i = 0; i < ARRAY_SIZE(read_all_tx_array)/4; i++)
if (test_bit(i, ring->scan_mask)) { if (test_bit(i, buffer->scan_mask)) {
/* lower byte */ /* lower byte */
xfers[j].tx_buf = st->tx + 2*j; xfers[j].tx_buf = st->tx + 2*j;
st->tx[2*j] = read_all_tx_array[i*4]; st->tx[2*j] = read_all_tx_array[i*4];
@ -128,7 +128,7 @@ static int lis3l02dq_read_all(struct iio_dev *indio_dev, u8 *rx_array)
* values in alternate bytes * values in alternate bytes
*/ */
spi_message_init(&msg); spi_message_init(&msg);
for (j = 0; j < ring->scan_count * 2; j++) for (j = 0; j < buffer->scan_count * 2; j++)
spi_message_add_tail(&xfers[j], &msg); spi_message_add_tail(&xfers[j], &msg);
ret = spi_sync(st->us, &msg); ret = spi_sync(st->us, &msg);
@ -138,7 +138,7 @@ static int lis3l02dq_read_all(struct iio_dev *indio_dev, u8 *rx_array)
return ret; return ret;
} }
static int lis3l02dq_get_ring_element(struct iio_dev *indio_dev, static int lis3l02dq_get_buffer_element(struct iio_dev *indio_dev,
u8 *buf) u8 *buf)
{ {
int ret, i; int ret, i;
@ -163,26 +163,26 @@ static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p)
{ {
struct iio_poll_func *pf = p; struct iio_poll_func *pf = p;
struct iio_dev *indio_dev = pf->indio_dev; struct iio_dev *indio_dev = pf->indio_dev;
struct iio_buffer *ring = indio_dev->buffer; struct iio_buffer *buffer = indio_dev->buffer;
int len = 0; int len = 0;
size_t datasize = ring->access->get_bytes_per_datum(ring); size_t datasize = buffer->access->get_bytes_per_datum(buffer);
char *data = kmalloc(datasize, GFP_KERNEL); char *data = kmalloc(datasize, GFP_KERNEL);
if (data == NULL) { if (data == NULL) {
dev_err(indio_dev->dev.parent, dev_err(indio_dev->dev.parent,
"memory alloc failed in ring bh"); "memory alloc failed in buffer bh");
return -ENOMEM; return -ENOMEM;
} }
if (ring->scan_count) if (buffer->scan_count)
len = lis3l02dq_get_ring_element(indio_dev, data); len = lis3l02dq_get_buffer_element(indio_dev, data);
/* Guaranteed to be aligned with 8 byte boundary */ /* Guaranteed to be aligned with 8 byte boundary */
if (ring->scan_timestamp) if (buffer->scan_timestamp)
*(s64 *)(((phys_addr_t)data + len *(s64 *)(((phys_addr_t)data + len
+ sizeof(s64) - 1) & ~(sizeof(s64) - 1)) + sizeof(s64) - 1) & ~(sizeof(s64) - 1))
= pf->timestamp; = pf->timestamp;
ring->access->store_to(ring, (u8 *)data, pf->timestamp); buffer->access->store_to(buffer, (u8 *)data, pf->timestamp);
iio_trigger_notify_done(indio_dev->trig); iio_trigger_notify_done(indio_dev->trig);
kfree(data); kfree(data);
@ -255,7 +255,7 @@ error_ret:
* *
* If disabling the interrupt also does a final read to ensure it is clear. * If disabling the interrupt also does a final read to ensure it is clear.
* This is only important in some cases where the scan enable elements are * This is only important in some cases where the scan enable elements are
* switched before the ring is reenabled. * switched before the buffer is reenabled.
**/ **/
static int lis3l02dq_data_rdy_trigger_set_state(struct iio_trigger *trig, static int lis3l02dq_data_rdy_trigger_set_state(struct iio_trigger *trig,
bool state) bool state)
@ -343,13 +343,13 @@ void lis3l02dq_remove_trigger(struct iio_dev *indio_dev)
iio_free_trigger(st->trig); iio_free_trigger(st->trig);
} }
void lis3l02dq_unconfigure_ring(struct iio_dev *indio_dev) void lis3l02dq_unconfigure_buffer(struct iio_dev *indio_dev)
{ {
iio_dealloc_pollfunc(indio_dev->pollfunc); iio_dealloc_pollfunc(indio_dev->pollfunc);
lis3l02dq_free_buf(indio_dev->buffer); lis3l02dq_free_buf(indio_dev->buffer);
} }
static int lis3l02dq_ring_postenable(struct iio_dev *indio_dev) static int lis3l02dq_buffer_postenable(struct iio_dev *indio_dev)
{ {
/* Disable unwanted channels otherwise the interrupt will not clear */ /* Disable unwanted channels otherwise the interrupt will not clear */
u8 t; u8 t;
@ -392,7 +392,7 @@ error_ret:
} }
/* Turn all channels on again */ /* Turn all channels on again */
static int lis3l02dq_ring_predisable(struct iio_dev *indio_dev) static int lis3l02dq_buffer_predisable(struct iio_dev *indio_dev)
{ {
u8 t; u8 t;
int ret; int ret;
@ -418,29 +418,29 @@ error_ret:
return ret; return ret;
} }
static const struct iio_buffer_setup_ops lis3l02dq_ring_setup_ops = { static const struct iio_buffer_setup_ops lis3l02dq_buffer_setup_ops = {
.preenable = &iio_sw_buffer_preenable, .preenable = &iio_sw_buffer_preenable,
.postenable = &lis3l02dq_ring_postenable, .postenable = &lis3l02dq_buffer_postenable,
.predisable = &lis3l02dq_ring_predisable, .predisable = &lis3l02dq_buffer_predisable,
}; };
int lis3l02dq_configure_ring(struct iio_dev *indio_dev) int lis3l02dq_configure_buffer(struct iio_dev *indio_dev)
{ {
int ret; int ret;
struct iio_buffer *ring; struct iio_buffer *buffer;
ring = lis3l02dq_alloc_buf(indio_dev); buffer = lis3l02dq_alloc_buf(indio_dev);
if (!ring) if (!buffer)
return -ENOMEM; return -ENOMEM;
indio_dev->buffer = ring; indio_dev->buffer = buffer;
/* Effectively select the ring buffer implementation */ /* Effectively select the buffer implementation */
indio_dev->buffer->access = &lis3l02dq_access_funcs; indio_dev->buffer->access = &lis3l02dq_access_funcs;
ring->bpe = 2; buffer->bpe = 2;
ring->scan_timestamp = true; buffer->scan_timestamp = true;
ring->setup_ops = &lis3l02dq_ring_setup_ops; buffer->setup_ops = &lis3l02dq_buffer_setup_ops;
ring->owner = THIS_MODULE; buffer->owner = THIS_MODULE;
/* Functions are NULL as we set handler below */ /* Functions are NULL as we set handler below */
indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time, indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,