[PATCH v3 0/2] iio: light: adux1020: guard() conversion and follow-up cleanup

From: Raffaele Tranfaglia via B4 Relay

Date: Wed Nov 18 2026 - 02:30:09 EST


Patch 1 converts the driver to guard(mutex), as Jonathan suggested
when applying the sampling frequency hardening patch. Patch 2 uses the
direct returns this allows to flatten the channel type checks in
adux1020_read_raw() and adux1020_write_raw().

Tested on arm64 QEMU with i2c-stub and lockdep enabled: reading and
writing the sampling frequency (valid and invalid values), reading the
LED current, reading in_proximity_raw and enabling the threshold
event. No lockdep warnings and no hangs after the error paths.

I prepared these patches with the help of an AI coding assistant, and
reviewed and tested them myself.

Signed-off-by: Raffaele Tranfaglia <raffaele.tranfaglia@xxxxxxxxx>
---
Changes in v3:
- Patch 2: add a local regmap pointer in adux1020_read_raw() and
adux1020_write_raw(), and use 'if (ret)' for regmap_read() errors
(Andy)
- Patch 2: split the adux1020_find_index() arguments logically (Andy)
- Link to v2: https://patch.msgid.link/20261117-adux1020-guard-v2-0-89707fa070c9@xxxxxxxxx

Changes in v2:
- Drop the unreferenced Link tag (Andy)
- Move ret to the end of the declarations in adux1020_read_raw() (Andy)
- New patch 2: return early on unsupported channel types instead of
nesting (Jonathan)
- Link to v1: https://patch.msgid.link/20261108-adux1020-guard-v1-1-db9c582f1eea@xxxxxxxxx

---
Raffaele Tranfaglia (2):
iio: light: adux1020: use guard() to simplify lock handling
iio: light: adux1020: return early on unsupported channel types

drivers/iio/light/adux1020.c | 189 ++++++++++++++++++-------------------------
1 file changed, 77 insertions(+), 112 deletions(-)
---
base-commit: d922ed738439e1d5b4701df7f4cdd49a09925624
change-id: 20261108-adux1020-guard-3820ce794843

Best regards,
--
Raffaele Tranfaglia <raffaele.tranfaglia@xxxxxxxxx>