diff options
Diffstat (limited to 'drivers/staging/iio/accel')
-rw-r--r-- | drivers/staging/iio/accel/adis16209_ring.c | 41 | ||||
-rw-r--r-- | drivers/staging/iio/accel/adis16240_ring.c | 33 | ||||
-rw-r--r-- | drivers/staging/iio/accel/lis3l02dq_ring.c | 43 | ||||
-rw-r--r-- | drivers/staging/iio/accel/sca3000_ring.c | 2 |
4 files changed, 60 insertions, 59 deletions
diff --git a/drivers/staging/iio/accel/adis16209_ring.c b/drivers/staging/iio/accel/adis16209_ring.c index d40b95f..120bf91 100644 --- a/drivers/staging/iio/accel/adis16209_ring.c +++ b/drivers/staging/iio/accel/adis16209_ring.c @@ -115,11 +115,11 @@ static void adis16209_trigger_bh_to_ring(struct work_struct *work_s) struct adis16209_state *st = container_of(work_s, struct adis16209_state, work_trigger_to_ring); + struct iio_ring_buffer *ring = st->indio_dev->ring; int i = 0; s16 *data; - size_t datasize = st->indio_dev - ->ring->access.get_bytes_per_datum(st->indio_dev->ring); + size_t datasize = ring->access.get_bytes_per_datum(ring); data = kmalloc(datasize , GFP_KERNEL); if (data == NULL) { @@ -127,19 +127,19 @@ static void adis16209_trigger_bh_to_ring(struct work_struct *work_s) return; } - if (st->indio_dev->scan_count) + if (ring->scan_count) if (adis16209_read_ring_data(&st->indio_dev->dev, st->rx) >= 0) - for (; i < st->indio_dev->scan_count; i++) + for (; i < ring->scan_count; i++) data[i] = be16_to_cpup( (__be16 *)&(st->rx[i*2])); /* Guaranteed to be aligned with 8 byte boundary */ - if (st->indio_dev->scan_timestamp) + if (ring->scan_timestamp) *((s64 *)(data + ((i + 3)/4)*4)) = st->last_timestamp; - st->indio_dev->ring->access.store_to(st->indio_dev->ring, - (u8 *)data, - st->last_timestamp); + ring->access.store_to(ring, + (u8 *)data, + st->last_timestamp); iio_trigger_notify_done(st->indio_dev->trig); kfree(data); @@ -159,19 +159,6 @@ int adis16209_configure_ring(struct iio_dev *indio_dev) struct adis16209_state *st = indio_dev->dev_data; struct iio_ring_buffer *ring; INIT_WORK(&st->work_trigger_to_ring, adis16209_trigger_bh_to_ring); - /* Set default scan mode */ - - iio_scan_mask_set(indio_dev, iio_scan_el_supply.number); - iio_scan_mask_set(indio_dev, iio_scan_el_rot.number); - iio_scan_mask_set(indio_dev, iio_scan_el_accel_x.number); - iio_scan_mask_set(indio_dev, iio_scan_el_accel_y.number); - iio_scan_mask_set(indio_dev, iio_scan_el_temp.number); - iio_scan_mask_set(indio_dev, iio_scan_el_aux_adc.number); - iio_scan_mask_set(indio_dev, iio_scan_el_incli_x.number); - iio_scan_mask_set(indio_dev, iio_scan_el_incli_y.number); - indio_dev->scan_timestamp = true; - - indio_dev->scan_el_attrs = &adis16209_scan_el_group; ring = iio_sw_rb_allocate(indio_dev); if (!ring) { @@ -182,11 +169,23 @@ int adis16209_configure_ring(struct iio_dev *indio_dev) /* Effectively select the ring buffer implementation */ iio_ring_sw_register_funcs(&ring->access); ring->bpe = 2; + ring->scan_el_attrs = &adis16209_scan_el_group; + ring->scan_timestamp = true; ring->preenable = &iio_sw_ring_preenable; ring->postenable = &iio_triggered_ring_postenable; ring->predisable = &iio_triggered_ring_predisable; ring->owner = THIS_MODULE; + /* Set default scan mode */ + iio_scan_mask_set(ring, iio_scan_el_supply.number); + iio_scan_mask_set(ring, iio_scan_el_rot.number); + iio_scan_mask_set(ring, iio_scan_el_accel_x.number); + iio_scan_mask_set(ring, iio_scan_el_accel_y.number); + iio_scan_mask_set(ring, iio_scan_el_temp.number); + iio_scan_mask_set(ring, iio_scan_el_aux_adc.number); + iio_scan_mask_set(ring, iio_scan_el_incli_x.number); + iio_scan_mask_set(ring, iio_scan_el_incli_y.number); + ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16209_poll_func_th); if (ret) goto error_iio_sw_rb_free; diff --git a/drivers/staging/iio/accel/adis16240_ring.c b/drivers/staging/iio/accel/adis16240_ring.c index 462d452..581d0e5 100644 --- a/drivers/staging/iio/accel/adis16240_ring.c +++ b/drivers/staging/iio/accel/adis16240_ring.c @@ -107,11 +107,11 @@ static void adis16240_trigger_bh_to_ring(struct work_struct *work_s) struct adis16240_state *st = container_of(work_s, struct adis16240_state, work_trigger_to_ring); + struct iio_ring_buffer *ring = st->indio_dev->ring; int i = 0; s16 *data; - size_t datasize = st->indio_dev - ->ring->access.get_bytes_per_datum(st->indio_dev->ring); + size_t datasize = ring->access.get_bytes_per_datum(ring); data = kmalloc(datasize , GFP_KERNEL); if (data == NULL) { @@ -119,17 +119,17 @@ static void adis16240_trigger_bh_to_ring(struct work_struct *work_s) return; } - if (st->indio_dev->scan_count) + if (ring->scan_count) if (adis16240_read_ring_data(&st->indio_dev->dev, st->rx) >= 0) - for (; i < st->indio_dev->scan_count; i++) + for (; i < ring->scan_count; i++) data[i] = be16_to_cpup( (__be16 *)&(st->rx[i*2])); /* Guaranteed to be aligned with 8 byte boundary */ - if (st->indio_dev->scan_timestamp) + if (ring->scan_timestamp) *((s64 *)(data + ((i + 3)/4)*4)) = st->last_timestamp; - st->indio_dev->ring->access.store_to(st->indio_dev->ring, + ring->access.store_to(ring, (u8 *)data, st->last_timestamp); @@ -151,17 +151,6 @@ int adis16240_configure_ring(struct iio_dev *indio_dev) struct adis16240_state *st = indio_dev->dev_data; struct iio_ring_buffer *ring; INIT_WORK(&st->work_trigger_to_ring, adis16240_trigger_bh_to_ring); - /* Set default scan mode */ - - iio_scan_mask_set(indio_dev, iio_scan_el_supply.number); - iio_scan_mask_set(indio_dev, iio_scan_el_accel_x.number); - iio_scan_mask_set(indio_dev, iio_scan_el_accel_y.number); - iio_scan_mask_set(indio_dev, iio_scan_el_accel_z.number); - iio_scan_mask_set(indio_dev, iio_scan_el_temp.number); - iio_scan_mask_set(indio_dev, iio_scan_el_aux_adc.number); - indio_dev->scan_timestamp = true; - - indio_dev->scan_el_attrs = &adis16240_scan_el_group; ring = iio_sw_rb_allocate(indio_dev); if (!ring) { @@ -172,11 +161,21 @@ int adis16240_configure_ring(struct iio_dev *indio_dev) /* Effectively select the ring buffer implementation */ iio_ring_sw_register_funcs(&ring->access); ring->bpe = 2; + ring->scan_el_attrs = &adis16240_scan_el_group; + ring->scan_timestamp = true; ring->preenable = &iio_sw_ring_preenable; ring->postenable = &iio_triggered_ring_postenable; ring->predisable = &iio_triggered_ring_predisable; ring->owner = THIS_MODULE; + /* Set default scan mode */ + iio_scan_mask_set(ring, iio_scan_el_supply.number); + iio_scan_mask_set(ring, iio_scan_el_accel_x.number); + iio_scan_mask_set(ring, iio_scan_el_accel_y.number); + iio_scan_mask_set(ring, iio_scan_el_accel_z.number); + iio_scan_mask_set(ring, iio_scan_el_temp.number); + iio_scan_mask_set(ring, iio_scan_el_aux_adc.number); + ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16240_poll_func_th); if (ret) goto error_iio_sw_rb_free; diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c index 9ad04f0..a68a381 100644 --- a/drivers/staging/iio/accel/lis3l02dq_ring.c +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c @@ -150,38 +150,40 @@ ssize_t lis3l02dq_read_accel_from_ring(struct device *dev, int ret, len = 0, i = 0; struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); struct iio_dev *dev_info = dev_get_drvdata(dev); + struct iio_ring_buffer *ring = dev_info->ring; + struct attribute_group *scan_el_attrs = ring->scan_el_attrs; s16 *data; - while (dev_info->scan_el_attrs->attrs[i]) { + while (scan_el_attrs->attrs[i]) { el = to_iio_scan_el((struct device_attribute *) - (dev_info->scan_el_attrs->attrs[i])); + (scan_el_attrs->attrs[i])); /* label is in fact the address */ if (el->label == this_attr->address) break; i++; } - if (!dev_info->scan_el_attrs->attrs[i]) { + if (!scan_el_attrs->attrs[i]) { ret = -EINVAL; goto error_ret; } /* If this element is in the scan mask */ - ret = iio_scan_mask_query(dev_info, el->number); + ret = iio_scan_mask_query(ring, el->number); if (ret < 0) goto error_ret; if (ret) { - data = kmalloc(dev_info->ring->access.get_bytes_per_datum(dev_info->ring), + data = kmalloc(ring->access.get_bytes_per_datum(ring), GFP_KERNEL); if (data == NULL) return -ENOMEM; - ret = dev_info->ring->access.read_last(dev_info->ring, - (u8 *)data); + ret = ring->access.read_last(ring, + (u8 *)data); if (ret) goto error_free_data; } else { ret = -EINVAL; goto error_ret; } - len = iio_scan_mask_count_to_right(dev_info, el->number); + len = iio_scan_mask_count_to_right(ring, el->number); if (len < 0) { ret = len; goto error_free_data; @@ -211,11 +213,12 @@ static const u8 read_all_tx_array[] = { **/ static int lis3l02dq_read_all(struct lis3l02dq_state *st, u8 *rx_array) { + struct iio_ring_buffer *ring = st->help.indio_dev->ring; struct spi_transfer *xfers; struct spi_message msg; int ret, i, j = 0; - xfers = kzalloc((st->help.indio_dev->scan_count) * 2 + xfers = kzalloc((ring->scan_count) * 2 * sizeof(*xfers), GFP_KERNEL); if (!xfers) return -ENOMEM; @@ -223,7 +226,7 @@ static int lis3l02dq_read_all(struct lis3l02dq_state *st, u8 *rx_array) mutex_lock(&st->buf_lock); for (i = 0; i < ARRAY_SIZE(read_all_tx_array)/4; i++) { - if (st->help.indio_dev->scan_mask & (1 << i)) { + if (ring->scan_mask & (1 << i)) { /* lower byte */ xfers[j].tx_buf = st->tx + 2*j; st->tx[2*j] = read_all_tx_array[i*4]; @@ -251,7 +254,7 @@ static int lis3l02dq_read_all(struct lis3l02dq_state *st, u8 *rx_array) * values in alternate bytes */ spi_message_init(&msg); - for (j = 0; j < st->help.indio_dev->scan_count * 2; j++) + for (j = 0; j < ring->scan_count * 2; j++) spi_message_add_tail(&xfers[j], &msg); ret = spi_sync(st->us, &msg); @@ -279,13 +282,13 @@ static int lis3l02dq_get_ring_element(struct iio_sw_ring_helper_state *h, u8 *rx_array ; s16 *data = (s16 *)buf; - rx_array = kzalloc(4 * (h->indio_dev->scan_count), GFP_KERNEL); + rx_array = kzalloc(4 * (h->indio_dev->ring->scan_count), GFP_KERNEL); if (rx_array == NULL) return -ENOMEM; ret = lis3l02dq_read_all(lis3l02dq_h_to_s(h), rx_array); if (ret < 0) return ret; - for (i = 0; i < h->indio_dev->scan_count; i++) + for (i = 0; i < h->indio_dev->ring->scan_count; i++) data[i] = combine_8_to_16(rx_array[i*4+1], rx_array[i*4+3]); kfree(rx_array); @@ -481,14 +484,7 @@ int lis3l02dq_configure_ring(struct iio_dev *indio_dev) struct iio_sw_ring_helper_state *h = iio_dev_get_devdata(indio_dev); struct iio_ring_buffer *ring; INIT_WORK(&h->work_trigger_to_ring, lis3l02dq_trigger_bh_to_ring); - /* Set default scan mode */ h->get_ring_element = &lis3l02dq_get_ring_element; - iio_scan_mask_set(indio_dev, iio_scan_el_accel_x.number); - iio_scan_mask_set(indio_dev, iio_scan_el_accel_y.number); - iio_scan_mask_set(indio_dev, iio_scan_el_accel_z.number); - indio_dev->scan_timestamp = true; - - indio_dev->scan_el_attrs = &lis3l02dq_scan_el_group; ring = iio_sw_rb_allocate(indio_dev); if (!ring) @@ -498,11 +494,18 @@ int lis3l02dq_configure_ring(struct iio_dev *indio_dev) /* Effectively select the ring buffer implementation */ iio_ring_sw_register_funcs(&ring->access); ring->bpe = 2; + ring->scan_el_attrs = &lis3l02dq_scan_el_group; + ring->scan_timestamp = true; ring->preenable = &iio_sw_ring_preenable; ring->postenable = &iio_triggered_ring_postenable; ring->predisable = &iio_triggered_ring_predisable; ring->owner = THIS_MODULE; + /* Set default scan mode */ + iio_scan_mask_set(ring, iio_scan_el_accel_x.number); + iio_scan_mask_set(ring, iio_scan_el_accel_y.number); + iio_scan_mask_set(ring, iio_scan_el_accel_z.number); + ret = iio_alloc_pollfunc(indio_dev, NULL, &lis3l02dq_poll_func_th); if (ret) goto error_iio_sw_rb_free;; diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c index eff5b9a..6d19d15 100644 --- a/drivers/staging/iio/accel/sca3000_ring.c +++ b/drivers/staging/iio/accel/sca3000_ring.c @@ -264,12 +264,12 @@ static inline void sca3000_rb_free(struct iio_ring_buffer *r) int sca3000_configure_ring(struct iio_dev *indio_dev) { - indio_dev->scan_el_attrs = &sca3000_scan_el_group; indio_dev->ring = sca3000_rb_allocate(indio_dev); if (indio_dev->ring == NULL) return -ENOMEM; indio_dev->modes |= INDIO_RING_HARDWARE_BUFFER; + indio_dev->ring->scan_el_attrs = &sca3000_scan_el_group; indio_dev->ring->access.rip_lots = &sca3000_rip_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; |