summaryrefslogtreecommitdiff
path: root/drivers/staging/iio/adc/ad7606_ring.c
diff options
context:
space:
mode:
authorJonathan Cameron <jic23@cam.ac.uk>2011-05-18 14:41:38 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2011-05-19 16:14:52 -0700
commit13cfac2038438bf98a649a5c92ed56e4534a0d84 (patch)
tree6d0ee66214b688ef9c99510f94d6afc7a7207911 /drivers/staging/iio/adc/ad7606_ring.c
parent70d4fd3fcd47e01c29754d59fffaaee47a690a50 (diff)
staging:iio:adc:ad7606 conversion to irq_chip based polling.
I'm far from sure what the best way to handle this particular part is, so have (I think) done the absolute minimum to change it to the new interface. V2: Trivial constification of device name. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Acked-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/iio/adc/ad7606_ring.c')
-rw-r--r--drivers/staging/iio/adc/ad7606_ring.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/drivers/staging/iio/adc/ad7606_ring.c b/drivers/staging/iio/adc/ad7606_ring.c
index b32cb0dea6d8..43caced22cee 100644
--- a/drivers/staging/iio/adc/ad7606_ring.c
+++ b/drivers/staging/iio/adc/ad7606_ring.c
@@ -157,16 +157,19 @@ static int ad7606_ring_preenable(struct iio_dev *indio_dev)
}
/**
- * ad7606_poll_func_th() th of trigger launched polling to ring buffer
+ * ad7606_trigger_handler_th() th of trigger launched polling to ring buffer
*
**/
-static void ad7606_poll_func_th(struct iio_dev *indio_dev, s64 time)
+static irqreturn_t ad7606_trigger_handler_th(int irq, void *p)
{
+ struct iio_poll_func *pf = p;
+ struct iio_dev *indio_dev = pf->private_data;
struct ad7606_state *st = indio_dev->dev_data;
gpio_set_value(st->pdata->gpio_convst, 1);
- return;
+ return IRQ_HANDLED;
}
+
/**
* ad7606_poll_bh_to_ring() bh of trigger launched polling to ring buffer
* @work_s: the work struct through which this was scheduled
@@ -245,10 +248,20 @@ int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev)
/* Effectively select the ring buffer implementation */
iio_ring_sw_register_funcs(&indio_dev->ring->access);
- ret = iio_alloc_pollfunc(indio_dev, NULL, &ad7606_poll_func_th);
- if (ret)
+ indio_dev->pollfunc = kzalloc(sizeof(*indio_dev->pollfunc), GFP_KERNEL);
+ if (indio_dev->pollfunc == NULL) {
+ ret = -ENOMEM;
goto error_deallocate_sw_rb;
-
+ }
+ indio_dev->pollfunc->private_data = indio_dev;
+ indio_dev->pollfunc->h = &ad7606_trigger_handler_th;
+ indio_dev->pollfunc->name =
+ kasprintf(GFP_KERNEL, "%s_consumer%d", indio_dev->name,
+ indio_dev->id);
+ if (indio_dev->pollfunc->name == NULL) {
+ ret = -ENOMEM;
+ goto error_free_poll_func;
+ }
/* Ring buffer functions - here trigger setup related */
indio_dev->ring->preenable = &ad7606_ring_preenable;
@@ -262,6 +275,8 @@ int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev)
/* Flag that polled ring buffering is possible */
indio_dev->modes |= INDIO_RING_TRIGGERED;
return 0;
+error_free_poll_func:
+ kfree(indio_dev->pollfunc);
error_deallocate_sw_rb:
iio_sw_rb_free(indio_dev->ring);
error_ret:
@@ -275,6 +290,7 @@ void ad7606_ring_cleanup(struct iio_dev *indio_dev)
iio_trigger_dettach_poll_func(indio_dev->trig,
indio_dev->pollfunc);
}
+ kfree(indio_dev->pollfunc->name);
kfree(indio_dev->pollfunc);
iio_sw_rb_free(indio_dev->ring);
}