Skip to contentSkip to conversation

hwmon: (sht3x) add device-tree support

RFC PATCH In review JuenKit Yip 2 participants 2 messages Jun 21, 2023 1 message not in the archive Hardware monitoring

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

RFC PATCH 2/2 hwmon: (sht3x) add device-tree support

add "compatible" property for supporting device-tree

---
 drivers/hwmon/sht3x.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/hwmon/sht3x.c +11 -1
index 31013b5b6..edcf6820c 100644
@@ -923,8 +923,18 @@ static const struct i2c_device_id sht3x_ids[] = {
 
 MODULE_DEVICE_TABLE(i2c, sht3x_ids);
 
+/* devicetree ID table */
+static const struct of_device_id sht3x_of_match[] = {
+	{ .compatible = "sensirion,sht3x" },
+	{ .compatible = "sensirion,sts3x" },
+	{},
+};
+
 static struct i2c_driver sht3x_i2c_driver = {
-	.driver.name = "sht3x",
+	.driver = {
+		.name = "sht3x",
+		.of_match_table = of_match_ptr(sht3x_of_match),
+	},
 	.probe       = sht3x_probe,
 	.id_table    = sht3x_ids,
 };
Signature · 1 line
2.30.2
maintainer
#2 lore raw
Quoted 12 lines · JuenKit Yip

add "compatible" property for supporting device-tree

---
 drivers/hwmon/sht3x.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/hwmon/sht3x.c +0 -0
index 31013b5b6..edcf6820c 100644

drivers/hwmon/sht3x.c static const struct i2c_device_id sht3x_ids[] = { · line 929

Quoted 7 lines
drivers/hwmon/sht3x.c +4 -0
@@ -923,8 +923,18 @@ static const struct i2c_device_id sht3x_ids[] = {
 
 MODULE_DEVICE_TABLE(i2c, sht3x_ids);
 
+/* devicetree ID table */
+static const struct of_device_id sht3x_of_match[] = {
+	{ .compatible = "sensirion,sht3x" },
+	{ .compatible = "sensirion,sts3x" },

Also needs a separate patch addding the two devices to Documentation/devicetree/bindings/trivial-devices.yaml.

Quoted 15 lines
drivers/hwmon/sht3x.c +7 -1
+	{},
+};
+
 static struct i2c_driver sht3x_i2c_driver = {
-	.driver.name = "sht3x",
+	.driver = {
+		.name = "sht3x",
+		.of_match_table = of_match_ptr(sht3x_of_match),
+	},
 	.probe       = sht3x_probe,
 	.id_table    = sht3x_ids,
 };
Signature · 1 line
2.30.2