From: Eugen Hristev <eugen.hristev@microchip.com>
To: nicolas.ferre@microchip.com, ludovic.desroches@microchip.com,
alexandre.belloni@free-electrons.com, linux-iio@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, jic23@kernel.org,
linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Cc: Eugen Hristev <eugen.hristev@microchip.com>
Subject: [PATCH 05/14] iio: triggers: add helper function to retrieve trigger
Date: Fri, 22 Dec 2017 17:07:12 +0200 [thread overview]
Message-ID: <1513955241-10985-6-git-send-email-eugen.hristev@microchip.com> (raw)
In-Reply-To: <1513955241-10985-1-git-send-email-eugen.hristev@microchip.com>
Add a helper function that will retrieve a trigger by index
from a device. This is intended to be used in trigger consumer drivers.
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
---
drivers/iio/iio_core_trigger.h | 21 +++++++++++++++++++++
drivers/iio/industrialio-trigger.c | 23 +++++++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/drivers/iio/iio_core_trigger.h b/drivers/iio/iio_core_trigger.h
index 1fdb1e4..14c4253 100644
--- a/drivers/iio/iio_core_trigger.h
+++ b/drivers/iio/iio_core_trigger.h
@@ -21,6 +21,15 @@ void iio_device_register_trigger_consumer(struct iio_dev *indio_dev);
**/
void iio_device_unregister_trigger_consumer(struct iio_dev *indio_dev);
+/**
+ * iio_trigger_find_from_device() - get the trigger from the device having the
+ * index given.
+ * @indio_dev: iio_dev where to get the trigger from
+ * @index: the index of the trigger to retrieve
+ **/
+__maybe_unused struct iio_trigger *
+iio_trigger_find_from_device(struct iio_dev *indio_dev, u32 index);
+
#else
/**
@@ -40,4 +49,16 @@ static void iio_device_unregister_trigger_consumer(struct iio_dev *indio_dev)
{
}
+/**
+ * iio_trigger_find_from_device() - get the trigger from the device having the
+ * index given.
+ * @indio_dev: iio_dev where to get the trigger from
+ * @index: the index of the trigger to retrieve
+ **/
+static __maybe_unused struct iio_trigger *
+iio_trigger_find_from_device(struct iio_dev *indio_dev, u32 index)
+{
+ return NULL;
+}
+
#endif /* CONFIG_TRIGGER_CONSUMER */
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
index ce66699..cbaa079 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -134,6 +134,29 @@ int iio_trigger_set_immutable(struct iio_dev *indio_dev, struct iio_trigger *tri
}
EXPORT_SYMBOL(iio_trigger_set_immutable);
+/* Find the trigger from the given device corresponding to given index */
+struct __maybe_unused iio_trigger *
+iio_trigger_find_from_device(struct iio_dev *indio_dev, u32 index)
+{
+ struct iio_trigger *iter, *trig = NULL;
+ u32 i = 0;
+
+ mutex_lock(&iio_trigger_list_lock);
+
+ list_for_each_entry(iter, &iio_trigger_list, list) {
+ if (!iio_trigger_validate_own_device(iter, indio_dev)) {
+ if (i == index) {
+ trig = iter;
+ break;
+ }
+ i++;
+ }
+ }
+ mutex_unlock(&iio_trigger_list_lock);
+
+ return trig;
+}
+
/* Search for trigger by name, assuming iio_trigger_list_lock held */
static struct iio_trigger *__iio_trigger_find_by_name(const char *name)
{
--
2.7.4
next prev parent reply other threads:[~2017-12-22 15:07 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-22 15:07 [PATCH 00/14] iio: triggers: add consumer support Eugen Hristev
2017-12-22 15:07 ` [PATCH 01/14] MAINTAINERS: add sama5d2 resistive touchscreen Eugen Hristev
2017-12-22 15:07 ` [PATCH 02/14] iio: Add channel for Position Eugen Hristev
[not found] ` <1513955241-10985-3-git-send-email-eugen.hristev-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org>
2017-12-29 16:09 ` Jonathan Cameron
2017-12-22 15:07 ` [PATCH 03/14] dt-bindings: iio: add binding support for iio trigger provider/consumer Eugen Hristev
[not found] ` <1513955241-10985-4-git-send-email-eugen.hristev-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org>
2017-12-26 22:35 ` Rob Herring
2017-12-29 17:24 ` Jonathan Cameron
2017-12-22 15:07 ` [PATCH 04/14] dt-bindings: input: touchscreen: sama5d2_rts: create bindings Eugen Hristev
2017-12-22 15:07 ` Eugen Hristev [this message]
2017-12-22 15:07 ` [PATCH 06/14] iio: triggers: expose attach and detach helpers for pollfuncs Eugen Hristev
2017-12-22 15:07 ` [PATCH 07/14] iio: triggers: on pollfunc attach, complete iio_dev if NULL Eugen Hristev
2017-12-29 17:23 ` Jonathan Cameron
2017-12-22 15:07 ` [PATCH 08/14] iio: triggers: add private data to pollfuncs Eugen Hristev
2017-12-22 15:07 ` [PATCH 09/14] iio: inkern: triggers: create helpers for OF trigger retrieval Eugen Hristev
[not found] ` <1513955241-10985-10-git-send-email-eugen.hristev-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org>
2017-12-29 17:20 ` Jonathan Cameron
[not found] ` <1513955241-10985-1-git-send-email-eugen.hristev-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org>
2017-12-22 15:07 ` [PATCH 10/14] iio: adc: at91-sama5d2_adc: force trigger removal on module remove Eugen Hristev
[not found] ` <1513955241-10985-11-git-send-email-eugen.hristev-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org>
2017-12-29 16:22 ` Jonathan Cameron
2017-12-22 15:07 ` [PATCH 11/14] iio: adc: at91-sama5d2_adc: optimize scan index for diff channels Eugen Hristev
[not found] ` <1513955241-10985-12-git-send-email-eugen.hristev-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org>
2017-12-29 16:24 ` Jonathan Cameron
2017-12-22 15:07 ` [PATCH 12/14] iio: adc: at91-sama5d2_adc: support for position and pressure channels Eugen Hristev
[not found] ` <1513955241-10985-13-git-send-email-eugen.hristev-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org>
2017-12-29 17:02 ` Jonathan Cameron
2018-01-04 15:17 ` Eugen Hristev
2018-01-06 15:05 ` Jonathan Cameron
2018-01-08 14:12 ` Ludovic Desroches
2018-01-14 10:47 ` Jonathan Cameron
2017-12-22 15:07 ` [PATCH 13/14] input: touchscreen: sama5d2_rts: SAMA5D2 Resistive touchscreen driver Eugen Hristev
[not found] ` <1513955241-10985-14-git-send-email-eugen.hristev-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org>
2017-12-22 16:29 ` Philippe Ombredanne
2017-12-26 22:41 ` Rob Herring
2017-12-29 17:16 ` Jonathan Cameron
2017-12-22 15:07 ` [PATCH 14/14] ARM: dts: at91: sama5d2: Add resistive touch device Eugen Hristev
[not found] ` <1513955241-10985-15-git-send-email-eugen.hristev-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org>
2017-12-22 16:10 ` Alexandre Belloni
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=1513955241-10985-6-git-send-email-eugen.hristev@microchip.com \
--to=eugen.hristev@microchip.com \
--cc=alexandre.belloni@free-electrons.com \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=jic23@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ludovic.desroches@microchip.com \
--cc=nicolas.ferre@microchip.com \
/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;
as well as URLs for NNTP newsgroup(s).