From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Nikhil Gautam <nikhilgtr@gmail.com>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
jic23@kernel.org, dlechner@baylibre.com, nuno.sa@analog.com,
andy@kernel.org
Subject: Re: [PATCH v3] iio: chemical: ccs811: Make sampling frequency configurable
Date: Sun, 25 Oct 2026 22:57:45 +0200 [thread overview]
Message-ID: <at5tSSk_Hr5MzOZ8@ashevche-desk.local> (raw)
In-Reply-To: <20261025173545.6892-1-nikhilgtr@gmail.com>
On Sun, Oct 25, 2026 at 11:05:45PM +0530, Nikhil Gautam wrote:
> Allow userspace to configure the CCS811 IAQ measurement rate through
> the IIO sampling_frequency attribute.
>
> Support the three IAQ measurement modes with sampling frequencies of
> 1 Hz, 0.1 Hz, and approximately 0.016667 Hz, corresponding to
> measurement intervals of 1, 10, and 60 seconds.
>
> Preserve unrelated bits in the MEAS_MODE register when updating the
> drive mode, and cache the selected mode after a successful register
> write. Expose the supported frequencies through
> sampling_frequency_available.
>
> Signed-off-by: Nikhil Gautam <nikhilgtr@gmail.com>
The cutter is missing here, we don't want to see changelog in the commit
messages and moreover this contribution is not strictly signed-off, as the tag
block is the last in the commit message. This is a show-stopper to take
the patch, even if it's desired and correct.
>
> Changes in v3:
> - Reuse the sampling frequency array instead of duplicating frequency values.
> - Separate register updates from locking and wakeup handling.
> - Use a separate variable for the updated MEAS_MODE register value.
> - Simplify the sampling frequency getter.
> - Mark the completed drive-mode configuration TODO as done.
>
> Changes in v2:
> - Fix the Clang build error caused by guard() in the switch statement.
> ---
...
> +static const int ccs811_samp_freq[] = {
> + 1, 0,
> + 0, 100000,
> + 0, 16667,
> +};
Make it double dimension array instead. Each index can be named as
CCS811_MODE_IAQ_1SEC and so on, while the shift is applied later on.
With the above being done, the code can use either a for-loop or
simple indexing.
*Yes, I see that the value(s) can be used directly in the code, but try to
explore an approach that can improve robustness and readability of the code.
...
> +{
> + struct ccs811_data *data = iio_priv(indio_dev);
> + int ret;
> +
> + switch (mask) {
> + case IIO_CHAN_INFO_SAMP_FREQ:
> + if (!iio_device_claim_direct(indio_dev))
> + return -EBUSY;
Can we use IIO_DEV_ACQUIRE_DIRECT_MODE() here?
> + ret = ccs811_set_sampling_freq(data, val, val2);
> +
> + iio_device_release_direct(indio_dev);
> + return ret;
> +
> + default:
> + return -EINVAL;
> + }
> +}
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-10-25 20:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-25 17:35 Nikhil Gautam
2026-10-25 20:57 ` Andy Shevchenko [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=at5tSSk_Hr5MzOZ8@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nikhilgtr@gmail.com \
--cc=nuno.sa@analog.com \
/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
all inboxes | Powered by JetHome®