linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: Use of_property_present() for testing DT property presence
@ 2023-03-10 14:47 Rob Herring
  2023-03-10 16:30 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Rob Herring @ 2023-03-10 14:47 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy
  Cc: devicetree, linux-hwmon, linuxppc-dev, linux-kernel

It is preferred to use typed property access functions (i.e.
of_property_read_<type> functions) rather than low-level
of_get_property/of_find_property functions for reading properties. As
part of this, convert of_get_property/of_find_property calls to the
recently added of_property_present() helper when we just want to test
for presence of a property and nothing more.

Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/hwmon/ibmpowernv.c | 4 ++--
 drivers/hwmon/pwm-fan.c    | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c
index 8e3724728cce..594254d6a72d 100644
--- a/drivers/hwmon/ibmpowernv.c
+++ b/drivers/hwmon/ibmpowernv.c
@@ -456,9 +456,9 @@ static int populate_attr_groups(struct platform_device *pdev)
 		 */
 		if (!of_property_read_string(np, "label", &label))
 			sensor_groups[type].attr_count++;
-		if (of_find_property(np, "sensor-data-min", NULL))
+		if (of_property_present(np, "sensor-data-min"))
 			sensor_groups[type].attr_count++;
-		if (of_find_property(np, "sensor-data-max", NULL))
+		if (of_property_present(np, "sensor-data-max"))
 			sensor_groups[type].attr_count++;
 	}
 
diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 83a347ca35da..57928d270015 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -427,7 +427,7 @@ static int pwm_fan_of_get_cooling_data(struct device *dev,
 	struct device_node *np = dev->of_node;
 	int num, i, ret;
 
-	if (!of_find_property(np, "cooling-levels", NULL))
+	if (!of_property_present(np, "cooling-levels"))
 		return 0;
 
 	ret = of_property_count_u32_elems(np, "cooling-levels");
-- 
2.39.2


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

* Re: [PATCH] hwmon: Use of_property_present() for testing DT property presence
  2023-03-10 14:47 [PATCH] hwmon: Use of_property_present() for testing DT property presence Rob Herring
@ 2023-03-10 16:30 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2023-03-10 16:30 UTC (permalink / raw)
  To: Rob Herring
  Cc: Jean Delvare, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, devicetree, linux-hwmon, linuxppc-dev,
	linux-kernel

On Fri, Mar 10, 2023 at 08:47:06AM -0600, Rob Herring wrote:
> It is preferred to use typed property access functions (i.e.
> of_property_read_<type> functions) rather than low-level
> of_get_property/of_find_property functions for reading properties. As
> part of this, convert of_get_property/of_find_property calls to the
> recently added of_property_present() helper when we just want to test
> for presence of a property and nothing more.
> 
> Signed-off-by: Rob Herring <robh@kernel.org>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/ibmpowernv.c | 4 ++--
>  drivers/hwmon/pwm-fan.c    | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c
> index 8e3724728cce..594254d6a72d 100644
> --- a/drivers/hwmon/ibmpowernv.c
> +++ b/drivers/hwmon/ibmpowernv.c
> @@ -456,9 +456,9 @@ static int populate_attr_groups(struct platform_device *pdev)
>  		 */
>  		if (!of_property_read_string(np, "label", &label))
>  			sensor_groups[type].attr_count++;
> -		if (of_find_property(np, "sensor-data-min", NULL))
> +		if (of_property_present(np, "sensor-data-min"))
>  			sensor_groups[type].attr_count++;
> -		if (of_find_property(np, "sensor-data-max", NULL))
> +		if (of_property_present(np, "sensor-data-max"))
>  			sensor_groups[type].attr_count++;
>  	}
>  
> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> index 83a347ca35da..57928d270015 100644
> --- a/drivers/hwmon/pwm-fan.c
> +++ b/drivers/hwmon/pwm-fan.c
> @@ -427,7 +427,7 @@ static int pwm_fan_of_get_cooling_data(struct device *dev,
>  	struct device_node *np = dev->of_node;
>  	int num, i, ret;
>  
> -	if (!of_find_property(np, "cooling-levels", NULL))
> +	if (!of_property_present(np, "cooling-levels"))
>  		return 0;
>  
>  	ret = of_property_count_u32_elems(np, "cooling-levels");

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

end of thread, other threads:[~2023-03-10 16:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-10 14:47 [PATCH] hwmon: Use of_property_present() for testing DT property presence Rob Herring
2023-03-10 16:30 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).