From: Jonathan Cameron <jic23@kernel.org>
To: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: light: veml6030: add support for triggered buffer
Date: Sat, 9 Nov 2024 15:14:59 +0000 [thread overview]
Message-ID: <20241109151459.57abf2dc@jic23-huawei> (raw)
In-Reply-To: <8c9b1e43-f47e-46a5-9189-fbe73b16ff7b@gmail.com>
On Sat, 9 Nov 2024 15:32:45 +0100
Javier Carrasco <javier.carrasco.cruz@gmail.com> wrote:
> Hi Jonathan, thanks for your feedback.
>
> On 09/11/2024 14:27, Jonathan Cameron wrote:
> > On Thu, 07 Nov 2024 21:22:45 +0100
> > Javier Carrasco <javier.carrasco.cruz@gmail.com> wrote:
> >
> >> All devices supported by this driver (currently veml6030, veml6035
> >> and veml7700) have two 16-bit channels, and can profit for the same
> >> configuration to support data access via triggered buffers.
> >>
> >> The measurements are stored in two 16-bit consecutive registers
> >> (addresses 0x04 and 0x05) as little endian, unsigned data.
> >>
> >> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
> > Hi Javier,
> >
> > Some comments inline below.
> >
> > Thanks,
> >
> > Jonathan
> >
> >> ---
> >> drivers/iio/light/Kconfig | 2 ++
> >> drivers/iio/light/veml6030.c | 84 ++++++++++++++++++++++++++++++++++++++++++++
> >> 2 files changed, 86 insertions(+)
> >>
>
> ...
>
> >> +static irqreturn_t veml6030_trigger_handler(int irq, void *p)
> >> +{
> >> + struct iio_poll_func *pf = p;
> >> + struct iio_dev *iio = pf->indio_dev;
> >> + struct veml6030_data *data = iio_priv(iio);
> >> + int i, ret, reg;
> >> + int j = 0;
> >> +
> >> + iio_for_each_active_channel(iio, i) {
> > Given you've set the available_scan_masks such that all channels are on
> > or off, you should be able to read them unconditionally.
> > The IIO core demux code will break them up if the user requested a subset.
> >
>
> What I wanted to model is that both channels (ALS and WH) should be
> accessible, but allowing the user to request a single one, as the ALS
> channel is usually more relevant. It seems that in that case I should
> leave available_scan_masks as it is, right? I don't want to keep any
> channel from being accessible.
Ah. No that's not what it is for. If you don't set it at all, any
combination of channels may be enabled. If you set it you are restricting
the choice of what is enabled to particular combinations. In the simple
case this is used when you want to enforce (at the driver level) that
'all' channels are always captured - usually because there is an efficient
bulk channel read.
The IIO core will then pull out the data for the channels the user actually
requested.
In a case where the reads are independent just don't provide available_scan_masks
at all. That matches providing 0x3, 0x2, 0x1, 0x0 here So any combination of
channels.
>
> > If it makes sense to allow individual channels (looks like it here)
> > then don't provide available_scan_masks.
> >
> > A bulk read may make sense (I've not checked register values).
> >
>
> In my interpretation, I thought that I could read a single register if
> there is only a single active channel, instead of using regmap_read_bulk
> unconditionally. the data registers have consecutive addresses, and a
> bulk read is possible, though.
>
> What approach is preferred in this case? Reading and pushing both
> channels at once without any loop, letting the IIO core demux do the
> rest, or reading only the active channels as it is done here?
It depends a bit on the device. People tend not to want one axis of an
accelerometer, but here a single channel is a likely case to optimize
for, so just don't provide available_scan_masks and it will all work I think.
If it's is a significant saving you can always figure out if a bulk
read makes sense in your driver and do it if both channels are enabled.
Probably not worth the complexity here.
Jonathan
>
> >> + ret = regmap_read(data->regmap, VEML6030_REG_DATA(i), ®);
> >> + if (ret)
> >> + goto done;
> >> +
> >> + data->scan.chans[j++] = reg;
> >> + }
> >> +
> >> + iio_push_to_buffers_with_timestamp(iio, &data->scan, pf->timestamp);
> >> +
> >> +done:
> >> + iio_trigger_notify_done(iio->trig);
> >> +
> >> + return IRQ_HANDLED;
> >> +}
>
> Thanks again and best regards,
> Javier Carrasco
>
prev parent reply other threads:[~2024-11-09 15:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 20:22 [PATCH] iio: light: veml6030: add support for triggered buffer Javier Carrasco
2024-11-08 9:41 ` kernel test robot
2024-11-08 10:33 ` Javier Carrasco
2024-11-09 13:21 ` Jonathan Cameron
2024-11-09 13:27 ` Jonathan Cameron
2024-11-09 14:32 ` Javier Carrasco
2024-11-09 15:14 ` Jonathan Cameron [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=20241109151459.57abf2dc@jic23-huawei \
--to=jic23@kernel.org \
--cc=javier.carrasco.cruz@gmail.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@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