From: Nikhil Gautam <nikhilgtr@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@intel.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 v4] iio: chemical: ccs811: Make sampling frequency configurable
Date: Tue, 3 Nov 2026 17:42:11 +0530 [thread overview]
Message-ID: <110601ff-f60d-407f-bfba-05a13c14d490@gmail.com> (raw)
In-Reply-To: <aunD9kPZ03d8s8AI@ashevche-desk.local>
On 03-11-2026 04:52 pm, Andy Shevchenko wrote:
> On Sun, Nov 01, 2026 at 11:10:19AM +0530, Nikhil Gautam wrote:
Hi Andy,
Thanks for the quick review.
>> +static const int ccs811_samp_freq[][2] = {
>> + { 1, 0 },
>> + { 0, 100000 },
>> + { 0, 16667 },
>> +};
> Now it would be better to have a common enum to index above and below.
> So it will be kept in sync
>
> enum {
> CCS811_MODE_IAQ_1SEC_IDX,
> CCS811_MODE_IAQ_10SEC_IDX,
> CCS811_MODE_IAQ_60SEC_IDX,
> };
>
> static const int ccs811_samp_freq[][2] = {
> [CCS811_MODE_IAQ_1SEC_IDX] = { 1, 0 },
> ...
> };
>
>> +/* Drive mode for each entry of ccs811_samp_freq[], same order */
>> +static const u8 ccs811_drive_mode[] = {
>> + CCS811_MODE_IAQ_1SEC,
>> + CCS811_MODE_IAQ_10SEC,
>> + CCS811_MODE_IAQ_60SEC,
>> +};
> ...and here in similar way.
>
> ...
Agreed, a shared index enum is cleaner than relying on "same order".
Will add it and use designated initializers in both tables.
>> +static int ccs811_update_sampling_freq(struct ccs811_data *data,
>> + int val, int val2)
>> +{
>> + u8 drive_mode;
>> + u8 mode;
>> + int i, ret;
> Why is 'i' signed? Also keep reversed xmas tree order.
No good reason, Will make it unsigned int and fix the declaration order.
>
> With
>
> struct i2c_client *client = data->client;
>
>> + ret = i2c_smbus_read_byte_data(data->client, CCS811_MEAS_MODE);
> ret = i2c_smbus_read_byte_data(client, CCS811_MEAS_MODE);
>
>> + if (ret < 0)
>> + return ret;
>> +
>> + mode = (ret & ~CCS811_MODE_MASK) | drive_mode;
>> + ret = i2c_smbus_write_byte_data(data->client, CCS811_MEAS_MODE,
>> + mode);
> ret = i2c_smbus_write_byte_data(client, CCS811_MEAS_MODE, mode);
Ack, will add the local client pointer and use it in both calls.
>> +static int ccs811_get_sampling_freq(struct ccs811_data *data,
>> + int *val, int *val2)
>> +{
>> + int i;
>> +
>> + guard(mutex)(&data->lock);
>> + for (i = 0; i < ARRAY_SIZE(ccs811_drive_mode); i++) {
> for (unsigned int i = 0; i < ARRAY_SIZE(ccs811_drive_mode); i++) {
Ack, will use a loop-scoped unsigned int.
>> +static int ccs811_write_raw(struct iio_dev *indio_dev,
>> + struct iio_chan_spec const *chan,
>> + int val, int val2, long mask)
>> +{
>> + struct ccs811_data *data = iio_priv(indio_dev);
>> + int ret;
> Why? I don't see any followup, without which this variable is redundant.
Leftover from the earlier claim/release version.
Will drop it and return ccs811_set_sampling_freq() directly.
Will update comments on next version.
Regards,
Nikhil
prev parent reply other threads:[~2026-11-03 12:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-01 5:40 Nikhil Gautam
2026-11-03 11:22 ` Andy Shevchenko
2026-11-03 12:12 ` Nikhil Gautam [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=110601ff-f60d-407f-bfba-05a13c14d490@gmail.com \
--to=nikhilgtr@gmail.com \
--cc=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=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®