diff mbox series

[1/2] of: Add of_property_present() helper

Message ID 20230215215547.691573-1-robh@kernel.org
State New
Headers show
Series [1/2] of: Add of_property_present() helper | expand

Commit Message

Rob Herring Feb. 15, 2023, 9:55 p.m. UTC
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(+)

Comments

Frank Rowand Feb. 16, 2023, 12:23 a.m. UTC | #1
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
diff mbox series

Patch

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
  */