All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH v2 18/20] staging:iio:ad799x: Use event spec for threshold hysteresis
Date: Sat, 12 Oct 2013 13:40:27 +0200	[thread overview]
Message-ID: <5259352B.5070906@metafoo.de> (raw)
In-Reply-To: <52593A44.3080007@kernel.org>

On 10/12/2013 02:02 PM, Jonathan Cameron wrote:
> On 10/07/13 15:11, Lars-Peter Clausen wrote:
>> Register the event threshold hysteresis attributes by using the new
>> IIO_EV_INFO_HYSTERESIS event spec type. This allows us to throw away a good
>> portion of boiler-plate code.
>>
>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> 
> Applied, as here as it is a great improvement.
> 
> I do wonder if we can handle the EITHER direction of the event more
> cleanly, now we have the different event masks.
> 
> Maybe that is even uglier than the current option.
> 
> What do you think?
[...]
>> +	}, {
>> +		.type = IIO_EV_TYPE_THRESH,
>> +		.dir = IIO_EV_DIR_EITHER,
>> +		.mask_separate = BIT(IIO_EV_INFO_HYSTERESIS),
> This is a little ugly, but I can see why you did it.  Do we need to allow an additional
> event_mask, perhaps
> mask_shared_by_both_directions ?
> 
> Then we could drop the IIO_EV_DIR_EITHER direction entirely.

Yes, you are right this is not exactly beautiful. I had to struggle with
myself a bit to convince me that it could go in as it is. I've tried a few
alternatives, but couldn't really find anything better. The problem is that
the setting whether we want to share the attribute by event direction and
e.g. by channel type are orthogonal. It is possible that an attribute is
shared by both event direction and channel type. That's why a separate event
mask doesn't work. The other two options I saw were:
1) Encoding the direction directly in the bit mask like we did before with
the old style event mask and the IIO_EV_BIT() macro. E.g. something like:
.mask_separate = IIO_EV_BIT(IIO_EV_DIR_EITHER, IIO_EV_INFO_HYSTERESIS)

The problem with this approach is that it takes up a lot of space in the
mask and limits the number of info attributes we can have.

2) Have one entry in the event spec array for each attribute e.g.

{
	.type = IIO_EV_TYPE_THRESH.
	.dir = IIO_EV_DIR_EITHER,
	.info = IIO_EV_INFO_HYSTERESIS,
	.shared_by = IIO_SEPARATE,
}

This again takes up extra space considering that the type and direction are
usually shared between the event attributes.

So the current approach is kind of a hybrid between the two. It allows you
to have multiple entries when necessary, but also allows you to group
similar attributes together.

- Lars


  reply	other threads:[~2013-10-12 11:38 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-07 14:11 [PATCH v2 01/20] iio: Factor IIO value formating into its own function Lars-Peter Clausen
2013-10-07 14:11 ` [PATCH v2 02/20] iio: Extend the event config interface Lars-Peter Clausen
2013-10-12 11:33   ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 03/20] iio:max1363: Switch to new " Lars-Peter Clausen
2013-10-12 11:34   ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 04/20] iio:ad5421: " Lars-Peter Clausen
2013-10-12 11:35   ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 05/20] iio:gp2ap020a00f: " Lars-Peter Clausen
2013-10-12 11:36   ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 06/20] iio:tsl2563: " Lars-Peter Clausen
2013-10-12 11:39   ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 07/20] iio:apds9300: Use " Lars-Peter Clausen
2013-10-12 11:41   ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 08/20] staging:iio:lis3l02dq: Switch to " Lars-Peter Clausen
2013-10-12 11:42   ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 09/20] staging:iio:lis2l02dq: Share threshold value between axis Lars-Peter Clausen
2013-10-12 11:43   ` Jonathan Cameron
2013-10-12 11:45   ` Jonathan Cameron
2013-10-12 10:51     ` Lars-Peter Clausen
2013-10-07 14:11 ` [PATCH v2 10/20] staging:iio:sca3000: Switch to new config interface Lars-Peter Clausen
2013-10-12 11:46   ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 11/20] staging:iio:ad7291: Switch to new event " Lars-Peter Clausen
2013-10-12 11:46   ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 12/20] staging:iio:ad799x: " Lars-Peter Clausen
2013-10-12 11:47   ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 13/20] staging:iio:ad7150: " Lars-Peter Clausen
2013-10-12 11:48   ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 14/20] staging:iio:simple_dummy: " Lars-Peter Clausen
2013-10-12 11:50   ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 15/20] staging:iio:tsl2x7x: " Lars-Peter Clausen
2013-10-12 11:50   ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 16/20] iio: Add a hysteresis event info attribute Lars-Peter Clausen
2013-10-12 11:51   ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 17/20] staging:iio:ad799x: Simplify threshold register look-up Lars-Peter Clausen
2013-10-12 11:52   ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 18/20] staging:iio:ad799x: Use event spec for threshold hysteresis Lars-Peter Clausen
2013-10-12 12:02   ` Jonathan Cameron
2013-10-12 11:40     ` Lars-Peter Clausen [this message]
2013-10-12 13:05       ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 19/20] staging:iio:ad7291: " Lars-Peter Clausen
2013-10-12 12:04   ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 20/20] iio: Remove support for the legacy event config interface Lars-Peter Clausen
2013-10-12 11:24 ` [PATCH v2 01/20] iio: Factor IIO value formating into its own function Jonathan Cameron

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=5259352B.5070906@metafoo.de \
    --to=lars@metafoo.de \
    --cc=jic23@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.