[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230501161543.25156692@jic23-huawei>
Date: Mon, 1 May 2023 16:15:43 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Herve Codina <herve.codina@...tlin.com>
Cc: Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Lars-Peter Clausen <lars@...afoo.de>,
Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>, alsa-devel@...a-project.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-iio@...r.kernel.org,
Christophe Leroy <christophe.leroy@...roup.eu>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>
Subject: Re: [PATCH 2/4] iio: inkern: Add a helper to query an available
minimum raw value
> > > diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
> > > index 6802596b017c..956120d8b5a3 100644
> > > --- a/include/linux/iio/consumer.h
> > > +++ b/include/linux/iio/consumer.h
> > > @@ -297,6 +297,17 @@ int iio_write_channel_raw(struct iio_channel *chan, int val);
> > > */
> > > int iio_read_max_channel_raw(struct iio_channel *chan, int *val);
> > >
> > > +/**
> > > + * iio_read_min_channel_raw() - read minimum available raw value from a given
> > > + * channel, i.e. the minimum possible value.
> > > + * @chan: The channel being queried.
> > > + * @val: Value read back.
> > > + *
> > > + * Note raw reads from iio channels are in adc counts and hence
> > > + * scale will need to be applied if standard units are required.
> >
> > Hmm. That comment is almost always true, but not quite. Not related to
> > your patch but some cleanup of this documentation and pushing it down next
> > to implementations should be done at some point. If anyone is really
> > bored and wants to take this on that's fine. If not, another one for the
> > todo list ;)
>
> If you are ok, I can change every where in consumer.h the following:
> * Note raw reads from iio channels are in adc counts and hence
> * scale will need to be applied if standard units required.
> by
> * Note raw reads from iio channels are not in standards units and
> * hence scale will need to be applied if standard units required.
If going to the effort, we should include offset and make it clear how
they are applied.
* Note, if standard units are required, raw reads from iio channels
* need the offset (default 0) and scale (default 1) to be applied
* as (raw + offset) * scale.
>
> Also the same for raw writes:
> * Note raw writes to iio channels are in dac counts and hence
> * scale will need to be applied if standard units required.
> by
> * Note raw writes to iio channels are not in standards units and
> * hence scale will need to be applied if standard units required.
This one is more interesting because you kind of need to apply the opposite
logic. Perhaps text such as.
* Note that for raw writes to iio channels, if the value provided is
* in standard units, the affect of the scale and offset must be removed
* as (value / scale) - offset.
My slight concern is that we'll spend longer arguing about these comments
than we spend on the rest of the patch set. Might be worth delaying
fixing the others for a separate series after this one.
Jonathan
>
> >
> > > + */
> > > +int iio_read_min_channel_raw(struct iio_channel *chan, int *val);
> > > +
> > > /**
> > > * iio_read_avail_channel_raw() - read available raw values from a given channel
> > > * @chan: The channel being queried.
> >
>
> Thanks for the review,
> Hervé
>
Powered by blists - more mailing lists