From: Jan Remes <ciakval@gmail.com>
To: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Joe Sandom" <joe.g.sandom@gmail.com>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Jan Remes <jan.remes@mycroftmind.com>,
Jonathan Cameron <jic23@kernel.org>,
stable@vger.kernel.org,
Martin Triska <martin.triska@mycroftmind.com>,
Andy Shevchenko <andriy.shevchenko@intel.com>
Subject: [PATCH v3 0/4] iio: light: tsl2591: fix lux calculation and precision, add I2C ID table, report saturation
Date: Thu, 22 Oct 2026 13:53:56 +0200 [thread overview]
Message-ID: <20261022-first-patch-v3-0-b792e89a429a@mycroftmind.com> (raw)
This series fixes several issues found while using the TSL2591 in
company products (Raspberry Pi CM5) and when testing (x86_64 laptops
with MCP2221 USB-I2C bridge).
The original field report found that the illumination value has always
been 0.0 (caused by division by zero on ARM).
Patch 1 fixes divisions by zero in the lux calculation, which occur with
LOW gain and short integration times, or in darkness when CH0 = 0.
Patch 2 adds an i2c_device_id table so the driver can be matched by name
(e.g. via sysfs new_device) on kernels without CONFIG_OF.
Patch 3 makes the driver return an error instead of a bogus value when the
sensor is saturated.
Patch 4 improves the formula for calculating lux values to make the
returned value more accurate.
Patches 3 and 4 change existing behavior, I am OK with splitting the
series into two, if that makes things better.
AI assistance: Claude Code (Claude Opus 5.5) was used for research on
sensor behavior, datasheets and Adafruit library, to compare results
produced by old and new formula, to draft some code for patches 1 and 4.
I reviewed all of it and tested it on x86_64.
Changes in v3:
- Patch 2: Fix commit message, OF-only drivers can still be enumerated via
DT or ACPI (PRP0001), only matching by name needs the I2C ID table (Andy)
- Patch 2: Drop Andy's Reviewed-by
- Rebase on current iio/testing
- Link to v2: https://patch.msgid.link/20261014141650.259929-1-ciakval@gmail.com
Changes in v2 (thanks to Andy Shevchenko for review):
- Patch 2: Use C99 initializers
- Patch 4: Keep variables in reversed xmas tree order
- Link to v1: https://lore.kernel.org/r/20261013143943.436816-1-ciakval@gmail.com/
Signed-off-by: Jan Remes <jan.remes@mycroftmind.com>
---
Jan Remes (4):
iio: light: tsl2591: don't divide by zero
iio: light: tsl2591: add I2C device ID table
iio: light: tsl2591: report saturation
iio: light: tsl2591: improve lux calculation precision
drivers/iio/light/tsl2591.c | 58 ++++++++++++++++++++++++++++++++-------------
1 file changed, 42 insertions(+), 16 deletions(-)
---
base-commit: 87e28db23d0384f3995c43ecc5ae2118b371edb5
change-id: 20261014-first-patch-23099c6002da
Best regards,
--
Jan Remes <jan.remes@mycroftmind.com>
next reply other threads:[~2026-10-22 11:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 11:53 Jan Remes [this message]
2026-10-22 11:53 ` [PATCH v3 1/4] iio: light: tsl2591: don't divide by zero Jan Remes
2026-10-22 11:53 ` [PATCH v3 2/4] iio: light: tsl2591: add I2C device ID table Jan Remes
2026-10-22 11:53 ` [PATCH v3 3/4] iio: light: tsl2591: report saturation Jan Remes
2026-10-22 11:54 ` [PATCH v3 4/4] iio: light: tsl2591: improve lux calculation precision Jan Remes
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=20261022-first-patch-v3-0-b792e89a429a@mycroftmind.com \
--to=ciakval@gmail.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jan.remes@mycroftmind.com \
--cc=jic23@kernel.org \
--cc=joe.g.sandom@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.triska@mycroftmind.com \
--cc=nuno.sa@analog.com \
--cc=stable@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
all inboxes | Powered by JetHome®