Skip to contentSkip to conversation

hwmon: (sht3x) add devicetree support

PATCH In review JuenKit Yip 3 participants 5 messages Nov 19, 2024

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

PATCH 1/2 hwmon: (sht3x) add devicetree support

add "compatible" property for supporting devicetree

---
 drivers/hwmon/sht3x.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/hwmon/sht3x.c +17 -1
index 650b0bcc2359..2ac1537b3e3e 100644
@@ -954,6 +954,19 @@ static int sht3x_probe(struct i2c_client *client)
 	return PTR_ERR_OR_ZERO(hwmon_dev);
 }
 
+/* devicetree ID table */
+static const struct of_device_id sht3x_of_match[] = {
+	{ .compatible = "sensirion,sht30", .data = (void *)sht3x },
+	{ .compatible = "sensirion,sht31", .data = (void *)sht3x },
+	{ .compatible = "sensirion,sht35", .data = (void *)sht3x },
+	{ .compatible = "sensirion,sts30", .data = (void *)sts3x },
+	{ .compatible = "sensirion,sts31", .data = (void *)sts3x },
+	{ .compatible = "sensirion,sts35", .data = (void *)sts3x },
+	{},
+};
+
+MODULE_DEVICE_TABLE(of, sht3x_of_match);
+
 /* device ID table */
 static const struct i2c_device_id sht3x_ids[] = {
 	{"sht3x", sht3x},
@@ -964,7 +977,10 @@ static const struct i2c_device_id sht3x_ids[] = {
 MODULE_DEVICE_TABLE(i2c, sht3x_ids);
 
 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,
 };
Signature · 1 line
2.39.5
#1 lore raw
Quoted 12 lines · JuenKit Yip

add "compatible" property for supporting devicetree

---
 drivers/hwmon/sht3x.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/hwmon/sht3x.c +0 -0
index 650b0bcc2359..2ac1537b3e3e 100644

drivers/hwmon/sht3x.c static int sht3x_probe(struct i2c_client *client) · line 959

Quoted 6 lines
drivers/hwmon/sht3x.c +3 -0
@@ -954,6 +954,19 @@ static int sht3x_probe(struct i2c_client *client)
 	return PTR_ERR_OR_ZERO(hwmon_dev);
 }
 
+/* devicetree ID table */
+static const struct of_device_id sht3x_of_match[] = {
+	{ .compatible = "sensirion,sht30", .data = (void *)sht3x },

This does not match your binding at all. Also all SHT/STS devices are compatible, so express it in the binding with a fallback.

Anyway, you cannot just send half of patch afterwards without resolving previous comments. If this is v2, mark it as v2. If this is a resend, mark it as RESEND.

See other examples on mailing lists (lore.kernel.org) and read submitting patches document.

Best regards,
Krzysztof

#2 lore raw

PATCH 2/2 dt-bindings: trivial-devices: add sensirion,sht3x

In reply to JuenKit Yip

add sensirion,sht3x as trivial device for devicetree support

---
 Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/trivial-devices.yaml +2 -0
index 9bf0fb17a05e..be006b21b1ea 100644
@@ -333,6 +333,8 @@ properties:
           - sensirion,sgp40
             # Sensirion low power multi-pixel gas sensor with I2C interface
           - sensirion,sgpc3
+            # Sensirion SHT3x-DIS humidity and temperature sensor with I2C interface
+          - sensirion,sht3x
             # Sensirion temperature & humidity sensor with I2C interface
           - sensirion,sht4x
             # Sensortek 3 axis accelerometer
Signature · 1 line
2.39.5
#3 lore raw

Re: [PATCH 2/2] dt-bindings: trivial-devices: add sensirion,sht3x

Quoted 5 lines · JuenKit Yip

add sensirion,sht3x as trivial device for devicetree support

---
 Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++

I see now you sent the same binding to proper addresses. This is therefore a RESEND and please mark it appropriately in the future. git format-patch -2 --subject-prefix="PATCH RESEND"

or similar command for b4.

Best regards,
Krzysztof

maintainer
#4 lore raw
In reply to JuenKit Yip
Quoted 13 lines · JuenKit Yip

add "compatible" property for supporting devicetree

---
  drivers/hwmon/sht3x.c | 18 +++++++++++++++++-
  1 file changed, 17 insertions(+), 1 deletion(-)
drivers/hwmon/sht3x.c +0 -0
index 650b0bcc2359..2ac1537b3e3e 100644
@@ -954,6 +954,19 @@ static int sht3x_probe(struct i2c_client *client)
  	return PTR_ERR_OR_ZERO(hwmon_dev);

drivers/hwmon/sht3x.c static int sht3x_probe(struct i2c_client *client) · line 964

Quoted 10 lines
drivers/hwmon/sht3x.c +8 -0
  }
 
+/* devicetree ID table */
+static const struct of_device_id sht3x_of_match[] = {
+	{ .compatible = "sensirion,sht30", .data = (void *)sht3x },
+	{ .compatible = "sensirion,sht31", .data = (void *)sht3x },
+	{ .compatible = "sensirion,sht35", .data = (void *)sht3x },
+	{ .compatible = "sensirion,sts30", .data = (void *)sts3x },
+	{ .compatible = "sensirion,sts31", .data = (void *)sts3x },
+	{ .compatible = "sensirion,sts35", .data = (void *)sts3x },

This either needs to be "sensirion,sht3x" and "sensirion,sts3x", and the matching entries need to be documented in the bindings document, or each individual entry needs to be listed in the bindings document. Also, this patch should be patch 2/2, and it needs to pass checkpatch without warning.

drivers/hwmon/sht3x.c static int sht3x_probe(struct i2c_client *client) · line 965

Quoted 1 line
drivers/hwmon/sht3x.c +1 -0
+	{},

Unnecessary ",".

Guenter