From: Lars-Peter Clausen <lars@metafoo.de>
To: Peter Meerwald <pmeerw@pmeerw.net>
Cc: linux-iio@vger.kernel.org, knaack.h@gmx.de
Subject: Re: [PATCH 15/15] iio:adc:ad799x: Allow to write event config
Date: Thu, 05 Jun 2014 11:14:14 +0200 [thread overview]
Message-ID: <539034E6.8000201@metafoo.de> (raw)
In-Reply-To: <alpine.DEB.2.01.1406041013310.12546@pmeerw.net>
On 06/04/2014 10:35 AM, Peter Meerwald wrote:
> Hello Lars-Peter,
>
> thank you for reviewing this series! reply below
>
>>> 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 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.
>
> yes, this is a problem; I have no good solution
> at least the enabled events show their correct status now :)
>
> one could turn on the union set of event and scan mode channels and ignore
> events or measurement when not in the event or or scan mode set, resp.
I that would be better, although it will probably require a custom demux for
the read data.
>
> sysfs-bus-iio documentation says
> "So if you want to be sure you have set what you think you have, check the
> contents of these attributes after everything is configured. Drivers
> may have to buffer any parameters so that they are consistent
> when a given event type is enabled at a future point (and not
> those for whatever event was previously enabled)."
>
> so there already is a warning :)
>
>
> another question:
> is an event supposed to occur on crossing the threshold or whenever and
> as long as the ADC value exceeds the threshold?
>
> the ad7997 does the later, the documentation is not very clear what is
> to be expected
It should probably only generate an event when it crosses the threshold
everything else makes little sense since we'd just generate a IRQ storm.
E.g. you can't make a over-temperature event go away in the interrupt
handler. I think in some drivers we temporarily disable the interrupt and
then start polling and wait for the value to go back below the threshold and
then re-enable it.
- Lars
next prev parent reply other threads:[~2014-06-05 9:14 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-03 22:42 [PATCH 00/15] ad799x cleanup Peter Meerwald
2014-06-03 22:42 ` [PATCH 01/15] staging:iio: Update iio_event_monitor program Peter Meerwald
2014-06-03 22:42 ` [PATCH 02/15] staging:iio: Fix iio_utils.h function prototypes Peter Meerwald
2014-06-03 22:42 ` [PATCH 03/15] iio:adc:ad799x: Fix ad799x_chip_info kerneldoc Peter Meerwald
2014-06-04 7:44 ` Lars-Peter Clausen
2014-06-03 22:42 ` [PATCH 04/15] iio:adc:ad799x: Drop I2C access helper functions Peter Meerwald
2014-06-03 22:42 ` [PATCH 05/15] iio:adc:ad799x: Save some lines in ad7997_8_update_scan_mode() exit handling Peter Meerwald
2014-06-04 7:56 ` Lars-Peter Clausen
2014-06-03 22:42 ` [PATCH 06/15] iio:adc:ad799x: Use BIT() and GENMASK() Peter Meerwald
2014-06-03 22:42 ` [PATCH 07/15] iio:adc:ad799x: Only expose event interface when IRQ is available Peter Meerwald
2014-06-04 8:01 ` Lars-Peter Clausen
2014-06-03 22:42 ` [PATCH 08/15] iio:adc:ad799x: Make chan_spec const in ad799x_chip_config struct Peter Meerwald
2014-06-04 7:57 ` Lars-Peter Clausen
2014-06-03 22:42 ` [PATCH 09/15] iio:adc:ad799x: Fix reported event values, apply shift Peter Meerwald
2014-06-03 22:42 ` [PATCH 10/15] iio:adc:ad799x: Check event value range on write Peter Meerwald
2014-06-04 7:46 ` Lars-Peter Clausen
2014-06-03 22:42 ` [PATCH 11/15] iio:adc:ad799x: Add helper function to read/write config register Peter Meerwald
2014-06-04 8:05 ` Lars-Peter Clausen
2014-06-04 8:42 ` Peter Meerwald
2014-06-03 22:42 ` [PATCH 12/15] iio:adc:ad799x: Write default config on probe and reset alert status on probe Peter Meerwald
2014-06-04 8:05 ` Lars-Peter Clausen
2014-06-03 22:42 ` [PATCH 13/15] iio:adc:ad799x: Rename ad7997_8_update_scan_mode() to ad799x_update_scan_mode() Peter Meerwald
2014-06-04 8:06 ` Lars-Peter Clausen
2014-06-03 22:42 ` [PATCH 14/15] iio:adc:ad799x: Return more meaningful event enabled state Peter Meerwald
2014-06-03 22:42 ` [PATCH 15/15] iio:adc:ad799x: Allow to write event config Peter Meerwald
2014-06-04 7:55 ` Lars-Peter Clausen
2014-06-04 8:35 ` Peter Meerwald
2014-06-05 9:14 ` Lars-Peter Clausen [this message]
2014-06-05 20:15 ` [PATCH 00/15] ad799x cleanup Jonathan Cameron
2014-06-07 15:53 ` Peter Meerwald
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=539034E6.8000201@metafoo.de \
--to=lars@metafoo.de \
--cc=knaack.h@gmx.de \
--cc=linux-iio@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/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).