Skip to contentSkip to conversation

hwmon: (tmp102) Change mode to read label property

PATCH In review Flaviu Nistor 3 participants 3 messages May 9 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwmon: (tmp102) Change mode to read label property

Replace of_property_read_string() with the preferred device_property_read_string() in the probe function to read the device label property, improving the driver compatibility since this method is not limited to Device Tree only.

---
 drivers/hwmon/tmp102.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/tmp102.c +1 -1
index 3aa1a3fbeaa9..a89cc49798f5 100644
@@ -313,7 +313,7 @@ static int tmp102_probe(struct i2c_client *client)
 	if (!tmp102)
 		return -ENOMEM;
 
-	of_property_read_string(dev->of_node, "label", &tmp102->label);
+	device_property_read_string(dev, "label", &tmp102->label);
 
 	i2c_set_clientdata(client, tmp102);
 
Signature · 1 line
2.43.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] Incomplete transition to firmware-agnostic API due to remaining `of_match_ptr()` usage. - [Low]…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Incomplete transition to firmware-agnostic API due to remaining of_match_ptr() usage.
- [Low] Missing inclusion of <linux/property.h> for device_property_read_string(). --

commit 1666c25db837ad9f0af1e26c9adc185e78ab62e5
Author: Flaviu Nistor <[email protected]>

hwmon: (tmp102) Change mode to read label property

This commit replaces the Device Tree specific of_property_read_string() with the firmware-agnostic device_property_read_string() in the probe function. This is intended to improve driver compatibility beyond just Device Tree.

Quoted 5 lines

Replace of_property_read_string() with the preferred device_property_read_string() in the probe function to read the device label property, improving the driver compatibility since this method is not limited to Device Tree only.

If the goal is to improve compatibility beyond Device Tree, should the driver also drop the use of of_match_ptr() around the match table?

When the kernel is configured without CONFIG_OF (such as on ACPI-only systems leveraging PRP0001 for DT-style matching), of_match_ptr() evaluates to NULL.

This drops the match table entirely and prevents the driver from binding, which seems to contradict the intent of this patch.

drivers/hwmon/tmp102.c static int tmp102_probe(struct i2c_client *client) · line 316

Quoted 10 lines
drivers/hwmon/tmp102.c +1 -1
index 3aa1a3fbeaa92..a89cc49798f54 100644
@@ -313,7 +313,7 @@ static int tmp102_probe(struct i2c_client *client)
 	if (!tmp102)
 		return -ENOMEM;
 
-	of_property_read_string(dev->of_node, "label", &tmp102->label);
+	device_property_read_string(dev, "label", &tmp102->label);

Does this code require an explicit inclusion of <linux/property.h>?

While it may currently compile due to implicit transitive includes, relying on them is fragile and could cause build regressions if those headers are refactored in the future.

Quoted 3 lines
drivers/hwmon/tmp102.c +0 -0
 	i2c_set_clientdata(client, tmp102);
 
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer
#2 lore raw
In reply to Flaviu Nistor
Quoted 6 lines · Flaviu Nistor

Replace of_property_read_string() with the preferred device_property_read_string() in the probe function to read the device label property, improving the driver compatibility since this method is not limited to Device Tree only.

The subject of this patch is completely off ...
"change mode" - what does this even mean ?

Quoted 10 lines
---
  drivers/hwmon/tmp102.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/tmp102.c +0 -0
index 3aa1a3fbeaa9..a89cc49798f5 100644

drivers/hwmon/tmp102.c static int tmp102_probe(struct i2c_client *client) · line 317

Quoted 6 lines
drivers/hwmon/tmp102.c +1 -1
@@ -313,7 +313,7 @@ static int tmp102_probe(struct i2c_client *client)
  	if (!tmp102)
  		return -ENOMEM;
 
-	of_property_read_string(dev->of_node, "label", &tmp102->label);
+	device_property_read_string(dev, "label", &tmp102->label);
 

Changing this also requires changing include files. Instead of including linux/of.h, you'll need to include linux/mod_devicetable.h and linux/property.h.

Thanks,
Guenter