diff options
author | Peter Meerwald <pmeerw@pmeerw.net> | 2014-12-06 08:54:00 +0300 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2014-07-14 00:59:40 +0400 |
commit | 3008d082f2fa27249d6318cf46f835ba443d3950 (patch) | |
tree | 385d092c5072960394f587c95a31d44413344d5f /drivers/iio/adc | |
parent | 1d15330a399217500d496f8cd1852e11225000a1 (diff) | |
download | linux-3008d082f2fa27249d6318cf46f835ba443d3950.tar.xz |
iio:adc:ad799x: Allow writing of event config
Allows explicity enabling of 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@pmeerw.net>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/adc')
-rw-r--r-- | drivers/iio/adc/ad799x.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index 08bcada39487..e37412da15f5 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); + +done: + mutex_unlock(&indio_dev->mlock); + + return ret; +} + static unsigned int ad799x_threshold_reg(const struct iio_chan_spec *chan, enum iio_event_direction dir, enum iio_event_info info) @@ -502,6 +535,7 @@ static const struct iio_info ad7993_4_7_8_irq_info = { .read_raw = &ad799x_read_raw, .event_attrs = &ad799x_event_attrs_group, .read_event_config = &ad799x_read_event_config, + .write_event_config = &ad799x_write_event_config, .read_event_value = &ad799x_read_event_value, .write_event_value = &ad799x_write_event_value, .driver_module = THIS_MODULE, |