linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Meerwald <pmeerw@pmeerw.net>
To: linux-iio@vger.kernel.org
Cc: lars@metafoo.de, jic23@kernel.org, Peter Meerwald <pmeerw@pmeerw.net>
Subject: [PATCH v2 13/13] iio:adc:ad799x: Allow to write event config
Date: Sat,  7 Jun 2014 17:31:37 +0200	[thread overview]
Message-ID: <1402155097-435-14-git-send-email-pmeerw@pmeerw.net> (raw)
In-Reply-To: <1402155097-435-1-git-send-email-pmeerw@pmeerw.net>

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@pmeerw.net>
---
 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 8b9c939..4048700 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)
@@ -503,6 +536,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,
-- 
1.9.1


      parent reply	other threads:[~2014-06-07 15:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-07 15:31 [PATCH v2 00/13] ad799x cleanup Peter Meerwald
2014-06-07 15:31 ` [PATCH v2 01/13] iio:adc:ad799x: Fix reading and writing of event values, apply shift Peter Meerwald
2014-06-09 12:10   ` Lars-Peter Clausen
2014-06-07 15:31 ` [PATCH v2 02/13] iio:adc:ad799x: Fix ad799x_chip_info kerneldoc Peter Meerwald
2014-06-07 15:31 ` [PATCH v2 03/13] iio:adc:ad799x: Drop I2C access helper functions Peter Meerwald
2014-06-07 15:31 ` [PATCH v2 04/13] iio:adc:ad799x: Save some lines in ad7997_8_update_scan_mode() exit handling Peter Meerwald
2014-06-07 15:31 ` [PATCH v2 05/13] iio:adc:ad799x: Use BIT() and GENMASK() Peter Meerwald
2014-06-09 12:02   ` Lars-Peter Clausen
2014-06-07 15:31 ` [PATCH v2 06/13] iio:adc:ad799x: Only expose event interface when IRQ is available Peter Meerwald
2014-06-07 15:31 ` [PATCH v2 07/13] iio:adc:ad799x: Make chan_spec const in ad799x_chip_config struct Peter Meerwald
2014-06-07 15:31 ` [PATCH v2 08/13] iio:adc:ad799x: Check range when writing event value Peter Meerwald
2014-06-07 15:31 ` [PATCH v2 09/13] iio:adc:ad799x: Add helper function to read/write config register Peter Meerwald
2014-06-07 15:31 ` [PATCH v2 10/13] iio:adc:ad799x: Write default config on probe and reset alert status on probe Peter Meerwald
2014-06-07 15:31 ` [PATCH v2 11/13] iio:adc:ad799x: Set conversion channels and rename ad7997_8_update_scan_mode() Peter Meerwald
2014-06-07 15:31 ` [PATCH v2 12/13] iio:adc:ad799x: Return more meaningful event enabled state Peter Meerwald
2014-06-07 15:31 ` Peter Meerwald [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1402155097-435-14-git-send-email-pmeerw@pmeerw.net \
    --to=pmeerw@pmeerw.net \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).