static int yas_probe_buffer(struct iio_dev *indio_dev) { int ret; struct iio_buffer *buffer; buffer = iio_sw_rb_allocate(indio_dev); if (!buffer) { ret = -ENOMEM; goto error_ret; } buffer->scan_timestamp = true; indio_dev->buffer = buffer; indio_dev->setup_ops = &yas_buffer_setup_ops; indio_dev->modes |= INDIO_BUFFER_TRIGGERED; ret = iio_buffer_register(indio_dev, indio_dev->channels, indio_dev->num_channels); if (ret) goto error_free_buf; iio_scan_mask_set(indio_dev, indio_dev->buffer, YAS_SCAN_ACCEL_X); iio_scan_mask_set(indio_dev, indio_dev->buffer, YAS_SCAN_ACCEL_Y); iio_scan_mask_set(indio_dev, indio_dev->buffer, YAS_SCAN_ACCEL_Z); return 0; error_free_buf: iio_sw_rb_free(indio_dev->buffer); error_ret: return ret; }
static int optical_allocate_ring(struct iio_dev *indio_dev) //VungGV? { /*int ret; printk (KERN_ALERT "[%s]\n", __FUNCTION__); ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time, &optical_trigger_handler, &optical_buffer_setup_ops); return ret;*/ int ret = 0; struct iio_ring_buffer *ring; ring = iio_sw_rb_allocate(indio_dev); if (!ring) { ret = -ENOMEM; return ret; } indio_dev->ring = ring; /* Effectively select the ring buffer implementation */ ring->access = &ring_sw_access_funcs; ring->bpe = 2; ring->scan_timestamp = true; ring->setup_ops = &optical_buffer_setup_ops; ring->owner = THIS_MODULE; /* Set default scan mode */ iio_scan_mask_set(ring, L1PH03_SCAN_PROX_X); iio_scan_mask_set(ring, L1PH03_SCAN_LIGHT_X); //iio_scan_mask_set(ring, ADIS16260_SCAN_AUX_ADC); //iio_scan_mask_set(ring, ADIS16260_SCAN_TEMP); //iio_scan_mask_set(ring, ADIS16260_SCAN_ANGL); indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time, &optical_trigger_handler, IRQF_ONESHOT, indio_dev, "lt1ph03_consumer%d", indio_dev->id); if (indio_dev->pollfunc == NULL) { ret = -ENOMEM; goto error_iio_sw_rb_free; } indio_dev->modes |= INDIO_RING_TRIGGERED; return 0; error_iio_sw_rb_free: iio_sw_rb_free(indio_dev->ring); return ret; }
int adis16204_configure_ring(struct iio_dev *indio_dev) { int ret = 0; struct iio_ring_buffer *ring; ring = iio_sw_rb_allocate(indio_dev); if (!ring) { ret = -ENOMEM; return ret; } indio_dev->ring = ring; /* Effectively select the ring buffer implementation */ ring->access = &ring_sw_access_funcs; ring->bpe = 2; ring->scan_timestamp = true; ring->setup_ops = &adis16204_ring_setup_ops; ring->owner = THIS_MODULE; /* Set default scan mode */ iio_scan_mask_set(ring, ADIS16204_SCAN_SUPPLY); iio_scan_mask_set(ring, ADIS16204_SCAN_ACC_X); iio_scan_mask_set(ring, ADIS16204_SCAN_ACC_Y); iio_scan_mask_set(ring, ADIS16204_SCAN_AUX_ADC); iio_scan_mask_set(ring, ADIS16204_SCAN_TEMP); indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time, &adis16204_trigger_handler, IRQF_ONESHOT, indio_dev, "%s_consumer%d", indio_dev->name, indio_dev->id); if (indio_dev->pollfunc == NULL) { ret = -ENOMEM; goto error_iio_sw_rb_free; } indio_dev->modes |= INDIO_RING_TRIGGERED; return 0; error_iio_sw_rb_free: iio_sw_rb_free(indio_dev->ring); return ret; }
int lis3l02dq_configure_ring(struct iio_dev *indio_dev) { int ret = 0; struct lis3l02dq_state *st = indio_dev->dev_data; struct iio_ring_buffer *ring; INIT_WORK(&st->work_trigger_to_ring, lis3l02dq_trigger_bh_to_ring); /* Set default scan mode */ 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) { ret = -ENOMEM; return ret; } indio_dev->ring = ring; /* Effectively select the ring buffer implementation */ iio_ring_sw_register_funcs(&ring->access); ring->preenable = &lis3l02dq_data_rdy_ring_preenable; ring->postenable = &lis3l02dq_data_rdy_ring_postenable; ring->predisable = &lis3l02dq_data_rdy_ring_predisable; ring->owner = THIS_MODULE; indio_dev->pollfunc = kzalloc(sizeof(*indio_dev->pollfunc), GFP_KERNEL); if (indio_dev->pollfunc == NULL) { ret = -ENOMEM; goto error_iio_sw_rb_free;; } indio_dev->pollfunc->poll_func_main = &lis3l02dq_poll_func_th; indio_dev->pollfunc->private_data = indio_dev; indio_dev->modes |= INDIO_RING_TRIGGERED; return 0; error_iio_sw_rb_free: iio_sw_rb_free(indio_dev->ring); return ret; }
int lis3l02dq_configure_ring(struct iio_dev *indio_dev) { int ret; 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); h->get_ring_element = &lis3l02dq_get_ring_element; ring = lis3l02dq_alloc_buf(indio_dev); if (!ring) return -ENOMEM; indio_dev->ring = ring; /* Effectively select the ring buffer implementation */ lis3l02dq_register_buf_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; indio_dev->modes |= INDIO_RING_TRIGGERED; return 0; error_iio_sw_rb_free: lis3l02dq_free_buf(indio_dev->ring); return ret; }
int adis16209_configure_ring(struct iio_dev *indio_dev) { int ret = 0; 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) { ret = -ENOMEM; return ret; } indio_dev->ring = ring; /* Effectively select the ring buffer implementation */ iio_ring_sw_register_funcs(&ring->access); ring->bpe = 2; ring->preenable = &iio_sw_ring_preenable; ring->postenable = &iio_triggered_ring_postenable; ring->predisable = &iio_triggered_ring_predisable; ring->owner = THIS_MODULE; ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16209_poll_func_th); if (ret) goto error_iio_sw_rb_free; indio_dev->modes |= INDIO_RING_TRIGGERED; return 0; error_iio_sw_rb_free: iio_sw_rb_free(indio_dev->ring); return ret; }
static ssize_t iio_scan_el_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { int ret = 0; bool state; struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_buffer *buffer = indio_dev->buffer; struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); state = !(buf[0] == '0'); mutex_lock(&indio_dev->mlock); if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) { ret = -EBUSY; goto error_ret; } ret = iio_scan_mask_query(buffer, this_attr->address); if (ret < 0) goto error_ret; if (!state && ret) { ret = iio_scan_mask_clear(buffer, this_attr->address); if (ret) goto error_ret; } else if (state && !ret) { ret = iio_scan_mask_set(buffer, this_attr->address); if (ret) goto error_ret; } error_ret: mutex_unlock(&indio_dev->mlock); return ret ? ret : len; }