summaryrefslogtreecommitdiffstats
path: root/drivers/staging/iio/adc/ad7887_ring.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/iio/adc/ad7887_ring.c')
-rw-r--r--drivers/staging/iio/adc/ad7887_ring.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/drivers/staging/iio/adc/ad7887_ring.c b/drivers/staging/iio/adc/ad7887_ring.c
index 113e97e..f3485b3 100644
--- a/drivers/staging/iio/adc/ad7887_ring.c
+++ b/drivers/staging/iio/adc/ad7887_ring.c
@@ -33,12 +33,13 @@ int ad7887_scan_from_ring(struct ad7887_state *st, long mask)
goto error_ret;
}
- ring_data = kmalloc(ring->access.get_bytes_per_datum(ring), GFP_KERNEL);
+ ring_data = kmalloc(ring->access->get_bytes_per_datum(ring),
+ GFP_KERNEL);
if (ring_data == NULL) {
ret = -ENOMEM;
goto error_ret;
}
- ret = ring->access.read_last(ring, (u8 *) ring_data);
+ ret = ring->access->read_last(ring, (u8 *) ring_data);
if (ret)
goto error_free_ring_data;
@@ -76,8 +77,8 @@ static int ad7887_ring_preenable(struct iio_dev *indio_dev)
st->d_size += sizeof(s64) - (st->d_size % sizeof(s64));
}
- if (indio_dev->ring->access.set_bytes_per_datum)
- indio_dev->ring->access.set_bytes_per_datum(indio_dev->ring,
+ if (indio_dev->ring->access->set_bytes_per_datum)
+ indio_dev->ring->access->set_bytes_per_datum(indio_dev->ring,
st->d_size);
switch (ring->scan_mask) {
@@ -117,7 +118,6 @@ static irqreturn_t ad7887_trigger_handler(int irq, void *p)
struct iio_dev *indio_dev = pf->private_data;
struct ad7887_state *st = iio_dev_get_devdata(indio_dev);
struct iio_ring_buffer *ring = indio_dev->ring;
- struct iio_sw_ring_buffer *sw_ring = iio_to_sw_ring(indio_dev->ring);
s64 time_ns;
__u8 *buf;
int b_sent;
@@ -140,7 +140,7 @@ static irqreturn_t ad7887_trigger_handler(int irq, void *p)
memcpy(buf + st->d_size - sizeof(s64),
&time_ns, sizeof(time_ns));
- indio_dev->ring->access.store_to(&sw_ring->buf, buf, time_ns);
+ indio_dev->ring->access->store_to(indio_dev->ring, buf, time_ns);
done:
kfree(buf);
iio_trigger_notify_done(indio_dev->trig);
@@ -148,6 +148,13 @@ done:
return IRQ_HANDLED;
}
+static const struct iio_ring_setup_ops ad7887_ring_setup_ops = {
+ .preenable = &ad7887_ring_preenable,
+ .postenable = &iio_triggered_ring_postenable,
+ .predisable = &iio_triggered_ring_predisable,
+ .postdisable = &ad7887_ring_postdisable,
+};
+
int ad7887_register_ring_funcs_and_init(struct iio_dev *indio_dev)
{
int ret;
@@ -158,7 +165,7 @@ int ad7887_register_ring_funcs_and_init(struct iio_dev *indio_dev)
goto error_ret;
}
/* Effectively select the ring buffer implementation */
- iio_ring_sw_register_funcs(&indio_dev->ring->access);
+ indio_dev->ring->access = &ring_sw_access_funcs;
indio_dev->pollfunc = kzalloc(sizeof(*indio_dev->pollfunc), GFP_KERNEL);
if (indio_dev->pollfunc == NULL) {
ret = -ENOMEM;
@@ -176,11 +183,7 @@ int ad7887_register_ring_funcs_and_init(struct iio_dev *indio_dev)
goto error_free_pollfunc;
}
/* Ring buffer functions - here trigger setup related */
-
- indio_dev->ring->preenable = &ad7887_ring_preenable;
- indio_dev->ring->postenable = &iio_triggered_ring_postenable;
- indio_dev->ring->predisable = &iio_triggered_ring_predisable;
- indio_dev->ring->postdisable = &ad7887_ring_postdisable;
+ indio_dev->ring->setup_ops = &ad7887_ring_setup_ops;
/* Flag that polled ring buffering is possible */
indio_dev->modes |= INDIO_RING_TRIGGERED;
OpenPOWER on IntegriCloud