of: Add of_property_present() helper
Rob Herring
maintainerPATCH 1/2 of: Add of_property_present() helper
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.
---
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(+)
include/linux/of.h +5 -0
@@ -1537,6 +1537,11 @@ static inline bool of_device_is_system_power_controller(const struct device_nodereturn 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 */
Signature · 1 line
2.39.1
Rob Herring
maintainerPATCH 2/2 of: Use of_property_present() helper
Use of_property_present() instead of of_get_property/of_find_property() in places where we just need to test presence of a property.
--- drivers/of/platform.c | 2 +- drivers/of/property.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/of/platform.c +1 -1
@@ -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
drivers/of/property.c +1 -1
@@ -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);
Signature · 1 line
2.39.1
Quoted 18 lines · Rob Herring
Add an
of_property_present()function similar tofwnode_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 <[email protected]>---
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(+)include/linux/of.h +0
-0@@ -1537,6 +1537,11 @@ static inline bool of_device_is_system_power_controller(const struct device_nodereturn of_property_read_bool (np,"system-power-controller" );
include/linux/of.h static inline bool of_device_is_system_power_controller(const struct device_node · line 1547
Quoted 10 lines
include/linux/of.h +5
-0} +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:
Test was boot of 32 bit arm devboard with full devicetree unittest