public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] hwmon: (sht3x) add devicetree support
@ 2024-11-19 14:07 JuenKit Yip
  2024-11-19 14:07 ` [PATCH 2/2] dt-bindings: trivial-devices: add sensirion,sht3x JuenKit Yip
  0 siblings, 1 reply; 3+ messages in thread
From: JuenKit Yip @ 2024-11-19 14:07 UTC (permalink / raw)
  To: robh, krzk+dt, conor+dt, jdelvare, linux, peteryin.openbmc,
	noahwang.wang, festevam, marex, lukas, devicetree, linux-kernel,
	linux-hwmon
  Cc: JuenKit Yip

add "compatible" property for supporting devicetree

Signed-off-by: JuenKit Yip <hunterteaegg@126.com>
---
 drivers/hwmon/sht3x.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/sht3x.c b/drivers/hwmon/sht3x.c
index 650b0bcc2359..2ac1537b3e3e 100644
--- a/drivers/hwmon/sht3x.c
+++ b/drivers/hwmon/sht3x.c
@@ -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,
 };
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-20 17:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20241119092208.74360-1-hunterteaegg@126.com>
2024-11-20 17:33 ` [PATCH 2/2] dt-bindings: trivial-devices: add sensirion,sht3x Conor Dooley
2024-11-19 14:07 [PATCH 1/2] hwmon: (sht3x) add devicetree support JuenKit Yip
2024-11-19 14:07 ` [PATCH 2/2] dt-bindings: trivial-devices: add sensirion,sht3x JuenKit Yip
2024-11-19 14:28   ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox