Skip to contentSkip to conversation

iio: temperature: Add support for the STS30 temperature sensor

PATCH In review Maxwell Doose 6 participants 18 messages Jun 21 – Jul 6

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover iio: temperature: Add support for the STS30 temperature sensor

Hi all,

This patch series adds support for the Sensirion STS30 temperature sensor family. This driver currently supports non clock stretched single shot measurements.

Given there were very little issues found with the v1 submission, I've decided to make this a regular patch series rather than an RFC patch.

Changes since v1:
* whole series:
- Squashed MAINTAINERS updates into both the dt-bindings commit and the driver commit.

* dt-bindings:
- Added ALERT pin as an interrupt and in the examples.

* driver:
- Fixed a mixup between the clock-stretched and non-clock stretched commands.
- Fixed an issue where the return value of sts30_reset() was ignored.
- Removed redundant "Author" line at the top.
- Added comment at the top for the formula used to calculate the temperature in Celsius alongside a macro.
- Added a dedicated macro for the temperature reading size.
- Separated the generic linux headers from the iio specific headers.
- Removed kernel.h from includes.
- Removed unneeded comments.
- Used named initializers for sts30_id and moved above _probe().

Maxwell Doose (2):
dt-bindings: iio: temperature: Add STS30 devicetree bindings
iio: temperature: Add STS30 temperature sensor driver

 .../iio/temperature/sensirion,sts30.yaml      |  55 +++
 MAINTAINERS                                   |   6 +
 drivers/iio/temperature/Kconfig               |  11 +
 drivers/iio/temperature/Makefile              |   1 +
 drivers/iio/temperature/sts30.c               | 329 ++++++++++++++++++
 5 files changed, 402 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/temperature/sensirion,sts30.yaml
 create mode 100644 drivers/iio/temperature/sts30.c
Signature · 1 line
2.54.0
#1 lore raw

PATCH v2 1/2 dt-bindings: iio: temperature: Add STS30 devicetree bindings

Add the devicetree bindings for the STS30 family of temperature sensors. The STS30 family of sensors includes the STS30, STS31, and STS35.

All devices in the STS30 family share the same commands, timings, etc. The only difference between them is their measurement accuracy and tolerance.

Additionally add MAINTAINERS entry for the driver.

---
Changes since v1:
- Squashed parts of the MAINTAINERS commit into this commit.
- Added ALERT pin as an interrupt and in the examples.

 .../iio/temperature/sensirion,sts30.yaml      | 55 +++++++++++++++++++
 MAINTAINERS                                   |  5 ++
 2 files changed, 60 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/temperature/sensirion,sts30.yaml
Documentation/devicetree/bindings/iio/temperature/sensirion,sts30.yaml new file +55 -0
new file mode 100644
index 000000000000..9bb0f04795d4
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/temperature/sensirion,sts30.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: STS30, STS31, and STS35 temperature iio sensors
+
+maintainers:
+  - Maxwell Doose <[email protected]>
+
+description: |
+  Family of digital temperature sensors from Sensirion with I2C interface.
+  All devices are compatible with each other, their only differences are
+  their levels of accuracy.
+
+  Datasheet available at:
+  https://sensirion.com/media/documents/1DA31AFD/65D613A8/Datasheet_STS3x_DIS.pdf
+
+properties:
+  compatible:
+    enum:
+      - sensirion,sts30
+      - sensirion,sts31
+      - sensirion,sts35
+
+  reg:
+    maxItems: 1
+
+  vdd-supply: true
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        temperature@4a {
+            compatible = "sensirion,sts30";
+            reg = <0x4a>;
+            vdd-supply = <&reg_3v3>;
+            interrupts = <2 IRQ_TYPE_EDGE_FALLING>;
+        };
+    };
MAINTAINERS +5 -0
index d95d3ef77773..7f94b8cac3e2 100644
@@ -24487,6 +24487,11 @@ F:	drivers/iio/chemical/sps30.c
 F:	drivers/iio/chemical/sps30_i2c.c
 F:	drivers/iio/chemical/sps30_serial.c
 
+SENSIRION STS30 TEMPERATURE SENSOR DRIVER
+M:	Maxwell Doose <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/iio/temperature/sensirion,sts30.yaml
+
 SERIAL DEVICE BUS
 M:	Rob Herring <[email protected]>
 L:	[email protected]
Signature · 1 line
2.54.0
maintainer Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] dt-bindings: iio: temperature: Add STS30 devicetree bindings

Quoted 15 lines · Maxwell Doose

Add the devicetree bindings for the STS30 family of temperature sensors. The STS30 family of sensors includes the STS30, STS31, and STS35.

All devices in the STS30 family share the same commands, timings, etc. The only difference between them is their measurement accuracy and tolerance.

Additionally add MAINTAINERS entry for the driver.

---
Changes since v1:
- Squashed parts of the MAINTAINERS commit into this commit.
- Added ALERT pin as an interrupt and in the examples.

Quoted 5 lines
 .../iio/temperature/sensirion,sts30.yaml      | 55 +++++++++++++++++++
 MAINTAINERS                                   |  5 ++
 2 files changed, 60 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/temperature/sensirion,sts30.yaml
maintainer
#3 lore raw

Re: [PATCH v2 1/2] dt-bindings: iio: temperature: Add STS30 devicetree bindings

In reply to Maxwell Doose
Quoted 6 lines · On Sat, 20 Jun 2026 19:46:23 -0500 Maxwell Doose <[email protected]> wrote:

Add the devicetree bindings for the STS30 family of temperature sensors. The STS30 family of sensors includes the STS30, STS31, and STS35.

All devices in the STS30 family share the same commands, timings, etc. The only difference between them is their measurement accuracy and tolerance.

Given we don't report accuracy (and reporting less accurate than they actually are should always be safe if we do add such reporting in future), I think a fallback compatible to the least accurate is appropriate for the other two.

Quoted 91 lines

Additionally add MAINTAINERS entry for the driver.

---
Changes since v1:
- Squashed parts of the MAINTAINERS commit into this commit.
- Added ALERT pin as an interrupt and in the examples.

 .../iio/temperature/sensirion,sts30.yaml      | 55 +++++++++++++++++++
 MAINTAINERS                                   |  5 ++
 2 files changed, 60 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/temperature/sensirion,sts30.yaml
Documentation/devicetree/bindings/iio/temperature/sensirion,sts30.yaml new file +55 -0
new file mode 100644
index 000000000000..9bb0f04795d4
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/temperature/sensirion,sts30.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: STS30, STS31, and STS35 temperature iio sensors
+
+maintainers:
+  - Maxwell Doose <[email protected]>
+
+description: |
+  Family of digital temperature sensors from Sensirion with I2C interface.
+  All devices are compatible with each other, their only differences are
+  their levels of accuracy.
+
+  Datasheet available at:
+  https://sensirion.com/media/documents/1DA31AFD/65D613A8/Datasheet_STS3x_DIS.pdf
+
+properties:
+  compatible:
+    enum:
+      - sensirion,sts30
+      - sensirion,sts31
+      - sensirion,sts35
+
+  reg:
+    maxItems: 1
+
+  vdd-supply: true
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        temperature@4a {
+            compatible = "sensirion,sts30";
+            reg = <0x4a>;
+            vdd-supply = <&reg_3v3>;
+            interrupts = <2 IRQ_TYPE_EDGE_FALLING>;
+        };
+    };
MAINTAINERS +5 -0
index d95d3ef77773..7f94b8cac3e2 100644
@@ -24487,6 +24487,11 @@ F:	drivers/iio/chemical/sps30.c
 F:	drivers/iio/chemical/sps30_i2c.c
 F:	drivers/iio/chemical/sps30_serial.c
 
+SENSIRION STS30 TEMPERATURE SENSOR DRIVER
+M:	Maxwell Doose <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/iio/temperature/sensirion,sts30.yaml
+
 SERIAL DEVICE BUS
 M:	Rob Herring <[email protected]>
 L:	[email protected]
#4 lore raw

PATCH v2 2/2 iio: temperature: Add STS30 temperature sensor driver

In reply to Maxwell Doose

Add a driver for the Sensirion STS30 family of temperature sensor drivers over I2C. The STS30 family of sensors includes the STS30, STS31, and STS35, all of which are supported by this driver, since they all share the same commands, etc. and only differ in accuracy and tolerance.

The driver currently supports single-shot non-clock stretched readings, by using a specified delay based on the repeatability/delay specified by the user. The repeatability/delay can be changed at any time through sysfs.

Additionally add Kconfig and Makefile entries for the driver as well as a MAINTAINERS entry.

---
Changes since v1:
- Squashed parts of the MAINTAINERS commit into this commit.
- Fixed a mixup between the clock-stretched and non-clock stretched commands.
- Fixed an issue where the return value of sts30_reset() was ignored.
- Removed redundant "Author" line at the top.
- Added comment at the top for the formula used to calculate the temperature in Celsius alongside a macro.
- Added a dedicated macro for the temperature reading size.
- Separated the generic linux headers from the iio specific headers.
- Removed kernel.h from includes.
- Removed unneeded comments.
- Used named initializers for sts30_id and moved above _probe().

 MAINTAINERS                      |   1 +
 drivers/iio/temperature/Kconfig  |  11 ++
 drivers/iio/temperature/Makefile |   1 +
 drivers/iio/temperature/sts30.c  | 329 +++++++++++++++++++++++++++++++
 4 files changed, 342 insertions(+)
 create mode 100644 drivers/iio/temperature/sts30.c
MAINTAINERS +1 -0
index 7f94b8cac3e2..6bb361ac213f 100644
@@ -24491,6 +24491,7 @@ SENSIRION STS30 TEMPERATURE SENSOR DRIVER
 M:	Maxwell Doose <[email protected]>
 S:	Maintained
 F:	Documentation/devicetree/bindings/iio/temperature/sensirion,sts30.yaml
+F:	drivers/iio/temperature/sts30.c
 
 SERIAL DEVICE BUS
 M:	Rob Herring <[email protected]>
drivers/iio/temperature/Kconfig +11 -0
index 9328b2250ace..c23a9c40c725 100644
@@ -88,6 +88,17 @@ config MLX90635
 	  This driver can also be built as a module. If so, the module will
 	  be called mlx90635.
 
+config STS30
+	tristate "STS30/STS31/STS35 temperature sensor"
+	depends on I2C
+	select CRC8
+	help
+	  If you say yes here you get support for the Sensirion STS30,
+	  STS31, and STS35 temperature sensors over I2C.
+
+	  This driver can also be built as a module. If so, the module will
+	  be called sts30.
+
 config TMP006
 	tristate "TMP006 infrared thermopile sensor"
 	depends on I2C
drivers/iio/temperature/Makefile +1 -0
index 07d6e65709f7..9c9bf8d1b70e 100644
@@ -14,6 +14,7 @@ obj-$(CONFIG_MCP9600) += mcp9600.o
 obj-$(CONFIG_MLX90614) += mlx90614.o
 obj-$(CONFIG_MLX90632) += mlx90632.o
 obj-$(CONFIG_MLX90632) += mlx90635.o
+obj-$(CONFIG_STS30) += sts30.o
 obj-$(CONFIG_TMP006) += tmp006.o
 obj-$(CONFIG_TMP007) += tmp007.o
 obj-$(CONFIG_TMP117) += tmp117.o
drivers/iio/temperature/sts30.c new file +329 -0

329 lines not on this page · raw message

Signature · 1 line
2.54.0
#5 lore raw

Re: [PATCH v2 2/2] iio: temperature: Add STS30 temperature sensor driver

drivers/iio/temperature/sts30.c line 18

Quoted 9 lines · On Sat, 20 Jun 2026 19:46:24 -0500 Maxwell Doose <[email protected]> wrote:
drivers/iio/temperature/sts30.c new file +9 -0
+#include <linux/array_size.h>
+#include <linux/bits.h>
+#include <linux/cleanup.h>
+#include <linux/crc8.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/export.h>
+#include <linux/i2c.h>

I am a numpty as I also forgot to mention a missing mod_devicetable.h header.

Signature · 3 lines
Kind regards

CJD
#6 lore raw

Re: [PATCH v2 2/2] iio: temperature: Add STS30 temperature sensor driver

Quoted 16 lines · Joshua Crofts

drivers/iio/temperature/sts30.c line 18

Quoted 9 lines · On Sat, 20 Jun 2026 19:46:24 -0500 Maxwell Doose <[email protected]> wrote:
drivers/iio/temperature/sts30.c new file +9 -0
+#include <linux/array_size.h>
+#include <linux/bits.h>
+#include <linux/cleanup.h>
+#include <linux/crc8.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/export.h>
+#include <linux/i2c.h>

I am a numpty as I also forgot to mention a missing mod_devicetable.h header.

D'oh, I ought to look at my includes a lot more closely as well.

#7 lore raw

Re: [PATCH v2 2/2] iio: temperature: Add STS30 temperature sensor driver

Quoted 19 lines · Maxwell Doose
Quoted 16 lines · Joshua Crofts

drivers/iio/temperature/sts30.c line 18

Quoted 9 lines · On Sat, 20 Jun 2026 19:46:24 -0500 Maxwell Doose <[email protected]> wrote:
drivers/iio/temperature/sts30.c new file +9 -0
+#include <linux/array_size.h>
+#include <linux/bits.h>
+#include <linux/cleanup.h>
+#include <linux/crc8.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/export.h>
+#include <linux/i2c.h>

I am a numpty as I also forgot to mention a missing mod_devicetable.h header.

Quoted 1 line

D'oh, I ought to look at my includes a lot more closely as well.

Forgot to mention, I'll be away for 2 weeks starting tomorrow so it'll have to wait :(

maintainer
#8 lore raw

Re: [PATCH v2 2/2] iio: temperature: Add STS30 temperature sensor driver

Quoted 20 lines · On Sun, 21 Jun 2026 19:09:11 -0500 Maxwell Doose <[email protected]> wrote:
Quoted 19 lines · Maxwell Doose
Quoted 16 lines · Joshua Crofts

drivers/iio/temperature/sts30.c line 18

Quoted 9 lines · On Sat, 20 Jun 2026 19:46:24 -0500 Maxwell Doose <[email protected]> wrote:
drivers/iio/temperature/sts30.c new file +9 -0
+#include <linux/array_size.h>
+#include <linux/bits.h>
+#include <linux/cleanup.h>
+#include <linux/crc8.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/export.h>
+#include <linux/i2c.h>  

I am a numpty as I also forgot to mention a missing mod_devicetable.h header.

Quoted 4 lines
Quoted 1 line

D'oh, I ought to look at my includes a lot more closely as well.

Forgot to mention, I'll be away for 2 weeks starting tomorrow so it'll have to wait :(

Don't add mod_devicetable.h. There is a series from Uwe that splits that header up and puts the tables different headers. i2c.h is now enough. (It's causing merge conflicts)

Jonathan

#9 lore raw

Re: [PATCH v2 2/2] iio: temperature: Add STS30 temperature sensor driver

Quoted 23 lines · On Fri, 3 Jul 2026 00:31:59 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 20 lines · On Sun, 21 Jun 2026 19:09:11 -0500 Maxwell Doose <[email protected]> wrote:
Quoted 19 lines · Maxwell Doose
Quoted 16 lines · Joshua Crofts

drivers/iio/temperature/sts30.c line 18

Quoted 9 lines · On Sat, 20 Jun 2026 19:46:24 -0500 Maxwell Doose <[email protected]> wrote:
drivers/iio/temperature/sts30.c new file +9 -0
+#include <linux/array_size.h>
+#include <linux/bits.h>
+#include <linux/cleanup.h>
+#include <linux/crc8.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/export.h>
+#include <linux/i2c.h>    

I am a numpty as I also forgot to mention a missing mod_devicetable.h header.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

D'oh, I ought to look at my includes a lot more closely as well.

Forgot to mention, I'll be away for 2 weeks starting tomorrow so it'll have to wait :(

Don't add mod_devicetable.h. There is a series from Uwe that splits that header up and puts the tables different headers. i2c.h is now enough. (It's causing merge conflicts)

Cool, one include less to worry about.

Signature · 3 lines
Kind regards

CJD
maintainer
#10 lore raw

Re: [PATCH v2 2/2] iio: temperature: Add STS30 temperature sensor driver

In reply to Maxwell Doose
Quoted 10 lines · On Sat, 20 Jun 2026 19:46:24 -0500 Maxwell Doose <[email protected]> wrote:

Add a driver for the Sensirion STS30 family of temperature sensor drivers over I2C. The STS30 family of sensors includes the STS30, STS31, and STS35, all of which are supported by this driver, since they all share the same commands, etc. and only differ in accuracy and tolerance.

The driver currently supports single-shot non-clock stretched readings, by using a specified delay based on the repeatability/delay specified by the user. The repeatability/delay can be changed at any time through sysfs.

Quoted 4 lines

Additionally add Kconfig and Makefile entries for the driver as well as a MAINTAINERS entry.

Big question first. Why IIO? These are fairly basic temperature sensors which typically means hwmon is more appropriate. What does it need that hwmon doesn't provide?

A few other things inline.

drivers/iio/temperature/sts30.c line 47

Quoted 13 lines
drivers/iio/temperature/sts30.c new file +7 -0
new file mode 100644
index 000000000000..dcfe3435ae5a
 
+
+/* Size of the temperature measurement data received after a read command */
+#define STS30_TEMP_MEAS_SIZE 2
+
+#define STS30_COMMAND_READ_HIGH_REPEAT 0x2400
+#define STS30_COMMAND_READ_MED_REPEAT 0x240B
+#define STS30_COMMAND_READ_LOW_REPEAT 0x2416

That smells like two fields in one value.

drivers/iio/temperature/sts30.c line 60

Quoted 4 lines
drivers/iio/temperature/sts30.c new file +3 -0
+
+#define STS30_COMMAND_RESET 0x30A2
 
+enum sts30_read_delays { 

Name it to indicate unit.

drivers/iio/temperature/sts30.c line 95

Quoted 10 lines
drivers/iio/temperature/sts30.c new file +9 -0
+	STS30_REPEAT_LOW = 4500,
+	STS30_REPEAT_MED = 6000,
+	STS30_REPEAT_HIGH = 15000
+};
+
 
+static int sts30_read(struct sts30_data *data, u16 command, u16 *val)
+{
+	u8 buf[STS30_MEAS_SIZE];
+	u8 tmp[2];

Might as well make it __be16 then it's aligned.

Quoted 11 lines
drivers/iio/temperature/sts30.c new file +11 -0
+	int ret;
+
+	put_unaligned_be16(command, tmp);
+
+	ret = i2c_master_send(data->client, tmp, sizeof(tmp));
+	if (ret < 0)
+		return ret;
+	if (ret != sizeof(tmp))
+		return -EIO;
+
+	fsleep(data->delay);

drivers/iio/temperature/sts30.c line 116

Quoted 10 lines
drivers/iio/temperature/sts30.c new file +10 -0
+
+	ret = i2c_master_recv(data->client, buf, sizeof(buf));
+	if (ret < 0)
+		return ret;
+	if (ret != sizeof(buf))
+		return -EIO;
+
+	*val = get_unaligned_be16(buf);
+
+	ret = sts30_verify_crc8(data, buf);

return sts30_...

Quoted 6 lines
drivers/iio/temperature/sts30.c new file +5 -0
+	if (ret)
+		return ret;
+
+	return 0;
+}
 

drivers/iio/temperature/sts30.c line 167

Quoted 10 lines
drivers/iio/temperature/sts30.c new file +10 -0
+
+static int sts30_read_raw(struct iio_dev *indio_dev,
+			  struct iio_chan_spec const *chan, int *val, int *val2,
+			  long mask)
+{
+	struct sts30_data *data = iio_priv(indio_dev);
+	int ret;
+	u16 tmp;
+
+	guard(mutex)(&data->lock);

I'd move this into appropriate scope as the lock isn't needed for all the const data cases.

Quoted 6 lines
drivers/iio/temperature/sts30.c new file +6 -0
+
+	switch (mask) {
+	case IIO_CHAN_INFO_RAW:
+		switch (data->delay) {
+		case STS30_REPEAT_LOW:
+			ret = sts30_read(data, STS30_COMMAND_READ_LOW_REPEAT, &tmp);

drivers/iio/temperature/sts30.c line 183

Quoted 10 lines
drivers/iio/temperature/sts30.c new file +10 -0
+			break;
+		case STS30_REPEAT_MED:
+			ret = sts30_read(data, STS30_COMMAND_READ_MED_REPEAT, &tmp);
+			break;
+		case STS30_REPEAT_HIGH:
+			ret = sts30_read(data, STS30_COMMAND_READ_HIGH_REPEAT, &tmp);
+			break;
+		default:
+			dev_warn(&data->client->dev, "Repeatability state corrupted, got: %d\n",
+				 data->delay);

Any realistic way this can happen? If not drop the print.

drivers/iio/temperature/sts30.c line 193

Quoted 10 lines
drivers/iio/temperature/sts30.c new file +10 -0
+			return -EINVAL;
+		}
+
+		if (ret)
+			return ret;
+
+		*val = tmp;
+		return IIO_VAL_INT;
+	case IIO_CHAN_INFO_OFFSET:
+		*val = STS30_TEMP_OFFSET;

These constant cases don't need the lock.

drivers/iio/temperature/sts30.c line 201

Quoted 8 lines
drivers/iio/temperature/sts30.c new file +8 -0
+		return IIO_VAL_INT;
+	case IIO_CHAN_INFO_SCALE:
+		*val = 175000;
+		*val2 = 65535;
+		return IIO_VAL_FRACTIONAL;
+	case IIO_CHAN_INFO_INT_TIME:
+		*val = 0;
+		*val2 = data->delay;

Might need the guard - I haven't checked.

Quoted 4 lines
drivers/iio/temperature/sts30.c new file +4 -0
+		return IIO_VAL_INT_PLUS_MICRO;
+	default:
+		return -EINVAL;
+	}

drivers/iio/temperature/sts30.c line 215

Quoted 10 lines
drivers/iio/temperature/sts30.c new file +10 -0
+}
+
+static int sts30_write_raw(struct iio_dev *indio_dev,
+			   struct iio_chan_spec const *chan, int val, int val2,
+			   long mask)
+{
+	struct sts30_data *data = iio_priv(indio_dev);
+
+	if (val)
+		return -EINVAL;

That is going to be IIO_* specific in the switch - so move it into the case block.

drivers/iio/temperature/sts30.c line 219

Quoted 4 lines
drivers/iio/temperature/sts30.c new file +4 -0
+
+	switch (mask) {
+	case IIO_CHAN_INFO_INT_TIME: {
+		guard(mutex)(&data->lock);

Given it is taken in all non error paths, I'd lift the guard() up to outside the switch.

drivers/iio/temperature/sts30.c line 224

Quoted 5 lines
drivers/iio/temperature/sts30.c new file +5 -0
+
+		switch (val2) {
+		case STS30_REPEAT_LOW:
+			data->delay = STS30_REPEAT_LOW;
+			break;

Given you are done in each of these, return instead of break.

Quoted 10 lines
drivers/iio/temperature/sts30.c new file +10 -0
+		case STS30_REPEAT_MED:
+			data->delay = STS30_REPEAT_MED;
+			break;
+		case STS30_REPEAT_HIGH:
+			data->delay = STS30_REPEAT_HIGH;
+			break;
+		default:
+			return -EINVAL;
+		}
+

drivers/iio/temperature/sts30.c line 244

Quoted 10 lines
drivers/iio/temperature/sts30.c new file +10 -0
+		return 0;
+	}
+	default:
+		return -EINVAL;
+	}
+}
+
+static const struct iio_info sts30_info = {
+	.read_raw = sts30_read_raw,
+	.write_raw = sts30_write_raw

Missing comma.

Basic rule of these is you can only skip the comma if doing so doesn't create additional churn when adding new stuff after it. Two cases are common.
1) Nothing can be added there - true of terminators {} etc.
2) It's one line anyway so any change will result in that line changing and hence no advantage in having the comma.

drivers/iio/temperature/sts30.c line 251

Quoted 7 lines
drivers/iio/temperature/sts30.c new file +7 -0
+};
+
+static const struct iio_chan_spec sts30_channels[] = {
+	{
+		.type = IIO_TEMP,
+		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_OFFSET) |
+				      BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_INT_TIME)

No obvious gain in going longer than 80 chars here. Just have one per line. Also the , is missing

Quoted 4 lines
drivers/iio/temperature/sts30.c new file +4 -0
+	},
+};
+
+static int sts30_probe(struct i2c_client *client)

drivers/iio/temperature/sts30.c line 265

Quoted 10 lines
drivers/iio/temperature/sts30.c new file +10 -0
+{
+	struct iio_dev *indio_dev;
+	struct sts30_data *data;
+	int ret;
+
+	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
+	if (!indio_dev)
+		return -ENOMEM;
+
+	indio_dev->name = client->name;

I'd prefer to see that done via device specific chip_info structures. IIRC there are some paths in which client->name might not be set appropriately. For ACPI PRP0001 (the route that uses compatible) it is set to the vendor stripped name so that is fine, but should we ever add 'proper' ACPI support it will be the _HID which isn't what we want.

Anyhow, normally we avoid thinking about this by getting from the data rather than the ->name via i2c_get_match_data() and appropriate structures.

Quoted 4 lines
drivers/iio/temperature/sts30.c new file +4 -0
+	indio_dev->info = &sts30_info;
+	indio_dev->channels = sts30_channels;
+	indio_dev->num_channels = ARRAY_SIZE(sts30_channels);
+	indio_dev->modes = INDIO_DIRECT_MODE;

drivers/iio/temperature/sts30.c line 279

Quoted 10 lines
drivers/iio/temperature/sts30.c new file +10 -0
+
+	data = iio_priv(indio_dev);
+	data->client = client;
+	data->delay = STS30_REPEAT_HIGH;
+
+	ret = devm_mutex_init(&client->dev, &data->lock);
+	if (ret)
+		return ret;
+
+	i2c_set_clientdata(client, indio_dev);

Why? I'm not seeing it being used.

Quoted 7 lines
drivers/iio/temperature/sts30.c new file +7 -0
+
+	ret = sts30_reset(data);
+	if (ret)
+		return ret;
+
+	return devm_iio_device_register(&client->dev, indio_dev);
+}
#11 lore raw

Re: [PATCH v2 2/2] iio: temperature: Add STS30 temperature sensor driver

Hi Jonathan,

Quoted 13 lines · On Fri, 3 Jul 2026 01:05:32 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 10 lines · On Sat, 20 Jun 2026 19:46:24 -0500 Maxwell Doose <[email protected]> wrote:

Add a driver for the Sensirion STS30 family of temperature sensor drivers over I2C. The STS30 family of sensors includes the STS30, STS31, and STS35, all of which are supported by this driver, since they all share the same commands, etc. and only differ in accuracy and tolerance.

The driver currently supports single-shot non-clock stretched readings, by using a specified delay based on the repeatability/delay specified by the user. The repeatability/delay can be changed at any time through sysfs.

Quoted 9 lines
Quoted 4 lines

Additionally add Kconfig and Makefile entries for the driver as well as a MAINTAINERS entry.

Big question first. Why IIO? These are fairly basic temperature sensors which typically means hwmon is more appropriate. What does it need that hwmon doesn't provide?

The datasheet says that the STS30 supports continuous reads which means that we can read it into a triggered buffer (which hwmon doesn't support) and at some point I'd like to implement that.

Additionally I don't have much experience (or any for that matter) in hwmon.

Quoted 30 lines

A few other things inline.

drivers/iio/temperature/sts30.c line 47

Quoted 13 lines
drivers/iio/temperature/sts30.c new file +7 -0
new file mode 100644
index 000000000000..dcfe3435ae5a
 
+
+/* Size of the temperature measurement data received after a read command */
+#define STS30_TEMP_MEAS_SIZE 2
+
+#define STS30_COMMAND_READ_HIGH_REPEAT 0x2400
+#define STS30_COMMAND_READ_MED_REPEAT 0x240B
+#define STS30_COMMAND_READ_LOW_REPEAT 0x2416  

That smells like two fields in one value.

drivers/iio/temperature/sts30.c line 60

Quoted 4 lines
drivers/iio/temperature/sts30.c new file +3 -0
+
+#define STS30_COMMAND_RESET 0x30A2  
 
+enum sts30_read_delays {   

Name it to indicate unit.

Quoted 5 lines
drivers/iio/temperature/sts30.c new file +5 -0
+	STS30_REPEAT_LOW = 4500,
+	STS30_REPEAT_MED = 6000,
+	STS30_REPEAT_HIGH = 15000
+};
+  
Quoted 5 lines

drivers/iio/temperature/sts30.c line 95

Quoted 4 lines
drivers/iio/temperature/sts30.c new file +4 -0
+static int sts30_read(struct sts30_data *data, u16 command, u16 *val)
+{
+	u8 buf[STS30_MEAS_SIZE];
+	u8 tmp[2];  

Might as well make it __be16 then it's aligned.

Makes sense.

Quoted 16 lines
Quoted 16 lines
drivers/iio/temperature/sts30.c new file +15 -0
+	int ret;
+
+	put_unaligned_be16(command, tmp);
+
+	ret = i2c_master_send(data->client, tmp, sizeof(tmp));
+	if (ret < 0)
+		return ret;
+	if (ret != sizeof(tmp))
+		return -EIO;
+
+	fsleep(data->delay);
+
+	ret = i2c_master_recv(data->client, buf, sizeof(buf));
+	if (ret < 0)
+		return ret;
Quoted 9 lines

drivers/iio/temperature/sts30.c line 116

Quoted 6 lines
drivers/iio/temperature/sts30.c new file +6 -0
+	if (ret != sizeof(buf))
+		return -EIO;
+
+	*val = get_unaligned_be16(buf);
+
+	ret = sts30_verify_crc8(data, buf);  

return sts30_...

D'oh, don't know how I missed this.

Quoted 7 lines
Quoted 6 lines
drivers/iio/temperature/sts30.c new file +5 -0
+	if (ret)
+		return ret;
+
+	return 0;
+}  
Quoted 14 lines

drivers/iio/temperature/sts30.c line 167

Quoted 10 lines
drivers/iio/temperature/sts30.c new file +10 -0
+
+static int sts30_read_raw(struct iio_dev *indio_dev,
+			  struct iio_chan_spec const *chan, int *val, int *val2,
+			  long mask)
+{
+	struct sts30_data *data = iio_priv(indio_dev);
+	int ret;
+	u16 tmp;
+
+	guard(mutex)(&data->lock);  

I'd move this into appropriate scope as the lock isn't needed for all the const data cases.

Will do.

Quoted 11 lines
Quoted 11 lines
drivers/iio/temperature/sts30.c new file +10 -0
+
+	switch (mask) {
+	case IIO_CHAN_INFO_RAW:
+		switch (data->delay) {
+		case STS30_REPEAT_LOW:
+			ret = sts30_read(data, STS30_COMMAND_READ_LOW_REPEAT, &tmp);
+			break;
+		case STS30_REPEAT_MED:
+			ret = sts30_read(data, STS30_COMMAND_READ_MED_REPEAT, &tmp);
+			break;
Quoted 9 lines

drivers/iio/temperature/sts30.c line 183

Quoted 6 lines
drivers/iio/temperature/sts30.c new file +6 -0
+		case STS30_REPEAT_HIGH:
+			ret = sts30_read(data, STS30_COMMAND_READ_HIGH_REPEAT, &tmp);
+			break;
+		default:
+			dev_warn(&data->client->dev, "Repeatability state corrupted, got: %d\n",
+				 data->delay);  

Any realistic way this can happen? If not drop the print.

Probably not (unless of course a cosmic ray flips a bit or two).

Quoted 13 lines

drivers/iio/temperature/sts30.c line 193

Quoted 11 lines
drivers/iio/temperature/sts30.c new file +10 -0
+			return -EINVAL;
+		}
+
+		if (ret)
+			return ret;
+
+		*val = tmp;
+		return IIO_VAL_INT;
+	case IIO_CHAN_INFO_OFFSET:
+		*val = STS30_TEMP_OFFSET;  

These constant cases don't need the lock.

Quoted 11 lines

drivers/iio/temperature/sts30.c line 201

Quoted 8 lines
drivers/iio/temperature/sts30.c new file +8 -0
+		return IIO_VAL_INT;
+	case IIO_CHAN_INFO_SCALE:
+		*val = 175000;
+		*val2 = 65535;
+		return IIO_VAL_FRACTIONAL;
+	case IIO_CHAN_INFO_INT_TIME:
+		*val = 0;
+		*val2 = data->delay;  

Might need the guard - I haven't checked.

I'm tempted to lock that read since it's shared, but I'll take a look into it.

Quoted 10 lines
Quoted 10 lines
drivers/iio/temperature/sts30.c new file +9 -0
+		return IIO_VAL_INT_PLUS_MICRO;
+	default:
+		return -EINVAL;
+	}
+}
+
+static int sts30_write_raw(struct iio_dev *indio_dev,
+			   struct iio_chan_spec const *chan, int val, int val2,
+			   long mask)
Quoted 9 lines

drivers/iio/temperature/sts30.c line 215

Quoted 5 lines
drivers/iio/temperature/sts30.c new file +5 -0
+{
+	struct sts30_data *data = iio_priv(indio_dev);
+
+	if (val)
+		return -EINVAL;  

That is going to be IIO_* specific in the switch - so move it into the case block.

Good point.

Quoted 9 lines

drivers/iio/temperature/sts30.c line 219

Quoted 5 lines
drivers/iio/temperature/sts30.c new file +4 -0
+
+	switch (mask) {
+	case IIO_CHAN_INFO_INT_TIME: {
+		guard(mutex)(&data->lock);  

Given it is taken in all non error paths, I'd lift the guard() up to outside the switch.

Will do.

Quoted 9 lines

drivers/iio/temperature/sts30.c line 224

Quoted 6 lines
drivers/iio/temperature/sts30.c new file +5 -0
+
+		switch (val2) {
+		case STS30_REPEAT_LOW:
+			data->delay = STS30_REPEAT_LOW;
+			break;  

Given you are done in each of these, return instead of break.

D'oh, also don't know how I missed this.

Quoted 23 lines
Quoted 11 lines
drivers/iio/temperature/sts30.c new file +10 -0
+		case STS30_REPEAT_MED:
+			data->delay = STS30_REPEAT_MED;
+			break;
+		case STS30_REPEAT_HIGH:
+			data->delay = STS30_REPEAT_HIGH;
+			break;
+		default:
+			return -EINVAL;
+		}
+

drivers/iio/temperature/sts30.c line 244

Quoted 10 lines
drivers/iio/temperature/sts30.c new file +10 -0
+		return 0;
+	}
+	default:
+		return -EINVAL;
+	}
+}
+
+static const struct iio_info sts30_info = {
+	.read_raw = sts30_read_raw,
+	.write_raw = sts30_write_raw  

Missing comma.

Quoted 6 lines

Basic rule of these is you can only skip the comma if doing so doesn't create additional churn when adding new stuff after it. Two cases are common.
1) Nothing can be added there - true of terminators {} etc.
2) It's one line anyway so any change will result in that line changing and hence no advantage in having the comma.

Ah. Will fix.

Quoted 12 lines

drivers/iio/temperature/sts30.c line 251

Quoted 8 lines
drivers/iio/temperature/sts30.c new file +7 -0
+};
+
+static const struct iio_chan_spec sts30_channels[] = {
+	{
+		.type = IIO_TEMP,
+		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_OFFSET) |
+				      BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_INT_TIME)  

No obvious gain in going longer than 80 chars here. Just have one per line. Also the , is missing

Will fix up.

Quoted 22 lines
Quoted 5 lines
drivers/iio/temperature/sts30.c new file +4 -0
+	},
+};
+
+static int sts30_probe(struct i2c_client *client)

drivers/iio/temperature/sts30.c line 265

Quoted 10 lines
drivers/iio/temperature/sts30.c new file +10 -0
+{
+	struct iio_dev *indio_dev;
+	struct sts30_data *data;
+	int ret;
+
+	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
+	if (!indio_dev)
+		return -ENOMEM;
+
+	indio_dev->name = client->name;  

I'd prefer to see that done via device specific chip_info structures. IIRC there are some paths in which client->name might not be set appropriately. For ACPI PRP0001 (the route that uses compatible) it is set to the vendor stripped name so that is fine, but should we ever add 'proper' ACPI support it will be the _HID which isn't what we want.

Quoted 3 lines

Anyhow, normally we avoid thinking about this by getting from the data rather than the ->name via i2c_get_match_data() and appropriate structures.

Alright then, will do.

Quoted 18 lines
Quoted 5 lines
drivers/iio/temperature/sts30.c new file +4 -0
+	indio_dev->info = &sts30_info;
+	indio_dev->channels = sts30_channels;
+	indio_dev->num_channels = ARRAY_SIZE(sts30_channels);
+	indio_dev->modes = INDIO_DIRECT_MODE;

drivers/iio/temperature/sts30.c line 279

Quoted 10 lines
drivers/iio/temperature/sts30.c new file +10 -0
+
+	data = iio_priv(indio_dev);
+	data->client = client;
+	data->delay = STS30_REPEAT_HIGH;
+
+	ret = devm_mutex_init(&client->dev, &data->lock);
+	if (ret)
+		return ret;
+
+	i2c_set_clientdata(client, indio_dev);  

Why? I'm not seeing it being used.

Will just get rid of it then.

I'm probably a numpty for submitting this without the hardware :( I'll probably just withhold the v3 until I can get hardware (or at least submit as an RFC).

Signature · 2 lines
best regards,
max
maintainer
#12 lore raw

Re: [PATCH v2 2/2] iio: temperature: Add STS30 temperature sensor driver

Quoted 23 lines · On Sat, 4 Jul 2026 14:45:03 -0500 Maxwell Doose <[email protected]> wrote:

Hi Jonathan,

Quoted 18 lines · On Fri, 3 Jul 2026 01:05:32 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 14 lines · On Sat, 20 Jun 2026 19:46:24 -0500 Maxwell Doose <[email protected]> wrote:

Add a driver for the Sensirion STS30 family of temperature sensor drivers over I2C. The STS30 family of sensors includes the STS30, STS31, and STS35, all of which are supported by this driver, since they all share the same commands, etc. and only differ in accuracy and tolerance.

The driver currently supports single-shot non-clock stretched readings, by using a specified delay based on the repeatability/delay specified by the user. The repeatability/delay can be changed at any time through sysfs.

Additionally add Kconfig and Makefile entries for the driver as well as a MAINTAINERS entry.

Quoted 8 lines
Quoted 4 lines

Big question first. Why IIO? These are fairly basic temperature sensors which typically means hwmon is more appropriate. What does it need that hwmon doesn't provide?

The datasheet says that the STS30 supports continuous reads which means that we can read it into a triggered buffer (which hwmon doesn't support) and at some point I'd like to implement that.

Hmm. For a temperature chip that is often more about the monitors running continuously than the ability to gather signals fast. Temperature changes tend to be fairly slow when it's a physical sensor - gets less obvious when infrared remote sensors are involved.

Even more relevant - there is an existing driver I think.
See drivers/hwmon/sht3x.c which supports things under the wildcard sts3x as well. Check if that covers this part.

Thanks,

Jonathan

Quoted 291 lines

Additionally I don't have much experience (or any for that matter) in hwmon.

Quoted 30 lines

A few other things inline.

drivers/iio/temperature/sts30.c line 47

Quoted 13 lines
drivers/iio/temperature/sts30.c new file +7 -0
new file mode 100644
index 000000000000..dcfe3435ae5a
 
+
+/* Size of the temperature measurement data received after a read command */
+#define STS30_TEMP_MEAS_SIZE 2
+
+#define STS30_COMMAND_READ_HIGH_REPEAT 0x2400
+#define STS30_COMMAND_READ_MED_REPEAT 0x240B
+#define STS30_COMMAND_READ_LOW_REPEAT 0x2416    

That smells like two fields in one value.

drivers/iio/temperature/sts30.c line 60

Quoted 4 lines
drivers/iio/temperature/sts30.c new file +3 -0
+
+#define STS30_COMMAND_RESET 0x30A2    
 
+enum sts30_read_delays {     

Name it to indicate unit.

Quoted 5 lines
drivers/iio/temperature/sts30.c new file +5 -0
+	STS30_REPEAT_LOW = 4500,
+	STS30_REPEAT_MED = 6000,
+	STS30_REPEAT_HIGH = 15000
+};
+    
Quoted 5 lines

drivers/iio/temperature/sts30.c line 95

Quoted 4 lines
drivers/iio/temperature/sts30.c new file +4 -0
+static int sts30_read(struct sts30_data *data, u16 command, u16 *val)
+{
+	u8 buf[STS30_MEAS_SIZE];
+	u8 tmp[2];    

Might as well make it __be16 then it's aligned.

Makes sense.

Quoted 16 lines
Quoted 16 lines
drivers/iio/temperature/sts30.c new file +15 -0
+	int ret;
+
+	put_unaligned_be16(command, tmp);
+
+	ret = i2c_master_send(data->client, tmp, sizeof(tmp));
+	if (ret < 0)
+		return ret;
+	if (ret != sizeof(tmp))
+		return -EIO;
+
+	fsleep(data->delay);
+
+	ret = i2c_master_recv(data->client, buf, sizeof(buf));
+	if (ret < 0)
+		return ret;
Quoted 9 lines

drivers/iio/temperature/sts30.c line 116

Quoted 6 lines
drivers/iio/temperature/sts30.c new file +6 -0
+	if (ret != sizeof(buf))
+		return -EIO;
+
+	*val = get_unaligned_be16(buf);
+
+	ret = sts30_verify_crc8(data, buf);    

return sts30_...

D'oh, don't know how I missed this.

Quoted 7 lines
Quoted 6 lines
drivers/iio/temperature/sts30.c new file +5 -0
+	if (ret)
+		return ret;
+
+	return 0;
+}    
Quoted 14 lines

drivers/iio/temperature/sts30.c line 167

Quoted 10 lines
drivers/iio/temperature/sts30.c new file +10 -0
+
+static int sts30_read_raw(struct iio_dev *indio_dev,
+			  struct iio_chan_spec const *chan, int *val, int *val2,
+			  long mask)
+{
+	struct sts30_data *data = iio_priv(indio_dev);
+	int ret;
+	u16 tmp;
+
+	guard(mutex)(&data->lock);    

I'd move this into appropriate scope as the lock isn't needed for all the const data cases.

Will do.

Quoted 11 lines
Quoted 11 lines
drivers/iio/temperature/sts30.c new file +10 -0
+
+	switch (mask) {
+	case IIO_CHAN_INFO_RAW:
+		switch (data->delay) {
+		case STS30_REPEAT_LOW:
+			ret = sts30_read(data, STS30_COMMAND_READ_LOW_REPEAT, &tmp);
+			break;
+		case STS30_REPEAT_MED:
+			ret = sts30_read(data, STS30_COMMAND_READ_MED_REPEAT, &tmp);
+			break;
Quoted 9 lines

drivers/iio/temperature/sts30.c line 183

Quoted 6 lines
drivers/iio/temperature/sts30.c new file +6 -0
+		case STS30_REPEAT_HIGH:
+			ret = sts30_read(data, STS30_COMMAND_READ_HIGH_REPEAT, &tmp);
+			break;
+		default:
+			dev_warn(&data->client->dev, "Repeatability state corrupted, got: %d\n",
+				 data->delay);    

Any realistic way this can happen? If not drop the print.

Probably not (unless of course a cosmic ray flips a bit or two).

Quoted 13 lines

drivers/iio/temperature/sts30.c line 193

Quoted 11 lines
drivers/iio/temperature/sts30.c new file +10 -0
+			return -EINVAL;
+		}
+
+		if (ret)
+			return ret;
+
+		*val = tmp;
+		return IIO_VAL_INT;
+	case IIO_CHAN_INFO_OFFSET:
+		*val = STS30_TEMP_OFFSET;    

These constant cases don't need the lock.

Quoted 11 lines

drivers/iio/temperature/sts30.c line 201

Quoted 8 lines
drivers/iio/temperature/sts30.c new file +8 -0
+		return IIO_VAL_INT;
+	case IIO_CHAN_INFO_SCALE:
+		*val = 175000;
+		*val2 = 65535;
+		return IIO_VAL_FRACTIONAL;
+	case IIO_CHAN_INFO_INT_TIME:
+		*val = 0;
+		*val2 = data->delay;    

Might need the guard - I haven't checked.

I'm tempted to lock that read since it's shared, but I'll take a look into it.

Quoted 10 lines
Quoted 10 lines
drivers/iio/temperature/sts30.c new file +9 -0
+		return IIO_VAL_INT_PLUS_MICRO;
+	default:
+		return -EINVAL;
+	}
+}
+
+static int sts30_write_raw(struct iio_dev *indio_dev,
+			   struct iio_chan_spec const *chan, int val, int val2,
+			   long mask)
Quoted 9 lines

drivers/iio/temperature/sts30.c line 215

Quoted 5 lines
drivers/iio/temperature/sts30.c new file +5 -0
+{
+	struct sts30_data *data = iio_priv(indio_dev);
+
+	if (val)
+		return -EINVAL;    

That is going to be IIO_* specific in the switch - so move it into the case block.

Good point.

Quoted 9 lines

drivers/iio/temperature/sts30.c line 219

Quoted 5 lines
drivers/iio/temperature/sts30.c new file +4 -0
+
+	switch (mask) {
+	case IIO_CHAN_INFO_INT_TIME: {
+		guard(mutex)(&data->lock);    

Given it is taken in all non error paths, I'd lift the guard() up to outside the switch.

Will do.

Quoted 9 lines

drivers/iio/temperature/sts30.c line 224

Quoted 6 lines
drivers/iio/temperature/sts30.c new file +5 -0
+
+		switch (val2) {
+		case STS30_REPEAT_LOW:
+			data->delay = STS30_REPEAT_LOW;
+			break;    

Given you are done in each of these, return instead of break.

D'oh, also don't know how I missed this.

Quoted 23 lines
Quoted 11 lines
drivers/iio/temperature/sts30.c new file +10 -0
+		case STS30_REPEAT_MED:
+			data->delay = STS30_REPEAT_MED;
+			break;
+		case STS30_REPEAT_HIGH:
+			data->delay = STS30_REPEAT_HIGH;
+			break;
+		default:
+			return -EINVAL;
+		}
+

drivers/iio/temperature/sts30.c line 244

Quoted 10 lines
drivers/iio/temperature/sts30.c new file +10 -0
+		return 0;
+	}
+	default:
+		return -EINVAL;
+	}
+}
+
+static const struct iio_info sts30_info = {
+	.read_raw = sts30_read_raw,
+	.write_raw = sts30_write_raw    

Missing comma.

Quoted 6 lines

Basic rule of these is you can only skip the comma if doing so doesn't create additional churn when adding new stuff after it. Two cases are common.
1) Nothing can be added there - true of terminators {} etc.
2) It's one line anyway so any change will result in that line changing and hence no advantage in having the comma.

Ah. Will fix.

Quoted 12 lines

drivers/iio/temperature/sts30.c line 251

Quoted 8 lines
drivers/iio/temperature/sts30.c new file +7 -0
+};
+
+static const struct iio_chan_spec sts30_channels[] = {
+	{
+		.type = IIO_TEMP,
+		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_OFFSET) |
+				      BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_INT_TIME)    

No obvious gain in going longer than 80 chars here. Just have one per line. Also the , is missing

Will fix up.

Quoted 22 lines
Quoted 5 lines
drivers/iio/temperature/sts30.c new file +4 -0
+	},
+};
+
+static int sts30_probe(struct i2c_client *client)

drivers/iio/temperature/sts30.c line 265

Quoted 10 lines
drivers/iio/temperature/sts30.c new file +10 -0
+{
+	struct iio_dev *indio_dev;
+	struct sts30_data *data;
+	int ret;
+
+	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
+	if (!indio_dev)
+		return -ENOMEM;
+
+	indio_dev->name = client->name;    

I'd prefer to see that done via device specific chip_info structures. IIRC there are some paths in which client->name might not be set appropriately. For ACPI PRP0001 (the route that uses compatible) it is set to the vendor stripped name so that is fine, but should we ever add 'proper' ACPI support it will be the _HID which isn't what we want.

Quoted 3 lines

Anyhow, normally we avoid thinking about this by getting from the data rather than the ->name via i2c_get_match_data() and appropriate structures.

Alright then, will do.

Quoted 18 lines
Quoted 5 lines
drivers/iio/temperature/sts30.c new file +4 -0
+	indio_dev->info = &sts30_info;
+	indio_dev->channels = sts30_channels;
+	indio_dev->num_channels = ARRAY_SIZE(sts30_channels);
+	indio_dev->modes = INDIO_DIRECT_MODE;

drivers/iio/temperature/sts30.c line 279

Quoted 10 lines
drivers/iio/temperature/sts30.c new file +10 -0
+
+	data = iio_priv(indio_dev);
+	data->client = client;
+	data->delay = STS30_REPEAT_HIGH;
+
+	ret = devm_mutex_init(&client->dev, &data->lock);
+	if (ret)
+		return ret;
+
+	i2c_set_clientdata(client, indio_dev);    

Why? I'm not seeing it being used.

Will just get rid of it then.

I'm probably a numpty for submitting this without the hardware :( I'll probably just withhold the v3 until I can get hardware (or at least submit as an RFC).

#13 lore raw

Re: [PATCH v2 2/2] iio: temperature: Add STS30 temperature sensor driver

Quoted 35 lines · On Sun, 5 Jul 2026 00:00:53 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 23 lines · On Sat, 4 Jul 2026 14:45:03 -0500 Maxwell Doose <[email protected]> wrote:

Hi Jonathan,

Quoted 18 lines · On Fri, 3 Jul 2026 01:05:32 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 14 lines · On Sat, 20 Jun 2026 19:46:24 -0500 Maxwell Doose <[email protected]> wrote:

Add a driver for the Sensirion STS30 family of temperature sensor drivers over I2C. The STS30 family of sensors includes the STS30, STS31, and STS35, all of which are supported by this driver, since they all share the same commands, etc. and only differ in accuracy and tolerance.

The driver currently supports single-shot non-clock stretched readings, by using a specified delay based on the repeatability/delay specified by the user. The repeatability/delay can be changed at any time through sysfs.

Additionally add Kconfig and Makefile entries for the driver as well as a MAINTAINERS entry.

Quoted 8 lines
Quoted 4 lines

Big question first. Why IIO? These are fairly basic temperature sensors which typically means hwmon is more appropriate. What does it need that hwmon doesn't provide?

The datasheet says that the STS30 supports continuous reads which means that we can read it into a triggered buffer (which hwmon doesn't support) and at some point I'd like to implement that.

Quoted 9 lines

Hmm. For a temperature chip that is often more about the monitors running continuously than the ability to gather signals fast. Temperature changes tend to be fairly slow when it's a physical sensor - gets less obvious when infrared remote sensors are involved.

Even more relevant - there is an existing driver I think.
See drivers/hwmon/sht3x.c which supports things under the wildcard sts3x as well. Check if that covers this part.

I think the last time I checked the sts30 series wasn't listed in the dt-bindings but it may have changed since then. Oh well. I'll still go check it out. If it's (very very) similar I would probably consider dropping this one, otherwise I'll improve this one and resubmit once I get the hardware.

Signature · 2 lines
best regards,
max
maintainer
#14 lore raw

Re: [PATCH v2 2/2] iio: temperature: Add STS30 temperature sensor driver

Quoted 48 lines · On Sat, 4 Jul 2026 20:57:17 -0500 Maxwell Doose <[email protected]> wrote:
Quoted 35 lines · On Sun, 5 Jul 2026 00:00:53 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 23 lines · On Sat, 4 Jul 2026 14:45:03 -0500 Maxwell Doose <[email protected]> wrote:

Hi Jonathan,

Quoted 18 lines · On Fri, 3 Jul 2026 01:05:32 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 14 lines · On Sat, 20 Jun 2026 19:46:24 -0500 Maxwell Doose <[email protected]> wrote:

Add a driver for the Sensirion STS30 family of temperature sensor drivers over I2C. The STS30 family of sensors includes the STS30, STS31, and STS35, all of which are supported by this driver, since they all share the same commands, etc. and only differ in accuracy and tolerance.

The driver currently supports single-shot non-clock stretched readings, by using a specified delay based on the repeatability/delay specified by the user. The repeatability/delay can be changed at any time through sysfs.

Additionally add Kconfig and Makefile entries for the driver as well as a MAINTAINERS entry.

Quoted 8 lines
Quoted 4 lines

Big question first. Why IIO? These are fairly basic temperature sensors which typically means hwmon is more appropriate. What does it need that hwmon doesn't provide?

The datasheet says that the STS30 supports continuous reads which means that we can read it into a triggered buffer (which hwmon doesn't support) and at some point I'd like to implement that.

Quoted 9 lines

Hmm. For a temperature chip that is often more about the monitors running continuously than the ability to gather signals fast. Temperature changes tend to be fairly slow when it's a physical sensor - gets less obvious when infrared remote sensors are involved.

Even more relevant - there is an existing driver I think.
See drivers/hwmon/sht3x.c which supports things under the wildcard sts3x as well. Check if that covers this part.

Quoted 6 lines

I think the last time I checked the sts30 series wasn't listed in the dt-bindings but it may have changed since then. Oh well. I'll still go check it out. If it's (very very) similar I would probably consider dropping this one, otherwise I'll improve this one and resubmit once I get the hardware.

Unless that other driver is for a very different part, then it is a non starter to have a driver in IIO. Perhaps there are features missing in the hwmon driver though. +CC Guenter and hwmon so they are aware of this discussion.

thanks,

Jonathan

maintainer
#15 lore raw

Re: [PATCH v2 2/2] iio: temperature: Add STS30 temperature sensor driver

Quoted 59 lines · Jonathan Cameron
Quoted 48 lines · On Sat, 4 Jul 2026 20:57:17 -0500 Maxwell Doose <[email protected]> wrote:
Quoted 35 lines · On Sun, 5 Jul 2026 00:00:53 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 23 lines · On Sat, 4 Jul 2026 14:45:03 -0500 Maxwell Doose <[email protected]> wrote:

Hi Jonathan,

Quoted 18 lines · On Fri, 3 Jul 2026 01:05:32 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 14 lines · On Sat, 20 Jun 2026 19:46:24 -0500 Maxwell Doose <[email protected]> wrote:

Add a driver for the Sensirion STS30 family of temperature sensor drivers over I2C. The STS30 family of sensors includes the STS30, STS31, and STS35, all of which are supported by this driver, since they all share the same commands, etc. and only differ in accuracy and tolerance.

The driver currently supports single-shot non-clock stretched readings, by using a specified delay based on the repeatability/delay specified by the user. The repeatability/delay can be changed at any time through sysfs.

Additionally add Kconfig and Makefile entries for the driver as well as a MAINTAINERS entry.

Quoted 8 lines
Quoted 4 lines

Big question first. Why IIO? These are fairly basic temperature sensors which typically means hwmon is more appropriate. What does it need that hwmon doesn't provide?

The datasheet says that the STS30 supports continuous reads which means that we can read it into a triggered buffer (which hwmon doesn't support) and at some point I'd like to implement that.

Quoted 9 lines

Hmm. For a temperature chip that is often more about the monitors running continuously than the ability to gather signals fast. Temperature changes tend to be fairly slow when it's a physical sensor - gets less obvious when infrared remote sensors are involved.

Even more relevant - there is an existing driver I think.
See drivers/hwmon/sht3x.c which supports things under the wildcard sts3x as well. Check if that covers this part.

Quoted 6 lines

I think the last time I checked the sts30 series wasn't listed in the dt-bindings but it may have changed since then. Oh well. I'll still go check it out. If it's (very very) similar I would probably consider dropping this one, otherwise I'll improve this one and resubmit once I get the hardware.

Quoted 5 lines

Unless that other driver is for a very different part, then it is a non starter to have a driver in IIO. Perhaps there are features missing in the hwmon driver though. +CC Guenter and hwmon so they are aware of this discussion.

I have no idea what might be missing, or why the existing hwmon driver would not be sufficient. Lack of explicit devicetree support, as suggested above ? That would require a few lines of code and an odd reason to duplicate the driver in the iio subsystem. Triggered buffer ? That makes sense for high speed ADCs, but not for low speed sensors like this one.

Guenter

reviewer
#16 lore raw
In reply to Maxwell Doose
Quoted 8 lines · Maxwell Doose

Hi all,

This patch series adds support for the Sensirion STS30 temperature sensor family. This driver currently supports non clock stretched single shot measurements.

Given there were very little issues found with the v1 submission, I've decided to make this a regular patch series rather than an RFC patch.

You should wait at least one week for feedback on a new driver before submitting the next revision.

Given that you said in v1 that don't actually have the hardware, I am not going to review this. We are getting more patches than I can keep up with already.

Quoted 6 lines

Changes since v1:
* whole series:
- Squashed MAINTAINERS updates into both the dt-bindings commit and the driver commit.

#17 lore raw
Quoted 11 lines · David Lechner
Quoted 8 lines · Maxwell Doose

Hi all,

This patch series adds support for the Sensirion STS30 temperature sensor family. This driver currently supports non clock stretched single shot measurements.

Given there were very little issues found with the v1 submission, I've decided to make this a regular patch series rather than an RFC patch.

Quoted 7 lines

You should wait at least one week for feedback on a new driver before submitting the next revision.

Given that you said in v1 that don't actually have the hardware, I am not going to review this. We are getting more patches than I can keep up with already.

Fair enough, I'll be away until 4 July anyways.