iio:core: Handle error when mask type is not separate
PATCH 1/1 iio:core: Handle error when mask type is not separate
When event spec is shared by multiple channels, which has definition for mask_shared_by_type, iio_device_register_eventset fails.
For example:
static const struct iio_event_spec iio_dummy_events[] = {
{
.type = IIO_EV_TYPE_THRESH,
.dir = IIO_EV_DIR_RISING, .mask_separate = BIT(IIO_EV_INFO_ENABLE), .mask_shared_by_type = BIT(IIO_EV_INFO_VALUE),
}, {
.type = IIO_EV_TYPE_THRESH,
.dir = IIO_EV_DIR_FALLING, .mask_separate = BIT(IIO_EV_INFO_ENABLE),a .mask_shared_by_type = BIT(IIO_EV_INFO_VALUE),
}
};
If two channels use this event spec, this will result in error.
This change handles EBUSY error similar to iio_device_add_info_mask_type().
--- drivers/iio/industrialio-event.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iio/industrialio-event.c +3 -0
@@ -345,6 +345,9 @@ static int iio_device_add_event(struct iio_dev *indio_dev, &indio_dev->event_interface->dev_attr_list);kfree (postfix); +if ((ret == -EBUSY ) && (shared_by !=IIO_SEPARATE )) +continue ; +if (ret)return ret;
Signature · 1 line
1.9.1
Jonathan Cameron
maintainerQuoted 18 lines · Srinivas Pandruvada
When event spec is shared by multiple channels, which has definition for
mask_shared_by_type,iio_device_register_eventsetfails.For example:
static const structiio_event_speciio_dummy_events[] = {
{
.type =IIO_EV_TYPE_THRESH,
.dir =IIO_EV_DIR_RISING, .mask_separate =BIT(IIO_EV_INFO_ENABLE), .mask_shared_by_type =BIT(IIO_EV_INFO_VALUE),
}, {
.type =IIO_EV_TYPE_THRESH,
.dir =IIO_EV_DIR_FALLING, .mask_separate = BIT(IIO_EV_INFO_ENABLE),a .mask_shared_by_type =BIT(IIO_EV_INFO_VALUE),
}
};
Quoted 5 lines
If two channels use this event spec, this will result in error.
This change handles EBUSY error similar to
iio_device_add_info_mask_type().Signed-off-by Srinivas Pandruvada <[email protected]>
Good spot. Applied to the fixes-togreg branch of iio.git and marked for stable. Grep suggests there is only one user in the tree (lis3l02dq) but still worth getting the fix out there for that one.
J
Quoted 19 lines
--- drivers/iio/industrialio-event.c | 3 +++ 1 file changed, 3 insertions(+)drivers/iio/industrialio-event.c +3
-0@@ -345,6 +345,9 @@ static int iio_device_add_event(struct iio_dev *indio_dev, &indio_dev->event_interface->dev_attr_list);kfree (postfix); +if ((ret == -EBUSY ) && (shared_by !=IIO_SEPARATE )) +continue ; +if (ret)return ret;