From: Jonathan Cameron <jic23@kernel.org>
To: Abhash jha <abhashkumarjha123@gmail.com>
Cc: anshulusr@gmail.com, linux-iio@vger.kernel.org, lars@metafoo.de,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: light: ltr390: Add configurable gain, resolution and ALS reading
Date: Sat, 27 Jul 2024 13:27:35 +0100 [thread overview]
Message-ID: <20240727132735.052502ad@jic23-huawei> (raw)
In-Reply-To: <CAG=0RqL1GxCKdzDzUjqECEsfQmunCwnv+g_5cqM1fcfBsg+P0w@mail.gmail.com>
Please crop replies to only leave the section being discussed.
It saves time for everyone reading the thread.
> > > -static const struct iio_info ltr390_info = {
> > > - .read_raw = ltr390_read_raw,
> > > +/* integration time in us */
> > > +static const int ltr390_int_time_map_us[] = {400000, 200000, 100000, 50000, 25000, 12500};
> > > +static const int ltr390_gain_map[] = {1, 3, 6, 9, 18};
> > > +
> > > +static IIO_CONST_ATTR_INT_TIME_AVAIL("400000 200000 100000 50000 25000 12500");
> > Please use read_avail() callback and the appropriate mask to provide this.
> > That enables it to be used from in kernel consumers and enforces the
> > ABI without a reviewer having to check what you have aligns.
> >
> > > +static IIO_CONST_ATTR(gain_available, "1 3 6 9 18");
> > Given we don't have a 'gain' control, what is the available applying to?
> >
> The gain gets controlled by writing to the iio_info_scale attribute,
> we write one of the above available values.
> So that we can scale the raw ALS and UVI values. I could use
> read_avail() for this too for the IIO_INFO_SCALE channel. Should I do
> that?
Yes, it would be appropriate to provide read_avail for IIO_INFO_SCALE
as that is standard ABI that userspace will have way to interpret.
> Can you elaborate more on your comment?
Basic rule of thumb is think very hard about whether there is an alternative
if you are providing attributes directly to an IIO driver.
There are a few corners where that is necessary for standard ABI
around FIFOs or certain event related attributes + a few special
corners for complex hardwware.
None of those apply here, so read_avail callback and choosing standard
ABI elements to match what you are trying to control / describe is the
way to go. That's the stuff that userspace tooling knows how to use.
Jonathan
next prev parent reply other threads:[~2024-07-27 12:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-18 10:49 [PATCH] iio: light: ltr390: Add configurable gain, resolution and ALS reading Abhash Jha
2024-07-20 15:55 ` Jonathan Cameron
2024-07-26 12:55 ` Abhash jha
2024-07-27 12:27 ` Jonathan Cameron [this message]
2024-07-28 15:19 ` [PATCH v2 1/3] iio: light: ltr390: Add configurable gain and resolution Abhash Jha
2024-07-28 15:19 ` [PATCH v2 2/3] iio: light: ltr390: Add ALS channel and support for " Abhash Jha
2024-07-28 16:58 ` Jonathan Cameron
2024-07-28 15:19 ` [PATCH v2 3/3] iio: light: ltr390: Calculate 'counts_per_uvi' dynamically Abhash Jha
2024-07-28 17:03 ` Jonathan Cameron
2024-07-28 17:03 ` [PATCH v2 1/3] iio: light: ltr390: Add configurable gain and resolution 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=20240727132735.052502ad@jic23-huawei \
--to=jic23@kernel.org \
--cc=abhashkumarjha123@gmail.com \
--cc=anshulusr@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