Skip to content

Commit 1843c2f

Browse files
itirdeajic23
authored andcommitted
iio: core: Introduce IIO_EV_DIR_NONE
For some events (e.g.: step detector) a direction does not make sense. Add IIO_EV_DIR_NONE to be used with such events and generate sysfs event attributes that do not contain direction. Signed-off-by: Irina Tirdea <[email protected]> Signed-off-by: Daniel Baluta <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 55aebeb commit 1843c2f

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

drivers/iio/industrialio-event.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,15 @@ static int iio_device_add_event(struct iio_dev *indio_dev,
327327
for_each_set_bit(i, mask, sizeof(*mask)*8) {
328328
if (i >= ARRAY_SIZE(iio_ev_info_text))
329329
return -EINVAL;
330-
postfix = kasprintf(GFP_KERNEL, "%s_%s_%s",
331-
iio_ev_type_text[type], iio_ev_dir_text[dir],
332-
iio_ev_info_text[i]);
330+
if (dir != IIO_EV_DIR_NONE)
331+
postfix = kasprintf(GFP_KERNEL, "%s_%s_%s",
332+
iio_ev_type_text[type],
333+
iio_ev_dir_text[dir],
334+
iio_ev_info_text[i]);
335+
else
336+
postfix = kasprintf(GFP_KERNEL, "%s_%s",
337+
iio_ev_type_text[type],
338+
iio_ev_info_text[i]);
333339
if (postfix == NULL)
334340
return -ENOMEM;
335341

include/linux/iio/types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ enum iio_event_direction {
8686
IIO_EV_DIR_EITHER,
8787
IIO_EV_DIR_RISING,
8888
IIO_EV_DIR_FALLING,
89+
IIO_EV_DIR_NONE,
8990
};
9091

9192
#define IIO_VAL_INT 1

0 commit comments

Comments
 (0)