From: Marc Titinger <mtitinger@baylibre.com>
To: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net
Cc: daniel.baluta@intel.com, linux-kernel@vger.kernel.org,
linux-iio@vger.kernel.org, Marc Titinger <mtitinger@baylibre.com>
Subject: [RFC 8/9] iio: buffer: allow for last-second trigger spawning from device driver
Date: Wed, 18 Nov 2015 15:38:34 +0100 [thread overview]
Message-ID: <1447857515-23935-9-git-send-email-mtitinger@baylibre.com> (raw)
In-Reply-To: <1447857515-23935-1-git-send-email-mtitinger@baylibre.com>
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
next prev parent reply other threads:[~2015-11-18 14:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-18 14:38 [RFC 0/9] spawn hrtimer trigger from client driver upon enabling buffer Marc Titinger
2015-11-18 14:38 ` [RFC 1/9] configfs: Allow dynamic group creation Marc Titinger
2015-11-18 14:38 ` [RFC 2/9] iio: core: Introduce IIO configfs support Marc Titinger
2015-11-18 14:38 ` [RFC 3/9] iio: core: Introduce IIO software triggers Marc Titinger
2015-11-18 14:38 ` [RFC 4/9] iio: trigger: Introduce IIO hrtimer based trigger Marc Titinger
2015-11-18 14:38 ` [RFC 5/9] iio: Documentation: Add IIO configfs documentation Marc Titinger
2015-11-18 15:38 ` Crt Mori
2015-11-18 16:06 ` Marc Titinger
2015-11-18 16:15 ` Daniel Baluta
2015-11-18 17:32 ` Jonathan Cameron
2015-11-18 14:38 ` [RFC 6/9] iio: ina2xx: add direct IO support for TI INA2xx Power Monitors Marc Titinger
2015-11-21 18:13 ` Jonathan Cameron
2015-11-23 16:15 ` Marc Titinger
2015-11-29 15:17 ` Jonathan Cameron
2015-11-18 14:38 ` [RFC 7/9] iio: ina2xx: add triggered buffer Marc Titinger
2015-11-18 14:38 ` Marc Titinger [this message]
2015-11-18 18:55 ` [RFC 8/9] iio: buffer: allow for last-second trigger spawning from device driver Jonathan Cameron
2015-11-19 9:15 ` Marc Titinger
2015-11-21 18:18 ` Jonathan Cameron
2015-11-18 14:38 ` [RFC 9/9] iio: (RFC) illustrate creation/destruction of hrtimer trigger upon buffer enable Marc Titinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1447857515-23935-9-git-send-email-mtitinger@baylibre.com \
--to=mtitinger@baylibre.com \
--cc=daniel.baluta@intel.com \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox