• Linus Walleij's avatar
    iio: trigger: helpers to determine own trigger · 702a7b8e
    Linus Walleij authored
    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: default avatarLinus Walleij <linus.walleij@linaro.org>
    Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
    702a7b8e
industrialio-trigger.c 18.9 KB