devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] of: Add of_property_present() helper
@ 2023-02-15 21:55 Rob Herring
  2023-02-15 21:55 ` [PATCH 2/2] of: Use " Rob Herring
  2023-02-16  0:23 ` [PATCH 1/2] of: Add " Frank Rowand
  0 siblings, 2 replies; 3+ messages in thread
From: Rob Herring @ 2023-02-15 21:55 UTC (permalink / raw)
  To: Frank Rowand; +Cc: devicetree, linux-kernel

Add an of_property_present() function similar to
fwnode_property_present(). of_property_read_bool() could be used
directly, but it is cleaner to not use it on non-boolean properties.

Signed-off-by: Rob Herring <robh@kernel.org>
---
I plan to add this for v6.3 and send most of the conversion patches in
the next cycle.
---
 include/linux/of.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/of.h b/include/linux/of.h
index 8b9f94386dc3..b3e04021186f 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -1537,6 +1537,11 @@ static inline bool of_device_is_system_power_controller(const struct device_node
 	return of_property_read_bool(np, "system-power-controller");
 }
 
+static inline bool of_property_present(const struct device_node *np, const char *propname)
+{
+	return of_property_read_bool(np, propname);
+}
+
 /*
  * Overlay support
  */
-- 
2.39.1


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

* [PATCH 2/2] of: Use of_property_present() helper
  2023-02-15 21:55 [PATCH 1/2] of: Add of_property_present() helper Rob Herring
@ 2023-02-15 21:55 ` Rob Herring
  2023-02-16  0:23 ` [PATCH 1/2] of: Add " Frank Rowand
  1 sibling, 0 replies; 3+ messages in thread
From: Rob Herring @ 2023-02-15 21:55 UTC (permalink / raw)
  To: Frank Rowand; +Cc: devicetree, linux-kernel

Use of_property_present() instead of of_get_property/of_find_property()
in places where we just need to test presence of a property.

Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/of/platform.c | 2 +-
 drivers/of/property.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index b3878a98d27f..284379e67649 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -529,7 +529,7 @@ static int __init of_platform_default_populate_init(void)
 		int ret;
 
 		/* Check if we have a MacOS display without a node spec */
-		if (of_get_property(of_chosen, "linux,bootx-noscreen", NULL)) {
+		if (of_property_present(of_chosen, "linux,bootx-noscreen")) {
 			/*
 			 * The old code tried to work out which node was the MacOS
 			 * display based on the address. I'm dropping that since the
diff --git a/drivers/of/property.c b/drivers/of/property.c
index 134cfc980b70..ff71d2ac26cb 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -1086,7 +1086,7 @@ static struct device_node *of_get_compat_node(struct device_node *np)
 			np = NULL;
 		}
 
-		if (of_find_property(np, "compatible", NULL))
+		if (of_property_present(np, "compatible"))
 			break;
 
 		np = of_get_next_parent(np);
-- 
2.39.1


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

* Re: [PATCH 1/2] of: Add of_property_present() helper
  2023-02-15 21:55 [PATCH 1/2] of: Add of_property_present() helper Rob Herring
  2023-02-15 21:55 ` [PATCH 2/2] of: Use " Rob Herring
@ 2023-02-16  0:23 ` Frank Rowand
  1 sibling, 0 replies; 3+ messages in thread
From: Frank Rowand @ 2023-02-16  0:23 UTC (permalink / raw)
  To: Rob Herring; +Cc: devicetree, linux-kernel

On 2/15/23 15:55, Rob Herring wrote:
> Add an of_property_present() function similar to
> fwnode_property_present(). of_property_read_bool() could be used
> directly, but it is cleaner to not use it on non-boolean properties.
> 
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
> I plan to add this for v6.3 and send most of the conversion patches in
> the next cycle.
> ---
>  include/linux/of.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/include/linux/of.h b/include/linux/of.h
> index 8b9f94386dc3..b3e04021186f 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -1537,6 +1537,11 @@ static inline bool of_device_is_system_power_controller(const struct device_node
>  	return of_property_read_bool(np, "system-power-controller");
>  }
>  
> +static inline bool of_property_present(const struct device_node *np, const char *propname)
> +{
> +	return of_property_read_bool(np, propname);
> +}
> +
>  /*
>   * Overlay support
>   */

of_property_present() needs a docbook header.

Otherwise, for patches 1 and 2:

Reviewed-by: Frank Rowand <frowand.list@gmail.com>
Tested-by: Frank Rowand <frowand.list@gmail.com>

Test was boot of 32 bit arm devboard with full devicetree unittest

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

end of thread, other threads:[~2023-02-16  0:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-15 21:55 [PATCH 1/2] of: Add of_property_present() helper Rob Herring
2023-02-15 21:55 ` [PATCH 2/2] of: Use " Rob Herring
2023-02-16  0:23 ` [PATCH 1/2] of: Add " Frank Rowand

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).