On 06/04/2014 12:42 AM, Peter Meerwald wrote:
allow to enable events previously, events were always reported as enabled, but actually only implicitly enabled when updating the buffer scan mode Signed-off-by: Peter Meerwald <pmeerw@xxxxxxxxxx> --- drivers/iio/adc/ad799x.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index b8191f1..f8bfbcb 100644 --- a/drivers/iio/adc/ad799x.c +++ b/drivers/iio/adc/ad799x.c @@ -375,6 +375,39 @@ static int ad799x_read_event_config(struct iio_dev *indio_dev, return 0; } +static int ad799x_write_event_config(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir, + int state) +{ + struct ad799x_state *st = iio_priv(indio_dev); + int ret; + + mutex_lock(&indio_dev->mlock); + if (iio_buffer_enabled(indio_dev)) { + ret = -EBUSY; + goto done; + } + + if (state) + st->config |= BIT(chan->scan_index) << AD799X_CHANNEL_SHIFT; + else + st->config &= ~(BIT(chan->scan_index) << AD799X_CHANNEL_SHIFT); + + if (st->config >> AD799X_CHANNEL_SHIFT) + st->config |= AD7998_ALERT_EN; + else + st->config &= ~AD7998_ALERT_EN; + + ret = ad799x_write_config(st, st->config);
If I understand this correctly the enabled channels will be overwritten again as soon as the scan mode is updated. I think that is a bit unexpected. I'm not quite sure how to implement being able to independently enable a channel for sampling and for event monitoring in a proper way though.
-- To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html