diff options
Diffstat (limited to 'drivers/staging/iio/accel')
-rw-r--r-- | drivers/staging/iio/accel/adis16220_core.c | 6 | ||||
-rw-r--r-- | drivers/staging/iio/accel/lis3l02dq_core.c | 66 | ||||
-rw-r--r-- | drivers/staging/iio/accel/lis3l02dq_ring.c | 14 | ||||
-rw-r--r-- | drivers/staging/iio/accel/sca3000_core.c | 66 | ||||
-rw-r--r-- | drivers/staging/iio/accel/sca3000_ring.c | 19 |
5 files changed, 101 insertions, 70 deletions
diff --git a/drivers/staging/iio/accel/adis16220_core.c b/drivers/staging/iio/accel/adis16220_core.c index 5c28961..4c9364b 100644 --- a/drivers/staging/iio/accel/adis16220_core.c +++ b/drivers/staging/iio/accel/adis16220_core.c @@ -102,7 +102,6 @@ static ssize_t adis16220_capture_buffer_read(struct iio_dev *indio_dev, int addr) { struct adis16220_state *st = iio_priv(indio_dev); - struct spi_message msg; struct spi_transfer xfers[] = { { .tx_buf = st->tx, @@ -147,10 +146,7 @@ static ssize_t adis16220_capture_buffer_read(struct iio_dev *indio_dev, } xfers[1].len = count; - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - ret = spi_sync(st->adis.spi, &msg); + ret = spi_sync_transfer(st->adis.spi, xfers, ARRAY_SIZE(xfers)); if (ret) { mutex_unlock(&st->buf_lock); diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index bb852dc..735c0a3 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -190,15 +190,26 @@ static u8 lis3l02dq_axis_map[3][3] = { }; static int lis3l02dq_read_thresh(struct iio_dev *indio_dev, - u64 e, - int *val) + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir, + enum iio_event_info info, + int *val, int *val2) { - return lis3l02dq_read_reg_s16(indio_dev, LIS3L02DQ_REG_THS_L_ADDR, val); + int ret; + + ret = lis3l02dq_read_reg_s16(indio_dev, LIS3L02DQ_REG_THS_L_ADDR, val); + if (ret) + return ret; + return IIO_VAL_INT; } static int lis3l02dq_write_thresh(struct iio_dev *indio_dev, - u64 event_code, - int val) + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir, + enum iio_event_info info, + int val, int val2) { u16 value = val; return lis3l02dq_spi_write_reg_s16(indio_dev, @@ -503,9 +514,19 @@ static irqreturn_t lis3l02dq_event_handler(int irq, void *private) return IRQ_HANDLED; } -#define LIS3L02DQ_EVENT_MASK \ - (IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) | \ - IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING)) +static const struct iio_event_spec lis3l02dq_event[] = { + { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_RISING, + .mask_separate = BIT(IIO_EV_INFO_ENABLE), + .mask_shared_by_type = BIT(IIO_EV_INFO_VALUE), + }, { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_FALLING, + .mask_separate = BIT(IIO_EV_INFO_ENABLE), + .mask_shared_by_type = BIT(IIO_EV_INFO_VALUE), + } +}; #define LIS3L02DQ_CHAN(index, mod) \ { \ @@ -523,7 +544,8 @@ static irqreturn_t lis3l02dq_event_handler(int irq, void *private) .realbits = 12, \ .storagebits = 16, \ }, \ - .event_mask = LIS3L02DQ_EVENT_MASK, \ + .event_spec = lis3l02dq_event, \ + .num_event_specs = ARRAY_SIZE(lis3l02dq_event), \ } static const struct iio_chan_spec lis3l02dq_channels[] = { @@ -535,14 +557,14 @@ static const struct iio_chan_spec lis3l02dq_channels[] = { static int lis3l02dq_read_event_config(struct iio_dev *indio_dev, - u64 event_code) + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir) { u8 val; int ret; - u8 mask = (1 << (IIO_EVENT_CODE_EXTRACT_MODIFIER(event_code)*2 + - (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == - IIO_EV_DIR_RISING))); + u8 mask = (1 << (chan->channel2*2 + (dir == IIO_EV_DIR_RISING))); ret = lis3l02dq_spi_read_reg_8(indio_dev, LIS3L02DQ_REG_WAKE_UP_CFG_ADDR, &val); @@ -587,16 +609,16 @@ error_ret: } static int lis3l02dq_write_event_config(struct iio_dev *indio_dev, - u64 event_code, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir, int state) { int ret = 0; u8 val, control; u8 currentlyset; bool changed = false; - u8 mask = (1 << (IIO_EVENT_CODE_EXTRACT_MODIFIER(event_code)*2 + - (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == - IIO_EV_DIR_RISING))); + u8 mask = (1 << (chan->channel2*2 + (dir == IIO_EV_DIR_RISING))); mutex_lock(&indio_dev->mlock); /* read current control */ @@ -654,10 +676,10 @@ static const struct attribute_group lis3l02dq_attribute_group = { static const struct iio_info lis3l02dq_info = { .read_raw = &lis3l02dq_read_raw, .write_raw = &lis3l02dq_write_raw, - .read_event_value = &lis3l02dq_read_thresh, - .write_event_value = &lis3l02dq_write_thresh, - .write_event_config = &lis3l02dq_write_event_config, - .read_event_config = &lis3l02dq_read_event_config, + .read_event_value_new = &lis3l02dq_read_thresh, + .write_event_value_new = &lis3l02dq_write_thresh, + .write_event_config_new = &lis3l02dq_write_event_config, + .read_event_config_new = &lis3l02dq_read_event_config, .driver_module = THIS_MODULE, .attrs = &lis3l02dq_attribute_group, }; @@ -694,7 +716,7 @@ static int lis3l02dq_probe(struct spi_device *spi) lis3l02dq_channels, ARRAY_SIZE(lis3l02dq_channels)); if (ret) { - printk(KERN_ERR "failed to initialize the buffer\n"); + dev_err(&spi->dev, "failed to initialize the buffer\n"); goto error_unreg_buffer_funcs; } diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c index 5b8f0f6..79cefe0 100644 --- a/drivers/staging/iio/accel/lis3l02dq_ring.c +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c @@ -111,7 +111,7 @@ static int lis3l02dq_get_buffer_element(struct iio_dev *indio_dev, u8 *buf) { int ret, i; - u8 *rx_array ; + u8 *rx_array; s16 *data = (s16 *)buf; int scan_count = bitmap_weight(indio_dev->active_scan_mask, indio_dev->masklength); @@ -146,11 +146,7 @@ static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p) if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength)) len = lis3l02dq_get_buffer_element(indio_dev, data); - /* Guaranteed to be aligned with 8 byte boundary */ - if (indio_dev->scan_timestamp) - *(s64 *)((u8 *)data + ALIGN(len, sizeof(s64))) - = pf->timestamp; - iio_push_to_buffers(indio_dev, (u8 *)data); + iio_push_to_buffers_with_timestamp(indio_dev, data, pf->timestamp); kfree(data); done: @@ -264,8 +260,7 @@ static int lis3l02dq_trig_try_reen(struct iio_trigger *trig) else break; if (i == 5) - printk(KERN_INFO - "Failed to clear the interrupt for lis3l02dq\n"); + pr_info("Failed to clear the interrupt for lis3l02dq\n"); /* irq reenabled so success! */ return 0; @@ -387,7 +382,6 @@ error_ret: } static const struct iio_buffer_setup_ops lis3l02dq_buffer_setup_ops = { - .preenable = &iio_sw_buffer_preenable, .postenable = &lis3l02dq_buffer_postenable, .predisable = &lis3l02dq_buffer_predisable, }; @@ -401,7 +395,7 @@ int lis3l02dq_configure_buffer(struct iio_dev *indio_dev) if (!buffer) return -ENOMEM; - indio_dev->buffer = buffer; + iio_device_attach_buffer(indio_dev, buffer); buffer->scan_timestamp = true; indio_dev->setup_ops = &lis3l02dq_buffer_setup_ops; diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index 48a25ba..c49e6ef 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -419,8 +419,11 @@ static IIO_DEVICE_ATTR(measurement_mode, S_IRUGO | S_IWUSR, static IIO_DEVICE_ATTR(revision, S_IRUGO, sca3000_show_rev, NULL, 0); -#define SCA3000_EVENT_MASK \ - (IIO_EV_BIT(IIO_EV_TYPE_MAG, IIO_EV_DIR_RISING)) +static const struct iio_event_spec sca3000_event = { + .type = IIO_EV_TYPE_MAG, + .dir = IIO_EV_DIR_RISING, + .mask_separate = BIT(IIO_EV_INFO_VALUE) | BIT(IIO_EV_INFO_ENABLE), +}; #define SCA3000_CHAN(index, mod) \ { \ @@ -437,7 +440,8 @@ static IIO_DEVICE_ATTR(revision, S_IRUGO, sca3000_show_rev, NULL, 0); .storagebits = 16, \ .shift = 5, \ }, \ - .event_mask = SCA3000_EVENT_MASK, \ + .event_spec = &sca3000_event, \ + .num_event_specs = 1, \ } static const struct iio_chan_spec sca3000_channels[] = { @@ -624,9 +628,9 @@ static ssize_t sca3000_set_frequency(struct device *dev, struct sca3000_state *st = iio_priv(indio_dev); int ret, base_freq = 0; int ctrlval; - long val; + int val; - ret = strict_strtol(buf, 10, &val); + ret = kstrtoint(buf, 10, &val); if (ret) return ret; @@ -703,12 +707,15 @@ static IIO_CONST_ATTR_TEMP_OFFSET("-214.6"); * sca3000_read_thresh() - query of a threshold **/ static int sca3000_read_thresh(struct iio_dev *indio_dev, - u64 e, - int *val) + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir, + enum iio_event_info info, + int *val, int *val2) { int ret, i; struct sca3000_state *st = iio_priv(indio_dev); - int num = IIO_EVENT_CODE_EXTRACT_MODIFIER(e); + int num = chan->channel2; mutex_lock(&st->lock); ret = sca3000_read_ctrl_reg(st, sca3000_addresses[num][1]); mutex_unlock(&st->lock); @@ -724,18 +731,21 @@ static int sca3000_read_thresh(struct iio_dev *indio_dev, ARRAY_SIZE(st->info->mot_det_mult_xz)) *val += st->info->mot_det_mult_xz[i]; - return 0; + return IIO_VAL_INT; } /** * sca3000_write_thresh() control of threshold **/ static int sca3000_write_thresh(struct iio_dev *indio_dev, - u64 e, - int val) + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir, + enum iio_event_info info, + int val, int val2) { struct sca3000_state *st = iio_priv(indio_dev); - int num = IIO_EVENT_CODE_EXTRACT_MODIFIER(e); + int num = chan->channel2; int ret; int i; u8 nonlinear = 0; @@ -866,12 +876,14 @@ done: * sca3000_read_event_config() what events are enabled **/ static int sca3000_read_event_config(struct iio_dev *indio_dev, - u64 e) + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir) { struct sca3000_state *st = iio_priv(indio_dev); int ret; u8 protect_mask = 0x03; - int num = IIO_EVENT_CODE_EXTRACT_MODIFIER(e); + int num = chan->channel2; /* read current value of mode register */ mutex_lock(&st->lock); @@ -931,12 +943,12 @@ static ssize_t sca3000_set_free_fall_mode(struct device *dev, { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct sca3000_state *st = iio_priv(indio_dev); - long val; + u8 val; int ret; u8 protect_mask = SCA3000_FREE_FALL_DETECT; mutex_lock(&st->lock); - ret = strict_strtol(buf, 10, &val); + ret = kstrtou8(buf, 10, &val); if (ret) goto error_ret; @@ -969,13 +981,15 @@ error_ret: * this mode is disabled. Currently normal mode is assumed. **/ static int sca3000_write_event_config(struct iio_dev *indio_dev, - u64 e, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir, int state) { struct sca3000_state *st = iio_priv(indio_dev); int ret, ctrlval; u8 protect_mask = 0x03; - int num = IIO_EVENT_CODE_EXTRACT_MODIFIER(e); + int num = chan->channel2; mutex_lock(&st->lock); /* First read the motion detector config to find out if @@ -1112,20 +1126,20 @@ static const struct iio_info sca3000_info = { .attrs = &sca3000_attribute_group, .read_raw = &sca3000_read_raw, .event_attrs = &sca3000_event_attribute_group, - .read_event_value = &sca3000_read_thresh, - .write_event_value = &sca3000_write_thresh, - .read_event_config = &sca3000_read_event_config, - .write_event_config = &sca3000_write_event_config, + .read_event_value_new = &sca3000_read_thresh, + .write_event_value_new = &sca3000_write_thresh, + .read_event_config_new = &sca3000_read_event_config, + .write_event_config_new = &sca3000_write_event_config, .driver_module = THIS_MODULE, }; static const struct iio_info sca3000_info_with_temp = { .attrs = &sca3000_attribute_group_with_temp, .read_raw = &sca3000_read_raw, - .read_event_value = &sca3000_read_thresh, - .write_event_value = &sca3000_write_thresh, - .read_event_config = &sca3000_read_event_config, - .write_event_config = &sca3000_write_event_config, + .read_event_value_new = &sca3000_read_thresh, + .write_event_value_new = &sca3000_write_thresh, + .read_event_config_new = &sca3000_read_event_config, + .write_event_config_new = &sca3000_write_event_config, .driver_module = THIS_MODULE, }; diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c index 3e5e860..ea0af6d 100644 --- a/drivers/staging/iio/accel/sca3000_ring.c +++ b/drivers/staging/iio/accel/sca3000_ring.c @@ -177,11 +177,11 @@ static ssize_t sca3000_set_ring_int(struct device *dev, struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct sca3000_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - long val; + u8 val; int ret; mutex_lock(&st->lock); - ret = strict_strtol(buf, 10, &val); + ret = kstrtou8(buf, 10, &val); if (ret) goto error_ret; ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_INT_MASK, 1); @@ -252,7 +252,7 @@ static struct iio_buffer *sca3000_rb_allocate(struct iio_dev *indio_dev) struct iio_buffer *buf; struct iio_hw_buffer *ring; - ring = kzalloc(sizeof *ring, GFP_KERNEL); + ring = kzalloc(sizeof(*ring), GFP_KERNEL); if (!ring) return NULL; @@ -265,7 +265,7 @@ static struct iio_buffer *sca3000_rb_allocate(struct iio_dev *indio_dev) return buf; } -static inline void sca3000_rb_free(struct iio_buffer *r) +static void sca3000_ring_release(struct iio_buffer *r) { kfree(iio_to_hw_buf(r)); } @@ -274,23 +274,28 @@ static const struct iio_buffer_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, + .release = sca3000_ring_release, }; int sca3000_configure_ring(struct iio_dev *indio_dev) { - indio_dev->buffer = sca3000_rb_allocate(indio_dev); - if (indio_dev->buffer == NULL) + struct iio_buffer *buffer; + + buffer = sca3000_rb_allocate(indio_dev); + if (buffer == NULL) return -ENOMEM; indio_dev->modes |= INDIO_BUFFER_HARDWARE; indio_dev->buffer->access = &sca3000_ring_access_funcs; + iio_device_attach_buffer(indio_dev, buffer); + return 0; } void sca3000_unconfigure_ring(struct iio_dev *indio_dev) { - sca3000_rb_free(indio_dev->buffer); + iio_buffer_put(indio_dev->buffer); } static inline |