diff options
Diffstat (limited to 'drivers/staging/iio/accel/lis3l02dq_core.c')
-rw-r--r-- | drivers/staging/iio/accel/lis3l02dq_core.c | 114 |
1 files changed, 55 insertions, 59 deletions
diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index a29dfd27d440..559545a42333 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -21,12 +21,11 @@ #include <linux/spi/spi.h> #include <linux/slab.h> #include <linux/sysfs.h> +#include <linux/module.h> #include "../iio.h" #include "../sysfs.h" -#include "../ring_generic.h" - -#include "accel.h" +#include "../buffer_generic.h" #include "lis3l02dq.h" @@ -35,8 +34,8 @@ * This means that use cannot be made of spi_write etc. */ /* direct copy of the irq_default_primary_handler */ -#ifndef CONFIG_IIO_RING_BUFFER -static irqreturn_t lis3l02dq_noring(int irq, void *private) +#ifndef CONFIG_IIO_BUFFER +static irqreturn_t lis3l02dq_nobuffer(int irq, void *private) { return IRQ_WAKE_THREAD; } @@ -201,14 +200,14 @@ static u8 lis3l02dq_axis_map[3][3] = { }; static int lis3l02dq_read_thresh(struct iio_dev *indio_dev, - int e, + u64 e, int *val) { return lis3l02dq_read_reg_s16(indio_dev, LIS3L02DQ_REG_THS_L_ADDR, val); } static int lis3l02dq_write_thresh(struct iio_dev *indio_dev, - int event_code, + u64 event_code, int val) { u16 value = val; @@ -260,10 +259,11 @@ static int lis3l02dq_read_raw(struct iio_dev *indio_dev, case 0: /* Take the iio_dev status lock */ mutex_lock(&indio_dev->mlock); - if (indio_dev->currentmode == INDIO_RING_TRIGGERED) - ret = lis3l02dq_read_accel_from_ring(indio_dev->ring, - chan->scan_index, - val); + if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) + ret = lis3l02dq_read_accel_from_buffer(indio_dev-> + buffer, + chan->scan_index, + val); else { reg = lis3l02dq_axis_map [LIS3L02DQ_ACCEL][chan->address]; @@ -453,55 +453,55 @@ static irqreturn_t lis3l02dq_event_handler(int irq, void *private) &t); if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Z_HIGH) - iio_push_event(indio_dev, 0, - IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL, + iio_push_event(indio_dev, + IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, - IIO_EV_MOD_Z, + IIO_MOD_Z, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), timestamp); if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Z_LOW) - iio_push_event(indio_dev, 0, - IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL, + iio_push_event(indio_dev, + IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, - IIO_EV_MOD_Z, + IIO_MOD_Z, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), timestamp); if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Y_HIGH) - iio_push_event(indio_dev, 0, - IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL, + iio_push_event(indio_dev, + IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, - IIO_EV_MOD_Y, + IIO_MOD_Y, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), timestamp); if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Y_LOW) - iio_push_event(indio_dev, 0, - IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL, + iio_push_event(indio_dev, + IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, - IIO_EV_MOD_Y, + IIO_MOD_Y, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), timestamp); if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_X_HIGH) - iio_push_event(indio_dev, 0, - IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL, + iio_push_event(indio_dev, + IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, - IIO_EV_MOD_X, + IIO_MOD_X, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), timestamp); if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_X_LOW) - iio_push_event(indio_dev, 0, - IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL, + iio_push_event(indio_dev, + IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, - IIO_EV_MOD_X, + IIO_MOD_X, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), timestamp); @@ -535,7 +535,7 @@ static struct iio_chan_spec lis3l02dq_channels[] = { static ssize_t lis3l02dq_read_event_config(struct iio_dev *indio_dev, - int event_code) + u64 event_code) { u8 val; @@ -587,7 +587,7 @@ error_ret: } static int lis3l02dq_write_event_config(struct iio_dev *indio_dev, - int event_code, + u64 event_code, int state) { int ret = 0; @@ -652,7 +652,6 @@ static const struct attribute_group lis3l02dq_attribute_group = { }; static const struct iio_info lis3l02dq_info = { - .num_interrupt_lines = 1, .read_raw = &lis3l02dq_read_raw, .write_raw = &lis3l02dq_write_raw, .read_event_value = &lis3l02dq_read_thresh, @@ -665,7 +664,7 @@ static const struct iio_info lis3l02dq_info = { static int __devinit lis3l02dq_probe(struct spi_device *spi) { - int ret, regdone = 0; + int ret; struct lis3l02dq_state *st; struct iio_dev *indio_dev; @@ -688,21 +687,16 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi) indio_dev->modes = INDIO_DIRECT_MODE; - ret = lis3l02dq_configure_ring(indio_dev); + ret = lis3l02dq_configure_buffer(indio_dev); if (ret) goto error_free_dev; - ret = iio_device_register(indio_dev); - if (ret) - goto error_unreg_ring_funcs; - regdone = 1; - - ret = iio_ring_buffer_register_ex(indio_dev->ring, 0, - lis3l02dq_channels, - ARRAY_SIZE(lis3l02dq_channels)); + ret = iio_buffer_register(indio_dev, + lis3l02dq_channels, + ARRAY_SIZE(lis3l02dq_channels)); if (ret) { - printk(KERN_ERR "failed to initialize the ring\n"); - goto error_unreg_ring_funcs; + printk(KERN_ERR "failed to initialize the buffer\n"); + goto error_unreg_buffer_funcs; } if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) { @@ -713,7 +707,7 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi) "lis3l02dq", indio_dev); if (ret) - goto error_uninitialize_ring; + goto error_uninitialize_buffer; ret = lis3l02dq_probe_trigger(indio_dev); if (ret) @@ -724,23 +718,25 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi) ret = lis3l02dq_initial_setup(indio_dev); if (ret) goto error_remove_trigger; + + ret = iio_device_register(indio_dev); + if (ret) + goto error_remove_trigger; + return 0; error_remove_trigger: - if (indio_dev->modes & INDIO_RING_TRIGGERED) + if (indio_dev->modes & INDIO_BUFFER_TRIGGERED) lis3l02dq_remove_trigger(indio_dev); error_free_interrupt: if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) free_irq(st->us->irq, indio_dev); -error_uninitialize_ring: - iio_ring_buffer_unregister(indio_dev->ring); -error_unreg_ring_funcs: - lis3l02dq_unconfigure_ring(indio_dev); +error_uninitialize_buffer: + iio_buffer_unregister(indio_dev); +error_unreg_buffer_funcs: + lis3l02dq_unconfigure_buffer(indio_dev); error_free_dev: - if (regdone) - iio_device_unregister(indio_dev); - else - iio_free_device(indio_dev); + iio_free_device(indio_dev); error_ret: return ret; } @@ -778,6 +774,8 @@ static int lis3l02dq_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); struct lis3l02dq_state *st = iio_priv(indio_dev); + iio_device_unregister(indio_dev); + ret = lis3l02dq_disable_all_events(indio_dev); if (ret) goto err_ret; @@ -790,12 +788,10 @@ static int lis3l02dq_remove(struct spi_device *spi) free_irq(st->us->irq, indio_dev); lis3l02dq_remove_trigger(indio_dev); - iio_ring_buffer_unregister(indio_dev->ring); - lis3l02dq_unconfigure_ring(indio_dev); - iio_device_unregister(indio_dev); - - return 0; + iio_buffer_unregister(indio_dev); + lis3l02dq_unconfigure_buffer(indio_dev); + iio_free_device(indio_dev); err_ret: return ret; } |