]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
iio: trigger: helpers to determine own trigger
authorLinus Walleij <linus.walleij@linaro.org>
Thu, 1 Sep 2016 08:27:17 +0000 (10:27 +0200)
committerJonathan Cameron <jic23@kernel.org>
Sat, 10 Sep 2016 15:49:14 +0000 (16:49 +0100)
commit702a7b8e064a93df0b63e9d718b666a9851088fc
treea0c55a6febbee6b67b507e83e49d8da4986ae8f8
parent4b1a9380a62ae669d1ae10dc118570c276a645ea
iio: trigger: helpers to determine own trigger

This adds a helper function to the IIO trigger framework:

iio_trigger_using_own(): for an IIO device, this tells
  whether the device is using itself as a trigger.
  This is true if the indio device:
  (A) supplies a trigger and
  (B) has assigned its own buffer poll function to use this
      trigger.

This helper function is good when constructing triggered,
buffered drivers that can either use its own hardware *OR*
an external trigger such as a HRTimer or even the trigger from
a totally different sensor.

Under such circumstances it is important to know for example
if the timestamp from the same trigger hardware should be used
when populating the buffer: if iio_trigger_using_own() is true,
we can use this timestamp, else we need to pick a unique
timestamp directly in the trigger handler.

For this to work of course IIO devices registering hardware
triggers must follow the convention to set the parent device
properly, as as well as setting the parent of the IIO device
itself.

When a new poll function is attached, we check if the parent
device of the IIO of the poll function is the same as the
parent device of the trigger and in that case we conclude that
the hardware is using itself as trigger.

Cc: Giuseppe Barba <giuseppe.barba@st.com>
Cc: Denis Ciocca <denis.ciocca@st.com>
Cc: Crestez Dan Leonard <leonard.crestez@intel.com>
Cc: Gregor Boirie <gregor.boirie@parrot.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/industrialio-trigger.c
include/linux/iio/trigger.h