Skip to content

Commit d89e119

Browse files
Benjamin-Gaignardjic23
authored andcommitted
iio: add hardware triggered operating mode
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>
1 parent 4e36a8a commit d89e119

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎drivers/iio/industrialio-core.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ static void iio_device_unregister_sysfs(struct iio_dev *indio_dev)
14231423
static void iio_dev_release(struct device *device)
14241424
{
14251425
struct iio_dev *indio_dev = dev_to_iio_dev(device);
1426-
if (indio_dev->modes & (INDIO_BUFFER_TRIGGERED | INDIO_EVENT_TRIGGERED))
1426+
if (indio_dev->modes & INDIO_ALL_TRIGGERED_MODES)
14271427
iio_device_unregister_trigger_consumer(indio_dev);
14281428
iio_device_unregister_eventset(indio_dev);
14291429
iio_device_unregister_sysfs(indio_dev);
@@ -1705,7 +1705,7 @@ int iio_device_register(struct iio_dev *indio_dev)
17051705
"Failed to register event set\n");
17061706
goto error_free_sysfs;
17071707
}
1708-
if (indio_dev->modes & (INDIO_BUFFER_TRIGGERED | INDIO_EVENT_TRIGGERED))
1708+
if (indio_dev->modes & INDIO_ALL_TRIGGERED_MODES)
17091709
iio_device_register_trigger_consumer(indio_dev);
17101710

17111711
if ((indio_dev->modes & INDIO_ALL_BUFFER_MODES) &&

‎include/linux/iio/iio.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,16 @@ unsigned int iio_get_time_res(const struct iio_dev *indio_dev);
352352
#define INDIO_BUFFER_SOFTWARE 0x04
353353
#define INDIO_BUFFER_HARDWARE 0x08
354354
#define INDIO_EVENT_TRIGGERED 0x10
355+
#define INDIO_HARDWARE_TRIGGERED 0x20
355356

356357
#define INDIO_ALL_BUFFER_MODES \
357358
(INDIO_BUFFER_TRIGGERED | INDIO_BUFFER_HARDWARE | INDIO_BUFFER_SOFTWARE)
358359

360+
#define INDIO_ALL_TRIGGERED_MODES \
361+
(INDIO_BUFFER_TRIGGERED \
362+
| INDIO_EVENT_TRIGGERED \
363+
| INDIO_HARDWARE_TRIGGERED)
364+
359365
#define INDIO_MAX_RAW_ELEMENTS 4
360366

361367
struct iio_trigger; /* forward declaration */

0 commit comments

Comments
 (0)