From: Jonathan Cameron <jic23@kernel.org>
To: Matti Vaittinen <mazziesaccount@gmail.com>
Cc: Jonathan Cameron <Jonathan.Cameron@Huawei.com>,
Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Angel Iglesias <ang.iglesiasg@gmail.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Andreas Klinger <ak@it-klinger.de>,
Benjamin Bara <bbara93@gmail.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] iio: pressure: Support ROHM BU1390
Date: Sun, 24 Sep 2023 13:14:54 +0100 [thread overview]
Message-ID: <20230924131454.7cae02a9@jic23-huawei> (raw)
In-Reply-To: <9d929df3-ac51-7d1f-ec00-856849cc70c7@gmail.com>
On Thu, 21 Sep 2023 12:00:39 +0300
Matti Vaittinen <mazziesaccount@gmail.com> wrote:
> On 9/21/23 11:17, Matti Vaittinen wrote:
>
> > Another thing to note is that, when we build the available_scan_mask
> > array - we should either pay attention to the order of masks - or change
> > the iio_scan_mask_match() to not accept first matching subset but to go
> > through all of the masks unless it finds and exactly matching one (and
> > in general prefer the smallest subset). Not sure this is worth the extra
> > cycles though.
>
> Replying to myself and to those who I perhaps managed to confuse :)
>
> As a result of above pondering I wrote this:
>
> @@ -411,6 +418,8 @@ static const unsigned long
> *iio_scan_mask_match(const unsigned long *av_masks,
> const unsigned long *mask,
> bool strict)
> {
> + const unsigned long *smallest = NULL;
> +
> if (bitmap_empty(mask, masklength))
> return NULL;
> while (*av_masks) {
> @@ -418,12 +427,16 @@ static const unsigned long
> *iio_scan_mask_match(const unsigned long *av_masks,
> if (bitmap_equal(mask, av_masks, masklength))
> return av_masks;
> } else {
> - if (bitmap_subset(mask, av_masks, masklength))
> - return av_masks;
> + if (bitmap_subset(mask, av_masks, masklength)) {
> + if (!smallest ||
> + bitmap_weight(av_masks, BITS_PER_LONG) <
> + bitmap_weight(smallest, BITS_PER_LONG))
> + smallest = av_masks;
> + }
> }
> av_masks += BITS_TO_LONGS(masklength);
> }
> - return NULL;
> + return smallest;
> }
>
> but ...
> ... I see a problem that some of the channels may be more costly to
> access than the other. It could be that reading some of the channels is
> just a matter of getting a cached value, while other could require a
> long measurement time and access to significant amount of registers. So,
> the knowledge of preferred scan masks should indeed be on the driver
> side. Hence, the ordering of the masks in the order of preference makes
> perfect sense. What we could do in the IIO core side is still go through
> all of the available masks to see if we find an exact match. I guess we
> could also document the fact that the order of masks matters.
I should have read on in the thread. Indeed - ordering of preferences needs
to be in driver control for exactly the reason you came up with!
Thanks,
Jonathan
>
> Thanks for listening - and sorry for the noise :)
>
> Yours,
> -- Matti
>
next prev parent reply other threads:[~2023-09-24 12:15 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-15 6:55 [PATCH v2 0/3] Support ROHM BM1390 pressure sensor Matti Vaittinen
2023-09-15 6:55 ` [PATCH v2 1/3] dt-bindings: Add " Matti Vaittinen
2023-09-15 6:56 ` [PATCH v2 2/3] iio: pressure: Support ROHM BU1390 Matti Vaittinen
2023-09-16 8:01 ` Christophe JAILLET
2023-09-17 9:56 ` Jonathan Cameron
2023-09-18 11:39 ` Matti Vaittinen
2023-09-19 14:32 ` Jonathan Cameron
2023-09-22 6:07 ` Matti Vaittinen
2023-09-17 10:35 ` Jonathan Cameron
2023-09-18 12:56 ` Matti Vaittinen
2023-09-19 11:28 ` Matti Vaittinen
2023-09-19 14:53 ` Jonathan Cameron
2023-09-21 8:17 ` Matti Vaittinen
2023-09-21 9:00 ` Matti Vaittinen
2023-09-24 12:14 ` Jonathan Cameron [this message]
2023-09-24 12:12 ` Jonathan Cameron
2023-09-19 14:45 ` Jonathan Cameron
2023-09-15 6:56 ` [PATCH v2 3/3] MAINTAINERS: Add ROHM BM1390 Matti Vaittinen
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=20230924131454.7cae02a9@jic23-huawei \
--to=jic23@kernel.org \
--cc=Jonathan.Cameron@Huawei.com \
--cc=ak@it-klinger.de \
--cc=andriy.shevchenko@linux.intel.com \
--cc=ang.iglesiasg@gmail.com \
--cc=bbara93@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matti.vaittinen@fi.rohmeurope.com \
--cc=mazziesaccount@gmail.com \
--cc=robh+dt@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).