diff mbox series

[1/2] hwmon: (sht3x) add devicetree support

Message ID 20241119140725.75297-1-hunterteaegg@126.com (mailing list archive)
State Changes Requested
Headers show
Series [1/2] hwmon: (sht3x) add devicetree support | expand

Commit Message

JuenKit Yip Nov. 19, 2024, 2:07 p.m. UTC
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(-)

Comments

Krzysztof Kozlowski Nov. 19, 2024, 2:13 p.m. UTC | #1
On 19/11/2024 15:07, JuenKit Yip wrote:
> 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 },
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
Guenter Roeck Nov. 19, 2024, 2:48 p.m. UTC | #2
On 11/19/24 06:07, JuenKit Yip wrote:
> 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 },

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.

> +	{},

Unnecessary ",".

Guenter
diff mbox series

Patch

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,
 };