[PATCH v4 3/4] hwmon: (sht3x) Add devicetree support

From: Zaixiang Xu

Date: Wed Mar 25 2026 - 05:09:04 EST


Add of_match_table to support devicetree based instantiation.
Specific match data is used to distinguish between temperature/humidity
(SHT) and temperature-only (STS) sensors.

Signed-off-by: Zaixiang Xu <zaixiang.xu.dev@xxxxxxxxx>
---
drivers/hwmon/sht3x.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/sht3x.c b/drivers/hwmon/sht3x.c
index 08306ccb6d0b..f2b1d3b8eb23 100644
--- a/drivers/hwmon/sht3x.c
+++ b/drivers/hwmon/sht3x.c
@@ -939,8 +939,19 @@ static const struct i2c_device_id sht3x_ids[] = {

MODULE_DEVICE_TABLE(i2c, sht3x_ids);

+static const struct of_device_id sht3x_of_match[] = {
+ { .compatible = "sensirion,sht30", .data = (void *)sht3x },
+ { .compatible = "sensirion,sts30", .data = (void *)sts3x },
+ { }
+};
+
+MODULE_DEVICE_TABLE(of, sht3x_of_match);
+
static struct i2c_driver sht3x_i2c_driver = {
- .driver.name = "sht3x",
+ .driver = {
+ .name = "sht3x",
+ .of_match_table = sht3x_of_match,
+ },
.probe = sht3x_probe,
.id_table = sht3x_ids,
};
--
2.34.1