aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2012-06-18 12:33:49 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-06-18 20:26:09 -0400
commit90032e4e9cc40e2933259190b670d70ddd149e68 (patch)
tree92bd743b87aa7d722eba306790155143e08fa129 /drivers/iio
parent23f2d735a932c7833d2d00da5e3ecdf4a6836210 (diff)
iio:adc:at91: Use new triggered buffer setup helper
Use the new triggered buffer setup helper function to allocate and register buffer and pollfunc. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Jonathan Cameron <jic23@kernel.org> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/adc/Kconfig3
-rw-r--r--drivers/iio/adc/at91_adc.c51
2 files changed, 5 insertions, 49 deletions
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 9a0df8123cc4..4f7f584cfd61 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -7,8 +7,7 @@ config AT91_ADC
7 tristate "Atmel AT91 ADC" 7 tristate "Atmel AT91 ADC"
8 depends on ARCH_AT91 8 depends on ARCH_AT91
9 select IIO_BUFFER 9 select IIO_BUFFER
10 select IIO_KFIFO_BUF 10 select IIO_TRIGGERED_BUFFER
11 select IIO_TRIGGER
12 select SYSFS 11 select SYSFS
13 help 12 help
14 Say yes here to build support for Atmel AT91 ADC. 13 Say yes here to build support for Atmel AT91 ADC.
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index f18a95d80255..6a084695b77e 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -26,9 +26,9 @@
26 26
27#include <linux/iio/iio.h> 27#include <linux/iio/iio.h>
28#include <linux/iio/buffer.h> 28#include <linux/iio/buffer.h>
29#include <linux/iio/kfifo_buf.h>
30#include <linux/iio/trigger.h> 29#include <linux/iio/trigger.h>
31#include <linux/iio/trigger_consumer.h> 30#include <linux/iio/trigger_consumer.h>
31#include <linux/iio/triggered_buffer.h>
32 32
33#include <mach/at91_adc.h> 33#include <mach/at91_adc.h>
34 34
@@ -318,58 +318,15 @@ static void at91_adc_trigger_remove(struct iio_dev *idev)
318 } 318 }
319} 319}
320 320
321static const struct iio_buffer_setup_ops at91_adc_buffer_ops = {
322 .preenable = &iio_sw_buffer_preenable,
323 .postenable = &iio_triggered_buffer_postenable,
324 .predisable = &iio_triggered_buffer_predisable,
325};
326
327static int at91_adc_buffer_init(struct iio_dev *idev) 321static int at91_adc_buffer_init(struct iio_dev *idev)
328{ 322{
329 int ret; 323 return iio_triggered_buffer_setup(idev, &iio_pollfunc_store_time,
330 324 &at91_adc_trigger_handler, NULL);
331 idev->buffer = iio_kfifo_allocate(idev);
332 if (!idev->buffer) {
333 ret = -ENOMEM;
334 goto error_ret;
335 }
336
337 idev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
338 &at91_adc_trigger_handler,
339 IRQF_ONESHOT,
340 idev,
341 "%s-consumer%d",
342 idev->name,
343 idev->id);
344 if (idev->pollfunc == NULL) {
345 ret = -ENOMEM;
346 goto error_pollfunc;
347 }
348
349 idev->setup_ops = &at91_adc_buffer_ops;
350 idev->modes |= INDIO_BUFFER_TRIGGERED;
351
352 ret = iio_buffer_register(idev,
353 idev->channels,
354 idev->num_channels);
355 if (ret)
356 goto error_register;
357
358 return 0;
359
360error_register:
361 iio_dealloc_pollfunc(idev->pollfunc);
362error_pollfunc:
363 iio_kfifo_free(idev->buffer);
364error_ret:
365 return ret;
366} 325}
367 326
368static void at91_adc_buffer_remove(struct iio_dev *idev) 327static void at91_adc_buffer_remove(struct iio_dev *idev)
369{ 328{
370 iio_buffer_unregister(idev); 329 iio_triggered_buffer_cleanup(idev);
371 iio_dealloc_pollfunc(idev->pollfunc);
372 iio_kfifo_free(idev->buffer);
373} 330}
374 331
375static int at91_adc_read_raw(struct iio_dev *idev, 332static int at91_adc_read_raw(struct iio_dev *idev,