mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/5] iio: chemical: sgp40: add funtions for serial number readback, self-test, and heater control.
@ 2026-11-02  9:12 Jaakko Koivisto
  2026-11-02  9:12 ` [PATCH v2 1/5] iio: chemical: sgp40: Do not convert I2C errors to EIO Jaakko Koivisto
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Jaakko Koivisto @ 2026-11-02  9:12 UTC (permalink / raw)
  To: Andreas Klinger, Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko
  Cc: linux-iio, linux-kernel, Jaakko Koivisto

Add commands for getting the Sensirion SGP40 VOC-sensor
serial number, controlling the device's internal heater,
and running the device self-test.

Replace the manual mutex_lock()/mutex_unlock() with guard(mutex).
Simplifies the locking patterns, making it easier to add new mutex-guarded
variable 'heater_enabled' in patch 5.
Extends the lock to cover i2c communications with the device.

Fixes issue with converting all i2c errors to EIO in
sgp40_measure_resistance_raw(). Included in the patchset as it was found
due to reviewer flagging the same issue in the v1 patches.

Changes in v2:
- Added patch for replacing mutex_lock()/mutex_unlock() with guard().

- Added guard against concurrent access to the device in
  sgp40_get_serial_number(), sgp40_execute_self_test(),
  and sgp40_turn_heater_off().

- Return EIO if CRC check fails in sgp40_get_serial_number(),
  sgp40_execute_self_test(), sgp40_and turn_heater_off().

- Fixed formatting issues, missing newlines, unnecessary debug-print and
  unnecessary 0LL constant, added comments for sleep times.

- Changed 1 ms sleeps in sgp40_get_serial_number() and
  sgp40_turn_heater_off() to use fsleep instead of msleep
  (checkpatch.pl warning against using short msleep)

- Removed storing serial-number in driver-data, instead retrieve it when
  requested.

- Use the existing serialnumber ABI for presenting the SN to userspace.

- Fixed error paths in sgp40_turn_heater_off(). In v1 positive
  numbers were returned for errors. Fail the driver probe if the self-test
  fails to run, or the response is not PASS or FAIL.

- Use the existing heater_enable ABI for heater control.

- Return any negative errors from i2c_master_send() without
  converting them to -EIO in get_serial_number, execute_self_test,
  and turn_heater_off.

- Added patch for fixing the i2c error conversion issue in
  sgp40_measure_resistance_raw().

- Log errors with dev_err_probe() instead of dev_err().

- Link to v1: https://lore.kernel.org/linux-iio/20260918134019.1101308-1-jmatko@utu.fi/

Jaakko Koivisto (5):
  iio: chemical: sgp40: Do not convert I2C errors to EIO
  iio: chemical: sgp40: Replace manual locking with guard()
  iio: chemical: sgp40: Implement get_serial_number-command
  iio: chemical: sgp40: Implement execute_self_test-command
  iio: chemical: sgp40: Implement turn_heater_off-command

 drivers/iio/chemical/sgp40.c | 231 +++++++++++++++++++++++++++++++----
 1 file changed, 210 insertions(+), 21 deletions(-)

-- 
2.56.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-11-02 10:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-02  9:12 [PATCH v2 0/5] iio: chemical: sgp40: add funtions for serial number readback, self-test, and heater control Jaakko Koivisto
2026-11-02  9:12 ` [PATCH v2 1/5] iio: chemical: sgp40: Do not convert I2C errors to EIO Jaakko Koivisto
2026-11-02  9:54   ` Joshua Crofts
2026-11-02  9:12 ` [PATCH v2 2/5] iio: chemical: sgp40: Replace manual locking with guard() Jaakko Koivisto
2026-11-02 10:10   ` Joshua Crofts
2026-11-02  9:12 ` [PATCH v2 3/5] iio: chemical: sgp40: Implement get_serial_number-command Jaakko Koivisto
2026-11-02 10:20   ` Joshua Crofts
2026-11-02  9:12 ` [PATCH v2 4/5] iio: chemical: sgp40: Implement execute_self_test-command Jaakko Koivisto
2026-11-02 10:21   ` Joshua Crofts
2026-11-02  9:56 ` [PATCH v2 5/5] iio: chemical: sgp40: Implement turn_heater_off-command Jaakko Koivisto
2026-11-02 10:24   ` Joshua Crofts

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®