From: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
To: Jorijn van der Graaf <jorijnvdgraaf@catcrafts.net>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
linux-iio@vger.kernel.org,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
devicetree@vger.kernel.org, "Kees Cook" <kees@kernel.org>,
"Gustavo A . R . Silva" <gustavoars@kernel.org>,
linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org,
"Luca Weiss" <luca.weiss@fairphone.com>
Subject: Re: [PATCH v2 5/5] iio: light: stk3310: support the Sensortek STK36C61
Date: Fri, 28 Aug 2026 01:18:18 -0300 [thread overview]
Message-ID: <apEMCqQXyj1tAMoP@debian-BULLSEYE-live-builder-AMD64> (raw)
In-Reply-To: <20260826175409.326131-6-jorijnvdgraaf@catcrafts.net>
Hello Jorijn, few questions inline.
On 08/26, Jorijn van der Graaf wrote:
> The Sensortek STK36C61 is a 3-in-1 ambient light / proximity / RGB
> colour sensor (chip ID 0x95) found in the Fairphone 6. Its register
> interface is compatible with the feature set this driver uses: the
> STATE/FLAG bit layout, the data and threshold registers and the gain
> and integration-time fields, verified on that device (the ALS and
> proximity readings scale with their gain and integration-time fields,
> thresholds written through the event interface read back from the
> chip, and the FLAG near/far bit crosses with them). Add its chip ID to
> the known-ID list and the device table entries.
>
...
>
> Assisted-by: Claude:claude-fable-5
> Signed-off-by: Jorijn van der Graaf <jorijnvdgraaf@catcrafts.net>
> ---
...
> @@ -417,10 +459,10 @@ static int stk3310_read_raw(struct iio_dev *indio_dev,
> mutex_unlock(&data->lock);
> return IIO_VAL_INT;
> case IIO_CHAN_INFO_INT_TIME:
> - if (chan->type == IIO_LIGHT)
> - ret = regmap_field_read(data->reg_als_it, &index);
> - else
> + if (chan->type == IIO_PROXIMITY)
> ret = regmap_field_read(data->reg_ps_it, &index);
> + else
> + ret = regmap_field_read(data->reg_als_it, &index);
The above seems unnecessary. Why changing the comparison from IIO_LIGHT to IIO_PROXIMITY?
After the proposed update we would have the integration time for both light and
intensity channels being read from the same register field?
> if (ret < 0)
> return ret;
>
> @@ -428,10 +470,12 @@ static int stk3310_read_raw(struct iio_dev *indio_dev,
> *val2 = stk3310_it_table[index][1];
> return IIO_VAL_INT_PLUS_MICRO;
> case IIO_CHAN_INFO_SCALE:
> - if (chan->type == IIO_LIGHT)
> - ret = regmap_field_read(data->reg_als_gain, &index);
> - else
> + if (chan->type == IIO_PROXIMITY)
> ret = regmap_field_read(data->reg_ps_gain, &index);
> + else if (chan->channel2 == IIO_MOD_LIGHT_CLEAR)
> + ret = regmap_field_read(data->reg_clear_gain, &index);
> + else
> + ret = regmap_field_read(data->reg_als_gain, &index);
Similar question here. What do we accomplish by comparing to proximity instead
of light? Is the gain info the same for light and intensity red/green/blue channels?
> if (ret < 0)
> return ret;
>
> @@ -451,7 +495,8 @@ static int stk3310_write_raw(struct iio_dev *indio_dev,
> int index;
> struct stk3310_data *data = iio_priv(indio_dev);
>
> - if (chan->type != IIO_LIGHT && chan->type != IIO_PROXIMITY)
> + if (chan->type != IIO_LIGHT && chan->type != IIO_PROXIMITY &&
> + chan->type != IIO_INTENSITY)
> return -EINVAL;
>
> switch (mask) {
> @@ -462,10 +507,10 @@ static int stk3310_write_raw(struct iio_dev *indio_dev,
> if (index < 0)
> return -EINVAL;
> mutex_lock(&data->lock);
> - if (chan->type == IIO_LIGHT)
> - ret = regmap_field_write(data->reg_als_it, index);
> - else
> + if (chan->type == IIO_PROXIMITY)
> ret = regmap_field_write(data->reg_ps_it, index);
> + else
> + ret = regmap_field_write(data->reg_als_it, index);
Same pattern, same questions.
> if (ret < 0)
> dev_err(&data->client->dev,
> "sensor configuration failed\n");
> @@ -479,10 +524,12 @@ static int stk3310_write_raw(struct iio_dev *indio_dev,
> if (index < 0)
> return -EINVAL;
> mutex_lock(&data->lock);
> - if (chan->type == IIO_LIGHT)
> - ret = regmap_field_write(data->reg_als_gain, index);
> - else
> + if (chan->type == IIO_PROXIMITY)
> ret = regmap_field_write(data->reg_ps_gain, index);
> + else if (chan->channel2 == IIO_MOD_LIGHT_CLEAR)
> + ret = regmap_field_write(data->reg_clear_gain, index);
> + else
> + ret = regmap_field_write(data->reg_als_gain, index);
And here.
> if (ret < 0)
> dev_err(&data->client->dev,
> "sensor configuration failed\n");
With best regards,
Marcelo
prev parent reply other threads:[~2026-08-28 4:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 17:54 [PATCH v2 0/5] iio: light: stk3310: per-chip match data and STK36C61 support Jorijn van der Graaf
2026-08-26 17:54 ` [PATCH v2 1/5] iio: light: stk3310: lower-case the i2c device ID names Jorijn van der Graaf
2026-08-26 18:03 ` sashiko-bot
2026-08-27 6:45 ` Andy Shevchenko
2026-08-26 17:54 ` [PATCH v2 2/5] dt-bindings: iio: light: stk33xx: document the Sensortek STK36C61 Jorijn van der Graaf
2026-08-26 17:54 ` [PATCH v2 3/5] iio: light: stk3310: move the data registers into the channel address Jorijn van der Graaf
2026-08-26 18:07 ` sashiko-bot
2026-08-27 6:47 ` Andy Shevchenko
2026-08-26 17:54 ` [PATCH v2 4/5] iio: light: stk3310: add per-chip match data Jorijn van der Graaf
2026-08-26 18:03 ` sashiko-bot
2026-08-27 7:47 ` Andy Shevchenko
2026-08-26 17:54 ` [PATCH v2 5/5] iio: light: stk3310: support the Sensortek STK36C61 Jorijn van der Graaf
2026-08-27 7:53 ` Andy Shevchenko
2026-08-28 4:18 ` Marcelo Schmitt [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=apEMCqQXyj1tAMoP@debian-BULLSEYE-live-builder-AMD64 \
--to=marcelo.schmitt1@gmail.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=gustavoars@kernel.org \
--cc=jic23@kernel.org \
--cc=jorijnvdgraaf@catcrafts.net \
--cc=kees@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luca.weiss@fairphone.com \
--cc=nuno.sa@analog.com \
--cc=robh@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