Skip to content

Commit

Permalink
iio: add hardware triggered operating mode
Browse files Browse the repository at this point in the history
Devices, like stm32 timer, could be triggered by hardware events which
are not buffer or software events. However it could be necessary to
validate the triggers like it is done for buffer or event triggered modes.
This patch add a new INDIO_HARDWARE_TRIGGERED operating mode for this
kind of devices and allow this mode to register trigger consumer.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
  • Loading branch information
Benjamin Gaignard authored and Jonathan Cameron committed Jun 11, 2017
1 parent 4e36a8a commit d89e119
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/iio/industrialio-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ static void iio_device_unregister_sysfs(struct iio_dev *indio_dev)
static void iio_dev_release(struct device *device)
{
struct iio_dev *indio_dev = dev_to_iio_dev(device);
if (indio_dev->modes & (INDIO_BUFFER_TRIGGERED | INDIO_EVENT_TRIGGERED))
if (indio_dev->modes & INDIO_ALL_TRIGGERED_MODES)
iio_device_unregister_trigger_consumer(indio_dev);
iio_device_unregister_eventset(indio_dev);
iio_device_unregister_sysfs(indio_dev);
Expand Down Expand Up @@ -1705,7 +1705,7 @@ int iio_device_register(struct iio_dev *indio_dev)
"Failed to register event set\n");
goto error_free_sysfs;
}
if (indio_dev->modes & (INDIO_BUFFER_TRIGGERED | INDIO_EVENT_TRIGGERED))
if (indio_dev->modes & INDIO_ALL_TRIGGERED_MODES)
iio_device_register_trigger_consumer(indio_dev);

if ((indio_dev->modes & INDIO_ALL_BUFFER_MODES) &&
Expand Down
6 changes: 6 additions & 0 deletions include/linux/iio/iio.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,16 @@ unsigned int iio_get_time_res(const struct iio_dev *indio_dev);
#define INDIO_BUFFER_SOFTWARE 0x04
#define INDIO_BUFFER_HARDWARE 0x08
#define INDIO_EVENT_TRIGGERED 0x10
#define INDIO_HARDWARE_TRIGGERED 0x20

#define INDIO_ALL_BUFFER_MODES \
(INDIO_BUFFER_TRIGGERED | INDIO_BUFFER_HARDWARE | INDIO_BUFFER_SOFTWARE)

#define INDIO_ALL_TRIGGERED_MODES \
(INDIO_BUFFER_TRIGGERED \
| INDIO_EVENT_TRIGGERED \
| INDIO_HARDWARE_TRIGGERED)

#define INDIO_MAX_RAW_ELEMENTS 4

struct iio_trigger; /* forward declaration */
Expand Down

0 comments on commit d89e119

Please sign in to comment.