Hi all,
The sht21 driver actually supports all i2c sht2x chips so add support for those names and additionally add DT support.
Tested for sht20 and verified against the datasheet for sht25.
Thanks!
Signed-off-by: Kurt Borja kuurtb@gmail.com --- Changes in v3: - Add MODULE_DEVICE_TABLE() (I forgot, sorry for the noise!) - Link to v2: https://lore.kernel.org/r/20250907-sht2x-v2-0-1c7dc90abf8e@gmail.com
Changes in v2: - Add a documentation cleanup patch - Add entry for each chip instead of sht2x placeholder - Update Kconfig too - Link to v1: https://lore.kernel.org/r/20250907-sht2x-v1-0-fd56843b1b43@gmail.com
--- Kurt Borja (4): hwmon: (sht21) Documentation cleanup hwmon: (sht21) Add support for SHT20, SHT25 chips hwmon: (sht21) Add devicetree support dt-bindings: trivial-devices: Add sht2x sensors
.../devicetree/bindings/trivial-devices.yaml | 3 +++ Documentation/hwmon/sht21.rst | 26 +++++++++++++--------- drivers/hwmon/Kconfig | 4 ++-- drivers/hwmon/sht21.c | 15 ++++++++++++- 4 files changed, 34 insertions(+), 14 deletions(-) --- base-commit: b236920731dd90c3fba8c227aa0c4dee5351a639 change-id: 20250907-sht2x-9b96125a0cf5
All sht2x chips share the same communication protocol so add support for them.
Cc: stable@vger.kernel.org Signed-off-by: Kurt Borja kuurtb@gmail.com --- Documentation/hwmon/sht21.rst | 10 ++++++++++ drivers/hwmon/Kconfig | 4 ++-- drivers/hwmon/sht21.c | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/Documentation/hwmon/sht21.rst b/Documentation/hwmon/sht21.rst index 9f66cd51b45dc4b89ce757d2209445478de046cd..d20e8a460ba6c7c8452bcdce68a1fce963413640 100644 --- a/Documentation/hwmon/sht21.rst +++ b/Documentation/hwmon/sht21.rst @@ -3,6 +3,16 @@ Kernel driver sht21
Supported chips:
+ * Sensirion SHT20 + + Prefix: 'sht20' + + Addresses scanned: none + + Datasheet: Publicly available at the Sensirion website + + https://www.sensirion.com/file/datasheet_sht20 + * Sensirion SHT21
Prefix: 'sht21' diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 9d28fcf7cd2a6f9e2f54694a717bd85ff4047b46..90dc8051418689e7a92293df15ce35cd822c77ff 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1930,8 +1930,8 @@ config SENSORS_SHT21 tristate "Sensiron humidity and temperature sensors. SHT21 and compat." depends on I2C help - If you say yes here you get support for the Sensiron SHT21, SHT25 - humidity and temperature sensors. + If you say yes here you get support for the Sensiron SHT20, SHT21, + SHT25 humidity and temperature sensors.
This driver can also be built as a module. If so, the module will be called sht21. diff --git a/drivers/hwmon/sht21.c b/drivers/hwmon/sht21.c index 97327313529b467ed89d8f6b06c2d78efd54efbf..97d71e3361e9d7f0512880149ba6479601b2fc0c 100644 --- a/drivers/hwmon/sht21.c +++ b/drivers/hwmon/sht21.c @@ -275,7 +275,9 @@ static int sht21_probe(struct i2c_client *client)
/* Device ID table */ static const struct i2c_device_id sht21_id[] = { + { "sht20" }, { "sht21" }, + { "sht25" }, { } }; MODULE_DEVICE_TABLE(i2c, sht21_id);
On 9/7/25 18:33, Kurt Borja wrote:
All sht2x chips share the same communication protocol so add support for them.
Cc: stable@vger.kernel.org
FWIW, I am going to drop this when applying. I don't add stable tags for patches which are not bug fixes. Anyone who wants such patches backported can request that separately after the patch is upstream.
Guenter
Add DT support for sht2x chips.
Cc: stable@vger.kernel.org Signed-off-by: Kurt Borja kuurtb@gmail.com --- drivers/hwmon/sht21.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/hwmon/sht21.c b/drivers/hwmon/sht21.c index 97d71e3361e9d7f0512880149ba6479601b2fc0c..627d35070a420ab9e51634bdc5cf5e3de3853326 100644 --- a/drivers/hwmon/sht21.c +++ b/drivers/hwmon/sht21.c @@ -282,8 +282,19 @@ static const struct i2c_device_id sht21_id[] = { }; MODULE_DEVICE_TABLE(i2c, sht21_id);
+static const struct of_device_id sht21_of_match[] = { + { .compatible = "sensirion,sht20" }, + { .compatible = "sensirion,sht21" }, + { .compatible = "sensirion,sht25" }, + { } +}; +MODULE_DEVICE_TABLE(of, sht21_of_match); + static struct i2c_driver sht21_driver = { - .driver.name = "sht21", + .driver = { + .name = "sht21", + .of_match_table = sht21_of_match, + }, .probe = sht21_probe, .id_table = sht21_id, };
Add sensirion,sht2x trivial sensors.
Cc: stable@vger.kernel.org Signed-off-by: Kurt Borja kuurtb@gmail.com --- Documentation/devicetree/bindings/trivial-devices.yaml | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index f3dd18681aa6f81255141bdda6daf8e45369a2c2..952244a7105591a0095b1ae57da7cb7345bdfc61 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -362,6 +362,9 @@ properties: # Sensirion low power multi-pixel gas sensor with I2C interface - sensirion,sgpc3 # Sensirion temperature & humidity sensor with I2C interface + - sensirion,sht20 + - sensirion,sht21 + - sensirion,sht25 - sensirion,sht4x # Sensortek 3 axis accelerometer - sensortek,stk8312
On 08/09/2025 03:33, Kurt Borja wrote:
Add sensirion,sht2x trivial sensors.
Cc: stable@vger.kernel.org
No, drop. No bug to fix here.
Please organize the patch documenting compatible (DT bindings) before their user. See also: https://elixir.bootlin.com/linux/v6.14-rc6/source/Documentation/devicetree/b...
Best regards, Krzysztof
Hi Krzysztof,
On Mon Sep 8, 2025 at 2:02 AM -05, Krzysztof Kozlowski wrote:
On 08/09/2025 03:33, Kurt Borja wrote:
Add sensirion,sht2x trivial sensors.
Cc: stable@vger.kernel.org
No, drop. No bug to fix here.
I included it because stable is fine with device IDs [1]. Is this avoided with dt-bindings related stuff?
Please organize the patch documenting compatible (DT bindings) before their user. See also: https://elixir.bootlin.com/linux/v6.14-rc6/source/Documentation/devicetree/b...
I will reorder.
Thanks for the review!
Best regards, Krzysztof
[1] https://elixir.bootlin.com/linux/v6.17-rc4/source/Documentation/process/stab...
On 08/09/2025 13:28, Kurt Borja wrote:
Hi Krzysztof,
On Mon Sep 8, 2025 at 2:02 AM -05, Krzysztof Kozlowski wrote:
On 08/09/2025 03:33, Kurt Borja wrote:
Add sensirion,sht2x trivial sensors.
Cc: stable@vger.kernel.org
No, drop. No bug to fix here.
I included it because stable is fine with device IDs [1]. Is this avoided with dt-bindings related stuff?
You do not add quirks or new IDs. You add something completely new - support for OF. That's a feature in this driver.
Best regards, Krzysztof
linux-stable-mirror@lists.linaro.org