aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorPeter Meerwald <pmeerw@pmeerw.net>2014-12-06 00:54:00 -0500
committerJonathan Cameron <jic23@kernel.org>2014-07-13 16:59:40 -0400
commit3008d082f2fa27249d6318cf46f835ba443d3950 (patch)
tree385d092c5072960394f587c95a31d44413344d5f /drivers/iio
parent1d15330a399217500d496f8cd1852e11225000a1 (diff)
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')
-rw-r--r--drivers/iio/adc/ad799x.c34
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,
375 return 0; 375 return 0;
376} 376}
377 377
378static int ad799x_write_event_config(struct iio_dev *indio_dev,
379 const struct iio_chan_spec *chan,
380 enum iio_event_type type,
381 enum iio_event_direction dir,
382 int state)
383{
384 struct ad799x_state *st = iio_priv(indio_dev);
385 int ret;
386
387 mutex_lock(&indio_dev->mlock);
388 if (iio_buffer_enabled(indio_dev)) {
389 ret = -EBUSY;
390 goto done;
391 }
392
393 if (state)
394 st->config |= BIT(chan->scan_index) << AD799X_CHANNEL_SHIFT;
395 else
396 st->config &= ~(BIT(chan->scan_index) << AD799X_CHANNEL_SHIFT);
397
398 if (st->config >> AD799X_CHANNEL_SHIFT)
399 st->config |= AD7998_ALERT_EN;
400 else
401 st->config &= ~AD7998_ALERT_EN;
402
403 ret = ad799x_write_config(st, st->config);
404
405done:
406 mutex_unlock(&indio_dev->mlock);
407
408 return ret;
409}
410
378static unsigned int ad799x_threshold_reg(const struct iio_chan_spec *chan, 411static unsigned int ad799x_threshold_reg(const struct iio_chan_spec *chan,
379 enum iio_event_direction dir, 412 enum iio_event_direction dir,
380 enum iio_event_info info) 413 enum iio_event_info info)
@@ -502,6 +535,7 @@ static const struct iio_info ad7993_4_7_8_irq_info = {
502 .read_raw = &ad799x_read_raw, 535 .read_raw = &ad799x_read_raw,
503 .event_attrs = &ad799x_event_attrs_group, 536 .event_attrs = &ad799x_event_attrs_group,
504 .read_event_config = &ad799x_read_event_config, 537 .read_event_config = &ad799x_read_event_config,
538 .write_event_config = &ad799x_write_event_config,
505 .read_event_value = &ad799x_read_event_value, 539 .read_event_value = &ad799x_read_event_value,
506 .write_event_value = &ad799x_write_event_value, 540 .write_event_value = &ad799x_write_event_value,
507 .driver_module = THIS_MODULE, 541 .driver_module = THIS_MODULE,