iio:adc:at91: Use new triggered buffer setup helper
authorLars-Peter Clausen <lars@metafoo.de>
Mon, 18 Jun 2012 16:33:49 +0000 (18:33 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 19 Jun 2012 00:26:09 +0000 (17:26 -0700)
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>
drivers/iio/adc/Kconfig
drivers/iio/adc/at91_adc.c

index 9a0df8123cc4058ddebd94764db966f2e7a73a5c..4f7f584cfd61ef361cfff609ae0c9a9bca999686 100644 (file)
@@ -7,8 +7,7 @@ config AT91_ADC
        tristate "Atmel AT91 ADC"
        depends on ARCH_AT91
        select IIO_BUFFER
-       select IIO_KFIFO_BUF
-       select IIO_TRIGGER
+       select IIO_TRIGGERED_BUFFER
        select SYSFS
        help
          Say yes here to build support for Atmel AT91 ADC.
index f18a95d802551fc029f51b33037e83a2185a7f79..6a084695b77e4b12529306f7fc01b4ddac7ae315 100644 (file)
@@ -26,9 +26,9 @@
 
 #include <linux/iio/iio.h>
 #include <linux/iio/buffer.h>
-#include <linux/iio/kfifo_buf.h>
 #include <linux/iio/trigger.h>
 #include <linux/iio/trigger_consumer.h>
+#include <linux/iio/triggered_buffer.h>
 
 #include <mach/at91_adc.h>
 
@@ -318,58 +318,15 @@ static void at91_adc_trigger_remove(struct iio_dev *idev)
        }
 }
 
-static const struct iio_buffer_setup_ops at91_adc_buffer_ops = {
-       .preenable = &iio_sw_buffer_preenable,
-       .postenable = &iio_triggered_buffer_postenable,
-       .predisable = &iio_triggered_buffer_predisable,
-};
-
 static int at91_adc_buffer_init(struct iio_dev *idev)
 {
-       int ret;
-
-       idev->buffer = iio_kfifo_allocate(idev);
-       if (!idev->buffer) {
-               ret = -ENOMEM;
-               goto error_ret;
-       }
-
-       idev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
-                                           &at91_adc_trigger_handler,
-                                           IRQF_ONESHOT,
-                                           idev,
-                                           "%s-consumer%d",
-                                           idev->name,
-                                           idev->id);
-       if (idev->pollfunc == NULL) {
-               ret = -ENOMEM;
-               goto error_pollfunc;
-       }
-
-       idev->setup_ops = &at91_adc_buffer_ops;
-       idev->modes |= INDIO_BUFFER_TRIGGERED;
-
-       ret = iio_buffer_register(idev,
-                                 idev->channels,
-                                 idev->num_channels);
-       if (ret)
-               goto error_register;
-
-       return 0;
-
-error_register:
-       iio_dealloc_pollfunc(idev->pollfunc);
-error_pollfunc:
-       iio_kfifo_free(idev->buffer);
-error_ret:
-       return ret;
+       return iio_triggered_buffer_setup(idev, &iio_pollfunc_store_time,
+               &at91_adc_trigger_handler, NULL);
 }
 
 static void at91_adc_buffer_remove(struct iio_dev *idev)
 {
-       iio_buffer_unregister(idev);
-       iio_dealloc_pollfunc(idev->pollfunc);
-       iio_kfifo_free(idev->buffer);
+       iio_triggered_buffer_cleanup(idev);
 }
 
 static int at91_adc_read_raw(struct iio_dev *idev,