All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] hwmon: (tmp102) Use device_property_read_string API
@ 2026-05-09 12:15 Flaviu Nistor
  2026-05-09 12:28 ` sashiko-bot
  0 siblings, 1 reply; 3+ messages in thread
From: Flaviu Nistor @ 2026-05-09 12:15 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: Flaviu Nistor, linux-hwmon, linux-kernel

Replace of_property_read_string() with the preferded
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.

Signed-off-by: Flaviu Nistor <flaviu.nistor@gmail.com>
---
 drivers/hwmon/tmp102.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c
index 3aa1a3fbeaa9..79578b28a91d 100644
--- a/drivers/hwmon/tmp102.c
+++ b/drivers/hwmon/tmp102.c
@@ -15,7 +15,8 @@
 #include <linux/jiffies.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
-#include <linux/of.h>
+#include <linux/mod_devicetable.h>
+#include <linux/property.h>
 
 #define	DRIVER_NAME "tmp102"
 
@@ -313,7 +314,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);
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] hwmon: (tmp102) Use device_property_read_string API
  2026-05-09 12:15 [PATCH v2] hwmon: (tmp102) Use device_property_read_string API Flaviu Nistor
@ 2026-05-09 12:28 ` sashiko-bot
  2026-05-09 14:09   ` Guenter Roeck
  0 siblings, 1 reply; 3+ messages in thread
From: sashiko-bot @ 2026-05-09 12:28 UTC (permalink / raw)
  To: Flaviu Nistor; +Cc: linux-hwmon

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The patch introduces an implicit header dependency and leaves cross-firmware compatibility incomplete by retaining the `of_match_ptr()` macro.
--

commit 8699d5dea7c2614372ba1cab8f6b99f73ebebe1e
Author: Flaviu Nistor <flaviu.nistor@gmail.com>
Subject: hwmon: (tmp102) Use device_property_read_string API

This patch replaces of_property_read_string() with
device_property_read_string() for reading the device label. It aims to
improve compatibility since the new method is not limited to Device Tree.

> improving the driver
> compatibility since this method is not limited to
> Device Tree only.

If the goal is to improve non-Device Tree compatibility, shouldn't
of_match_ptr() also be removed from the i2c_driver struct? 

When CONFIG_OF is disabled on ACPI-only platforms, of_match_ptr()
evaluates to NULL. This prevents the standard PRP0001 mechanism from
matching the driver via compatible strings.

> diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c
> index 3aa1a3fbeaa92..79578b28a91d3 100644
> --- a/drivers/hwmon/tmp102.c
> +++ b/drivers/hwmon/tmp102.c
> @@ -15,7 +15,8 @@
>  #include <linux/jiffies.h>
>  #include <linux/regmap.h>
>  #include <linux/regulator/consumer.h>
> -#include <linux/of.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/property.h>

Does removing this include create an implicit header dependency? 

The code still uses of_match_ptr() further down in the file:

drivers/hwmon/tmp102.c:
static struct i2c_driver tmp102_driver = {
	.driver.name	= DRIVER_NAME,
	.driver.of_match_table = of_match_ptr(tmp102_of_match),
	...
};

Since of_match_ptr() is defined in linux/of.h, the file now relies on
another header to implicitly include it. Dropping the of_match_ptr()
macro entirely would safely resolve this implicit dependency and fully
support the cross-firmware compatibility goal.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260509121511.60601-1-flaviu.nistor@gmail.com?part=1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] hwmon: (tmp102) Use device_property_read_string API
  2026-05-09 12:28 ` sashiko-bot
@ 2026-05-09 14:09   ` Guenter Roeck
  0 siblings, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2026-05-09 14:09 UTC (permalink / raw)
  To: Flaviu Nistor; +Cc: linux-hwmon

On 5/9/26 05:28, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] The patch introduces an implicit header dependency and leaves cross-firmware compatibility incomplete by retaining the `of_match_ptr()` macro.
> --
> 
> commit 8699d5dea7c2614372ba1cab8f6b99f73ebebe1e
> Author: Flaviu Nistor <flaviu.nistor@gmail.com>
> Subject: hwmon: (tmp102) Use device_property_read_string API
> 
> This patch replaces of_property_read_string() with
> device_property_read_string() for reading the device label. It aims to
> improve compatibility since the new method is not limited to Device Tree.
> 
>> improving the driver
>> compatibility since this method is not limited to
>> Device Tree only.
> 
> If the goal is to improve non-Device Tree compatibility, shouldn't
> of_match_ptr() also be removed from the i2c_driver struct?
> 
> When CONFIG_OF is disabled on ACPI-only platforms, of_match_ptr()
> evaluates to NULL. This prevents the standard PRP0001 mechanism from
> matching the driver via compatible strings.
> 
>> diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c
>> index 3aa1a3fbeaa92..79578b28a91d3 100644
>> --- a/drivers/hwmon/tmp102.c
>> +++ b/drivers/hwmon/tmp102.c
>> @@ -15,7 +15,8 @@
>>   #include <linux/jiffies.h>
>>   #include <linux/regmap.h>
>>   #include <linux/regulator/consumer.h>
>> -#include <linux/of.h>
>> +#include <linux/mod_devicetable.h>
>> +#include <linux/property.h>
> 
> Does removing this include create an implicit header dependency?
> 
> The code still uses of_match_ptr() further down in the file:
> 
> drivers/hwmon/tmp102.c:
> static struct i2c_driver tmp102_driver = {
> 	.driver.name	= DRIVER_NAME,
> 	.driver.of_match_table = of_match_ptr(tmp102_of_match),
> 	...
> };
> 
> Since of_match_ptr() is defined in linux/of.h, the file now relies on
> another header to implicitly include it. Dropping the of_match_ptr()
> macro entirely would safely resolve this implicit dependency and fully
> support the cross-firmware compatibility goal.
> 

Please listen. Sashiko told you that you should drop of_match_ptr() already
in its feedback to v1.

Guenter


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-09 14:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-09 12:15 [PATCH v2] hwmon: (tmp102) Use device_property_read_string API Flaviu Nistor
2026-05-09 12:28 ` sashiko-bot
2026-05-09 14:09   ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.