/* Whilst this makes a lot of calls to iio_sw_ring functions - it is to device * specific to be rolled into the core. */ static irqreturn_t adis16209_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct adis16209_state *st = iio_priv(indio_dev); struct iio_buffer *ring = indio_dev->buffer; int i = 0; s16 *data; size_t datasize = ring->access->get_bytes_per_datum(ring); data = kmalloc(datasize , GFP_KERNEL); if (data == NULL) { dev_err(&st->us->dev, "memory alloc failed in ring bh"); return -ENOMEM; } if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength) && adis16209_read_ring_data(&indio_dev->dev, st->rx) >= 0) for (; i < bitmap_weight(indio_dev->active_scan_mask, indio_dev->masklength); i++) data[i] = be16_to_cpup((__be16 *)&(st->rx[i*2])); /* Guaranteed to be aligned with 8 byte boundary */ if (ring->scan_timestamp) *((s64 *)(data + ((i + 3)/4)*4)) = pf->timestamp; ring->access->store_to(ring, (u8 *)data, pf->timestamp); iio_trigger_notify_done(indio_dev->trig); kfree(data); return IRQ_HANDLED; }
/* Whilst this makes a lot of calls to iio_sw_ring functions - it is to device * specific to be rolled into the core. */ 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); int i = 0; s16 *data; size_t datasize = st->indio_dev ->ring->access.get_bpd(st->indio_dev->ring); data = kmalloc(datasize , GFP_KERNEL); if (data == NULL) { dev_err(&st->us->dev, "memory alloc failed in ring bh"); return; } if (st->indio_dev->scan_count) if (adis16209_read_ring_data(&st->indio_dev->dev, st->rx) >= 0) for (; i < st->indio_dev->scan_count; i++) { data[i] = combine_8_to_16(st->rx[i*2+1], st->rx[i*2]); } /* Guaranteed to be aligned with 8 byte boundary */ if (st->indio_dev->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); iio_trigger_notify_done(st->indio_dev->trig); kfree(data); return; }