Skip to contentSkip to conversation

hwmon: (tmp401) Add of_match_table

PATCH Superseded Camel Guo 3 participants 3 messages Apr 29, 2022 – May 2, 2022 Hardware monitoring

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Camel Guo

author
#0 lore raw

PATCH 1/1 hwmon: (tmp401) Add of_match_table

Add the missing of_match_table to allow device tree probing

---
 drivers/hwmon/tmp401.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/hwmon/tmp401.c +11 -0
index a58a2f31a07e..cc0a1c219b1f 100644
@@ -750,10 +750,21 @@ static int tmp401_probe(struct i2c_client *client)
 	return 0;
 }
 
+static const struct of_device_id __maybe_unused tmp4xx_of_match[] = {
+	{ .compatible = "ti,tmp401", },
+	{ .compatible = "ti,tmp411", },
+	{ .compatible = "ti,tmp431", },
+	{ .compatible = "ti,tmp432", },
+	{ .compatible = "ti,tmp435", },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, tmp4xx_of_match);
+
 static struct i2c_driver tmp401_driver = {
 	.class		= I2C_CLASS_HWMON,
 	.driver = {
 		.name	= "tmp401",
+		.of_match_table = of_match_ptr(tmp4xx_of_match),
 	},
 	.probe_new	= tmp401_probe,
 	.id_table	= tmp401_id,
Signature · 1 line
2.30.2
maintainer
#1 lore raw
Quoted 2 lines · Camel Guo

Add the missing of_match_table to allow device tree probing

I2C devices probe based on the I2C device table even on devicetree systems, so this isn't a correct statement. Please provide evidence and explain in detail the circumstances where this does not work.

Guenter

Quoted 31 lines
---
  drivers/hwmon/tmp401.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
drivers/hwmon/tmp401.c +11 -0
index a58a2f31a07e..cc0a1c219b1f 100644
@@ -750,10 +750,21 @@ static int tmp401_probe(struct i2c_client *client)
  	return 0;
  }
 
+static const struct of_device_id __maybe_unused tmp4xx_of_match[] = {
+	{ .compatible = "ti,tmp401", },
+	{ .compatible = "ti,tmp411", },
+	{ .compatible = "ti,tmp431", },
+	{ .compatible = "ti,tmp432", },
+	{ .compatible = "ti,tmp435", },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, tmp4xx_of_match);
+
  static struct i2c_driver tmp401_driver = {
  	.class		= I2C_CLASS_HWMON,
  	.driver = {
  		.name	= "tmp401",
+		.of_match_table = of_match_ptr(tmp4xx_of_match),
  	},
  	.probe_new	= tmp401_probe,
  	.id_table	= tmp401_id,
#2 lore raw
Quoted 7 lines · Guenter Roeck
Quoted 2 lines · Camel Guo

Add the missing of_match_table to allow device tree probing

I2C devices probe based on the I2C device table even on devicetree systems, so this isn't a correct statement. Please provide evidence and explain in detail the circumstances where this does not work.

Commit message was updated in v2. Please check out v2 instead.

Quoted 35 lines

Guenter

Quoted 31 lines

---
   drivers/hwmon/tmp401.c | 11 +++++++++++

   1 file changed, 11 insertions(+)
drivers/hwmon/tmp401.c +11 -0
index a58a2f31a07e..cc0a1c219b1f 100644
@@ -750,10 +750,21 @@ static int tmp401_probe(struct i2c_client *client)
         return 0;
    }
 
+static const struct of_device_id __maybe_unused tmp4xx_of_match[] = {
+     { .compatible = "ti,tmp401", },
+     { .compatible = "ti,tmp411", },
+     { .compatible = "ti,tmp431", },
+     { .compatible = "ti,tmp432", },
+     { .compatible = "ti,tmp435", },
+     { },
+};
+MODULE_DEVICE_TABLE(of, tmp4xx_of_match);
+
    static struct i2c_driver tmp401_driver = {
         .class          = I2C_CLASS_HWMON,
         .driver = {
                 .name   = "tmp401",
+             .of_match_table = of_match_ptr(tmp4xx_of_match),
         },
         .probe_new      = tmp401_probe,
         .id_table       = tmp401_id,