Skip to content

iio: light: tsl2591: fix lux calculation and precision, add I2C ID table, report saturation

Jan Remes linux-iio lkml stable 4 versions – Applied

Status from this message: Applied to the fixes-togreg branch of iio.git

Get series with b4
b4 am [email protected] change-id 20261014-first-patch-23099c6002da

Versions newest first

  1. v4 Latest4 patches 2 repliesApplied
  2. v34 patches 2 repliesSuperseded inferred link
  3. v24 patches 9 repliesSuperseded inferred link
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v14 patches4 repliesSuperseded

Changes in v4 from the cover letter

- no changes in the code
- drop "Assisted-by: LLM" tags (Andy)
- Patch 2: make commit message more to the point (Andy)
- Link to v3: https://patch.msgid.link/[email protected]

Patches in v4 Applied

#Subject and filesSizeRepliesApplied
1/4iio: light: tsl2591: don't divide by zerodrivers/iio/light/tsl2591.c+22 -101 reply
2/4iio: light: tsl2591: add I2C device ID tabledrivers/iio/light/tsl2591.c+7 -01 reply
3/4iio: light: tsl2591: report saturationdrivers/iio/light/tsl2591.c+11 -10 replies
4/4iio: light: tsl2591: improve lux calculation precisiondrivers/iio/light/tsl2591.c+12 -150 replies

Reviews trailers per patch

3 of 4 patches have a Reviewed-by or Acked-by.

PatchAndy Shevchenko
1/4R-b
2/4
3/4R-b
4/4R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/4] iio: light: tsl2591: fix lux calculation and precision, add I2C ID table, report saturation

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 v4:
- no changes in the code
- drop "Assisted-by: LLM" tags (Andy)
- Patch 2: make commit message more to the point (Andy)
- Link to v3: https://patch.msgid.link/[email protected]

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/[email protected]

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/[email protected]/

To: Jonathan Cameron <[email protected]>
To: David Lechner <[email protected]>
To: Nuno Sá <[email protected]>
To: Andy Shevchenko <[email protected]>
To: Joe Sandom <[email protected]>

---
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,

Signature · 1 line
Jan Remes <[email protected]>