From: JuenKit Yip <hunterteaegg@126.com>
To: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
jdelvare@suse.com, linux@roeck-us.net,
peteryin.openbmc@gmail.com, noahwang.wang@outlook.com,
festevam@gmail.com, marex@denx.de, lukas@wunner.de,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hwmon@vger.kernel.org
Cc: JuenKit Yip <hunterteaegg@126.com>
Subject: [PATCH 1/2] hwmon: (sht3x) add devicetree support
Date: Tue, 19 Nov 2024 09:07:24 -0500 [thread overview]
Message-ID: <20241119140725.75297-1-hunterteaegg@126.com> (raw)
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
next reply other threads:[~2024-11-19 14:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-19 14:07 JuenKit Yip [this message]
2024-11-19 14:07 ` [PATCH 2/2] dt-bindings: trivial-devices: add sensirion,sht3x JuenKit Yip
2024-11-19 14:28 ` Krzysztof Kozlowski
2024-11-19 14:13 ` [PATCH 1/2] hwmon: (sht3x) add devicetree support Krzysztof Kozlowski
2024-11-19 14:48 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241119140725.75297-1-hunterteaegg@126.com \
--to=hunterteaegg@126.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=jdelvare@suse.com \
--cc=krzk+dt@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=lukas@wunner.de \
--cc=marex@denx.de \
--cc=noahwang.wang@outlook.com \
--cc=peteryin.openbmc@gmail.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox