From: Jorijn van der Graaf <jorijnvdgraaf@catcrafts.net>
To: Jonathan Cameron <jic23@kernel.org>, linux-iio@vger.kernel.org
Cc: "David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Andy Shevchenko" <andriy.shevchenko@intel.com>,
"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>,
"Marcelo Schmitt" <marcelo.schmitt1@gmail.com>,
"Jorijn van der Graaf" <jorijnvdgraaf@catcrafts.net>
Subject: [PATCH v3 3/5] iio: light: stk3310: move the data registers into the channel address
Date: Tue, 1 Sep 2026 02:51:12 +0200 [thread overview]
Message-ID: <20260901005114.203062-4-jorijnvdgraaf@catcrafts.net> (raw)
In-Reply-To: <20260901005114.203062-1-jorijnvdgraaf@catcrafts.net>
The RAW read selects its data register with a per-channel-type branch.
Record each channel's data register in its .address field and read
from there, so adding a channel does not grow the branch.
Suggested-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Assisted-by: Claude:claude-fable-5
Signed-off-by: Jorijn van der Graaf <jorijnvdgraaf@catcrafts.net>
---
drivers/iio/light/stk3310.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c
index 5b5b6812edc7..156888969366 100644
--- a/drivers/iio/light/stk3310.c
+++ b/drivers/iio/light/stk3310.c
@@ -184,6 +184,7 @@ static const struct iio_chan_spec_ext_info stk3310_ext_info[] = {
static const struct iio_chan_spec stk3310_channels[] = {
{
.type = IIO_LIGHT,
+ .address = STK3310_REG_ALS_DATA_MSB,
.info_mask_separate =
BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_SCALE) |
@@ -191,6 +192,7 @@ static const struct iio_chan_spec stk3310_channels[] = {
},
{
.type = IIO_PROXIMITY,
+ .address = STK3310_REG_PS_DATA_MSB,
.info_mask_separate =
BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_SCALE) |
@@ -370,25 +372,20 @@ static int stk3310_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
{
- u8 reg;
__be16 buf;
int ret;
unsigned int index;
struct stk3310_data *data = iio_priv(indio_dev);
struct i2c_client *client = data->client;
+ struct regmap *map = data->regmap;
if (chan->type != IIO_LIGHT && chan->type != IIO_PROXIMITY)
return -EINVAL;
switch (mask) {
case IIO_CHAN_INFO_RAW:
- if (chan->type == IIO_LIGHT)
- reg = STK3310_REG_ALS_DATA_MSB;
- else
- reg = STK3310_REG_PS_DATA_MSB;
-
mutex_lock(&data->lock);
- ret = regmap_bulk_read(data->regmap, reg, &buf, sizeof(buf));
+ ret = regmap_bulk_read(map, chan->address, &buf, sizeof(buf));
if (ret < 0) {
dev_err(&client->dev, "register read failed\n");
mutex_unlock(&data->lock);
--
2.55.0
next prev parent reply other threads:[~2026-09-01 0:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 0:51 [PATCH v3 0/5] iio: light: stk3310: per-chip match data and STK36C61 support Jorijn van der Graaf
2026-09-01 0:51 ` [PATCH v3 1/5] iio: light: stk3310: lower-case the i2c device ID names Jorijn van der Graaf
2026-09-01 0:51 ` [PATCH v3 2/5] dt-bindings: iio: light: stk33xx: document the Sensortek STK36C61 Jorijn van der Graaf
2026-09-01 0:51 ` Jorijn van der Graaf [this message]
2026-09-01 0:51 ` [PATCH v3 4/5] iio: light: stk3310: add per-chip match data Jorijn van der Graaf
2026-09-01 0:51 ` [PATCH v3 5/5] iio: light: stk3310: support the Sensortek STK36C61 Jorijn van der Graaf
2026-09-01 1:04 ` sashiko-bot
2026-09-05 0:50 ` Jonathan Cameron
2026-09-05 0:51 ` [PATCH v3 0/5] iio: light: stk3310: per-chip match data and STK36C61 support 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=20260901005114.203062-4-jorijnvdgraaf@catcrafts.net \
--to=jorijnvdgraaf@catcrafts.net \
--cc=andriy.shevchenko@intel.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=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=marcelo.schmitt1@gmail.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