From 3698477e339a902f31f2181805e1026e56612188 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Fri, 31 Mar 2023 11:04:53 +0200 Subject: of: implement of_property_present helper We have various code using of_find_property(np, propname, NULL) to detect whether propname exists and some more that uses of_property_read_bool on non-boolean properties. There's work underway in Linux to switch a lot of these instances to of_property_present[1]. Let's prepare for porting Linux code that uses the property by adding it. [1]: https://lore.kernel.org/linux-devicetree/?q=of_property_present Signed-off-by: Ahmad Fatoum Link: https://lore.barebox.org/20230331090453.1424337-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer --- include/of.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/of.h b/include/of.h index 0c5c2c0205..b88f39ebfa 100644 --- a/include/of.h +++ b/include/of.h @@ -1039,8 +1039,10 @@ static inline int of_property_read_string_index(const struct device_node *np, * @np: device node from which the property value is to be read. * @propname: name of the property to be searched. * - * Search for a property in a device node. - * Returns true if the property exist false otherwise. + * Search for a boolean property in a device node. Usage on non-boolean + * property types is deprecated. + + * Return: true if the property exist false otherwise. */ static inline bool of_property_read_bool(const struct device_node *np, const char *propname) @@ -1050,6 +1052,20 @@ static inline bool of_property_read_bool(const struct device_node *np, return prop ? true : false; } +/** + * of_property_present - Test if a property is present in a node + * @np: device node to search for the property. + * @propname: name of the property to be searched. + * + * Test for a property present in a device node. + * + * Return: true if the property exists false otherwise. + */ +static inline bool of_property_present(const struct device_node *np, const char *propname) +{ + return of_property_read_bool(np, propname); +} + static inline int of_property_read_u8(const struct device_node *np, const char *propname, u8 *out_value) -- cgit v1.2.1