Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1272245

[RFC 8/9] iio: buffer: allow for last-second trigger spawning from device driver

From Marc Titinger <mtitinger@baylibre.com>
Newsgroups linux.kernel
Subject [RFC 8/9] iio: buffer: allow for last-second trigger spawning from device driver
Date 2015-11-18 15:50 +0100
Message-ID <qwcdB-4dg-35@gated-at.bofh.it> (permalink)
References <qwc3T-48h-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


The hrtimer sw-trigger allow for polling mode on devices w/o hard irq
trigger source, but setting the frequency from userland for both the
hrtimer trigger device and the adc is error prone.

Make adc drivers able to setup the sw-trigger at the last second when the
buffer is enabled, and the sampling frequency is known.

enable_trigger is called from verify_update, before the classical setup_ops
are called in buffers_enable. This gives a chance to complete the setup of
indio_dev->trig.

Signed-off-by: Marc Titinger <mtitinger@baylibre.com>
---
 drivers/iio/industrialio-buffer.c | 5 +++++
 include/linux/iio/iio.h           | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index d7e908a..ba7abd4 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -647,6 +647,11 @@ static int iio_verify_update(struct iio_dev *indio_dev,
 	if (insert_buffer)
 		modes &= insert_buffer->access->modes;
 
+	if (indio_dev->setup_ops &&
+	    indio_dev->setup_ops->enable_trigger &&
+	   (indio_dev->setup_ops->enable_trigger(indio_dev) < 0))
+		return -ENXIO;
+
 	/* Definitely possible for devices to support both of these. */
 	if ((modes & INDIO_BUFFER_TRIGGERED) && indio_dev->trig) {
 		config->mode = INDIO_BUFFER_TRIGGERED;
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 7bb7f67..8f82113 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -419,6 +419,8 @@ struct iio_info {
 
 /**
  * struct iio_buffer_setup_ops - buffer setup related callbacks
+ * @enable_trigger:	[DRIVER] function to call if a trigger is instancied
+ *				 upon enabling the buffer (sw triggers)
  * @preenable:		[DRIVER] function to run prior to marking buffer enabled
  * @postenable:		[DRIVER] function to run after marking buffer enabled
  * @predisable:		[DRIVER] function to run prior to marking buffer
@@ -428,6 +430,7 @@ struct iio_info {
  *			scan mask is valid for the device.
  */
 struct iio_buffer_setup_ops {
+	int (*enable_trigger)(struct iio_dev *);
 	int (*preenable)(struct iio_dev *);
 	int (*postenable)(struct iio_dev *);
 	int (*predisable)(struct iio_dev *);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC 0/9] spawn hrtimer trigger from client driver upon enabling buffer Marc Titinger <mtitinger@baylibre.com> - 2015-11-18 15:40 +0100
  [RFC 1/9] configfs: Allow dynamic group creation Marc Titinger <mtitinger@baylibre.com> - 2015-11-18 15:40 +0100
  [RFC 7/9] iio: ina2xx: add triggered buffer Marc Titinger <mtitinger@baylibre.com> - 2015-11-18 15:50 +0100
  [RFC 2/9] iio: core: Introduce IIO configfs support Marc Titinger <mtitinger@baylibre.com> - 2015-11-18 15:50 +0100
  [RFC 8/9] iio: buffer: allow for last-second trigger spawning from device driver Marc Titinger <mtitinger@baylibre.com> - 2015-11-18 15:50 +0100
    Re: [RFC 8/9] iio: buffer: allow for last-second trigger spawning  from device driver Jonathan Cameron <jic23@kernel.org> - 2015-11-18 20:00 +0100
      Re: [RFC 8/9] iio: buffer: allow for last-second trigger spawning  from device driver Marc Titinger <mtitinger@baylibre.com> - 2015-11-19 10:20 +0100
        Re: [RFC 8/9] iio: buffer: allow for last-second trigger spawning  from device driver Jonathan Cameron <jic23@kernel.org> - 2015-11-21 19:20 +0100
  [RFC 3/9] iio: core: Introduce IIO software triggers Marc Titinger <mtitinger@baylibre.com> - 2015-11-18 15:50 +0100
  [RFC 6/9] iio: ina2xx: add direct IO support for TI INA2xx Power Monitors Marc Titinger <mtitinger@baylibre.com> - 2015-11-18 15:50 +0100
    Re: [RFC 6/9] iio: ina2xx: add direct IO support for TI INA2xx Power  Monitors Jonathan Cameron <jic23@kernel.org> - 2015-11-21 19:20 +0100
      Re: [RFC 6/9] iio: ina2xx: add direct IO support for TI INA2xx Power  Monitors Marc Titinger <mtitinger@baylibre.com> - 2015-11-23 17:20 +0100
        Re: [RFC 6/9] iio: ina2xx: add direct IO support for TI INA2xx Power  Monitors Jonathan Cameron <jic23@kernel.org> - 2015-11-29 16:20 +0100

csiph-web