diff mbox series

[2/3] hwmon: (sht3x) add device-tree support

Message ID DB4PR10MB62616C555E4D76672BDC6B7B9220A@DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM (mailing list archive)
State Changes Requested
Headers show
Series [1/3] hwmon: (sht3x) convert some of sysfs interface to hwmon | expand

Commit Message

JuenKit Yip June 24, 2023, 4:01 p.m. UTC
From: JuenKit Yip <JuenKit_Yip@hotmail.com>

add "compatible" property for supporting device-tree

Signed-off-by: JuenKit Yip <JuenKit_Yip@hotmail.com>
---
 drivers/hwmon/sht3x.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Guenter Roeck June 24, 2023, 4:34 p.m. UTC | #1
On 6/24/23 09:01, JuenKit_Yip@hotmail.com wrote:
> From: JuenKit Yip <JuenKit_Yip@hotmail.com>
> 
> add "compatible" property for supporting device-tree
> 
> Signed-off-by: JuenKit Yip <JuenKit_Yip@hotmail.com>
> ---
>   drivers/hwmon/sht3x.c | 12 +++++++++++-
>   1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/sht3x.c b/drivers/hwmon/sht3x.c
> index 9b2dadd11eeb..e7648c011e5f 100644
> --- a/drivers/hwmon/sht3x.c
> +++ b/drivers/hwmon/sht3x.c
> @@ -925,8 +925,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" },
> +	{},
> +};

Add

MODULE_DEVICE_TABLE(of, sht3x_of_match);

> +
>   static struct i2c_driver sht3x_i2c_driver = {
> -	.driver.name = "sht3x",
> +	.driver = {
> +		.name = "sht3x",
> +		.of_match_table = of_match_ptr(sht3x_of_match),

Drop of_match_ptr().

> +	},
>   	.probe       = sht3x_probe,
>   	.id_table    = sht3x_ids,
>   };
diff mbox series

Patch

diff --git a/drivers/hwmon/sht3x.c b/drivers/hwmon/sht3x.c
index 9b2dadd11eeb..e7648c011e5f 100644
--- a/drivers/hwmon/sht3x.c
+++ b/drivers/hwmon/sht3x.c
@@ -925,8 +925,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,
 };